comparison org/sense.org @ 273:c39b8b29a79e

fixed ambigous in-text function references
author Robert McIntyre <rlm@mit.edu>
date Wed, 15 Feb 2012 06:56:47 -0700
parents be78d7bd6920
children 23aadf376e9d
comparison
equal deleted inserted replaced
271:5833b4ce877a 273:c39b8b29a79e
4 #+description: sensory utilities 4 #+description: sensory utilities
5 #+keywords: simulation, jMonkeyEngine3, clojure, simulated senses 5 #+keywords: simulation, jMonkeyEngine3, clojure, simulated senses
6 #+SETUPFILE: ../../aurellem/org/setup.org 6 #+SETUPFILE: ../../aurellem/org/setup.org
7 #+INCLUDE: ../../aurellem/org/level-0.org 7 #+INCLUDE: ../../aurellem/org/level-0.org
8 8
9
10 * Blender Utilities 9 * Blender Utilities
11 In blender, any object can be assigned an arbitray number of key-value 10 In blender, any object can be assigned an arbitray number of key-value
12 pairs which are called "Custom Properties". These are accessable in 11 pairs which are called "Custom Properties". These are accessable in
13 jMonkyeEngine when blender files are imported with the 12 jMonkyeEngine when blender files are imported with the
14 =BlenderLoader=. =(meta-data)= extracts these properties. 13 =BlenderLoader=. =meta-data= extracts these properties.
15 14
16 #+name: blender-1 15 #+name: blender-1
17 #+begin_src clojure 16 #+begin_src clojure
18 (defn meta-data 17 (defn meta-data
19 "Get the meta-data for a node created with blender." 18 "Get the meta-data for a node created with blender."
106 #+CAPTION: Head on view of the finger. In both the head and side views you can see the divide where the touch-sensors transition from high density to low density. 105 #+CAPTION: Head on view of the finger. In both the head and side views you can see the divide where the touch-sensors transition from high density to low density.
107 #+ATTR_HTML: width="300" 106 #+ATTR_HTML: width="300"
108 [[../images/finger-3.png]] 107 [[../images/finger-3.png]]
109 108
110 The following code loads images and gets the locations of the white 109 The following code loads images and gets the locations of the white
111 pixels so that they can be used to create senses. =(load-image)= finds 110 pixels so that they can be used to create senses. =load-image= finds
112 images using jMonkeyEngine's asset-manager, so the image path is 111 images using jMonkeyEngine's asset-manager, so the image path is
113 expected to be relative to the =assets= directory. Thanks to Dylan 112 expected to be relative to the =assets= directory. Thanks to Dylan
114 for the beautiful version of =(filter-pixels)=. 113 for the beautiful version of =filter-pixels=.
115 114
116 #+name: topology-1 115 #+name: topology-1
117 #+begin_src clojure 116 #+begin_src clojure
118 (defn load-image 117 (defn load-image
119 "Load an image as a BufferedImage using the asset-manager system." 118 "Load an image as a BufferedImage using the asset-manager system."
157 156
158 Information from the senses is transmitted to the brain via bundles of 157 Information from the senses is transmitted to the brain via bundles of
159 axons, whether it be the optic nerve or the spinal cord. While these 158 axons, whether it be the optic nerve or the spinal cord. While these
160 bundles more or less perserve the overall topology of a sense's 159 bundles more or less perserve the overall topology of a sense's
161 two-dimensional surface, they do not perserve the percise euclidean 160 two-dimensional surface, they do not perserve the percise euclidean
162 distances between every sensor. =(collapse)= is here to smoosh the 161 distances between every sensor. =collapse= is here to smoosh the
163 sensors described by a UV-map into a contigous region that still 162 sensors described by a UV-map into a contigous region that still
164 perserves the topology of the original sense. 163 perserves the topology of the original sense.
165 164
166 #+name: topology-2 165 #+name: topology-2
167 #+begin_src clojure 166 #+begin_src clojure
233 original-order))) 232 original-order)))
234 #+end_src 233 #+end_src
235 * Viewing Sense Data 234 * Viewing Sense Data
236 235
237 It's vital to /see/ the sense data to make sure that everything is 236 It's vital to /see/ the sense data to make sure that everything is
238 behaving as it should. =(view-sense)= and its helper, =(view-image)= 237 behaving as it should. =view-sense= and its helper, =view-image=
239 are here so that each sense can define its own way of turning 238 are here so that each sense can define its own way of turning
240 sense-data into pictures, while the actual rendering of said pictures 239 sense-data into pictures, while the actual rendering of said pictures
241 stays in one central place. =(points->image)= helps senses generate a 240 stays in one central place. =points->image= helps senses generate a
242 base image onto which they can overlay actual sense data. 241 base image onto which they can overlay actual sense data.
243 242
244 #+name: view-senses 243 #+name: view-senses
245 #+begin_src clojure 244 #+begin_src clojure
246 (in-ns 'cortex.sense) 245 (in-ns 'cortex.sense)
349 - Create a single top-level empty node whose name is the name of the sense 348 - Create a single top-level empty node whose name is the name of the sense
350 - Add empty nodes which each contain meta-data relevant 349 - Add empty nodes which each contain meta-data relevant
351 to the sense, including a UV-map describing the number/distribution 350 to the sense, including a UV-map describing the number/distribution
352 of sensors if applicipable. 351 of sensors if applicipable.
353 - Make each empty-node the child of the top-level 352 - Make each empty-node the child of the top-level
354 node. =(sense-nodes)= below generates functions to find these children. 353 node. =sense-nodes= below generates functions to find these children.
355 354
356 For touch, store the path to the UV-map which describes touch-sensors in the 355 For touch, store the path to the UV-map which describes touch-sensors in the
357 meta-data of the object to which that map applies. 356 meta-data of the object to which that map applies.
358 357
359 Each sense provides code that analyzes the Node structure of the 358 Each sense provides code that analyzes the Node structure of the
361 structure if necessary. 360 structure if necessary.
362 361
363 Empty nodes created in blender have no appearance or physical presence 362 Empty nodes created in blender have no appearance or physical presence
364 in jMonkeyEngine, but do appear in the scene graph. Empty nodes that 363 in jMonkeyEngine, but do appear in the scene graph. Empty nodes that
365 represent a sense which "follows" another geometry (like eyes and 364 represent a sense which "follows" another geometry (like eyes and
366 ears) follow the closest physical object. =(closest-node)= finds this 365 ears) follow the closest physical object. =closest-node= finds this
367 closest object given the Creature and a particular empty node. 366 closest object given the Creature and a particular empty node.
368 367
369 #+name: node-1 368 #+name: node-1
370 #+begin_src clojure 369 #+begin_src clojure
371 (defn sense-nodes 370 (defn sense-nodes
407 (.localToWorld object local-coordinate nil)) 406 (.localToWorld object local-coordinate nil))
408 #+end_src 407 #+end_src
409 408
410 ** Sense Binding 409 ** Sense Binding
411 410
412 =(bind-sense)= binds either a Camera or a Listener object to any 411 =bind-sense= binds either a Camera or a Listener object to any
413 object so that they will follow that object no matter how it 412 object so that they will follow that object no matter how it
414 moves. It is used to create both eyes and ears. 413 moves. It is used to create both eyes and ears.
415 414
416 #+name: node-2 415 #+name: node-2
417 #+begin_src clojure 416 #+begin_src clojure
440 (.mult total-rotation initial-sense-rotation)))) 439 (.mult total-rotation initial-sense-rotation))))
441 (controlRender [_ _]))))) 440 (controlRender [_ _])))))
442 #+end_src 441 #+end_src
443 442
444 Here is some example code which shows how a camera bound to a blue box 443 Here is some example code which shows how a camera bound to a blue box
445 with =(bind-sense)= moves as the box is buffeted by white cannonballs. 444 with =bind-sense= moves as the box is buffeted by white cannonballs.
446 445
447 #+name: test 446 #+name: test
448 #+begin_src clojure 447 #+begin_src clojure
449 (defn test-bind-sense 448 (defn test-bind-sense
450 "Show a camera that stays in the same relative position to a blue 449 "Show a camera that stays in the same relative position to a blue