comparison org/body.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 63dafe7365df
children 23aadf376e9d
comparison
equal deleted inserted replaced
271:5833b4ce877a 273:c39b8b29a79e
1 #+title: Building a Body 1 #+title: Building a Body
2 #+author: Robert McIntyre 2 #+author: Robert McIntyre
3 #+email: rlm@mit.edu 3 #+email: rlm@mit.edu
4 #+description: Simulating a body (movement, touch, propioception) in jMonkeyEngine3. 4 #+description: Simulating a body (movement, touch, propioception) in jMonkeyEngine3.
5 #+SETUPFILE: ../../aurellem/org/setup.org 5 #+SETUPFILE: ../../aurellem/org/setup.org
6 #+INCLUDE: ../../aurellem/org/level-0.org 6 #+INCLUDE: ../../aurellem/org/level-0.org
7 7
8 * Design Constraints 8 * Design Constraints
16 ** Bag of Bones 16 ** Bag of Bones
17 17
18 How to create such a body? One option I ultimately rejected is to use 18 How to create such a body? One option I ultimately rejected is to use
19 blender's [[http://wiki.blender.org/index.php/Doc:2.6/Manual/Rigging/Armatures][armature]] system. The idea would have been to define a mesh 19 blender's [[http://wiki.blender.org/index.php/Doc:2.6/Manual/Rigging/Armatures][armature]] system. The idea would have been to define a mesh
20 which describes the creature's entire body. To this you add an 20 which describes the creature's entire body. To this you add an
21 (skeleton) which deforms this mesh. This technique is used extensively 21 skeleton which deforms this mesh. This technique is used extensively
22 to model humans and create realistic animations. It is hard to use for 22 to model humans and create realistic animations. It is hard to use for
23 my purposes because it is difficult to update the creature's Physics 23 my purposes because it is difficult to update the creature's Physics
24 Collision Mesh in tandem with its Geometric Mesh under the influence 24 Collision Mesh in tandem with its Geometric Mesh under the influence
25 of the armature. Withouth this the creature will not be able to grab 25 of the armature. Withouth this the creature will not be able to grab
26 things in its environment, and it won't be able to tell where its 26 things in its environment, and it won't be able to tell where its
138 (.addControl geom physics-control))) 138 (.addControl geom physics-control)))
139 (filter #(isa? (class %) Geometry ) 139 (filter #(isa? (class %) Geometry )
140 (node-seq creature))))) 140 (node-seq creature)))))
141 #+end_src 141 #+end_src
142 142
143 =(physical!)= iterates through a creature's node structure, creating 143 =physical!)= iterates through a creature's node structure, creating
144 CollisionShapes for each geometry with the mass specified in that 144 CollisionShapes for each geometry with the mass specified in that
145 geometry's meta-data. 145 geometry's meta-data.
146 146
147 #+name: test-2 147 #+name: test-2
148 #+begin_src clojure 148 #+begin_src clojure
218 - Determine the two spatials the joint it meant to connect. 218 - Determine the two spatials the joint it meant to connect.
219 - Create the joint based on the meta-data of the empty node. 219 - Create the joint based on the meta-data of the empty node.
220 220
221 ** Finding the Joints 221 ** Finding the Joints
222 222
223 The higher order function =(sense-nodes)= from =cortex.sense= simplifies 223 The higher order function =sense-nodes= from =cortex.sense= simplifies
224 the first task. 224 the first task.
225 225
226 #+name: joints-2 226 #+name: joints-2
227 #+begin_src clojure 227 #+begin_src clojure
228 (defvar 228 (defvar
230 joints 230 joints
231 (sense-nodes "joints") 231 (sense-nodes "joints")
232 "Return the children of the creature's \"joints\" node.") 232 "Return the children of the creature's \"joints\" node.")
233 #+end_src 233 #+end_src
234 234
235
236 ** Joint Targets and Orientation 235 ** Joint Targets and Orientation
237 236
238 This technique for finding a joint's targets is very similiar to 237 This technique for finding a joint's targets is very similiar to
239 =(cortex.sense/closest-node)=. A small cube, centered around the 238 =cortex.sense/closest-node=. A small cube, centered around the
240 empty-node, grows exponentially until it intersects two /physical/ 239 empty-node, grows exponentially until it intersects two /physical/
241 objects. The objects are ordered according to the joint's rotation, 240 objects. The objects are ordered according to the joint's rotation,
242 with the first one being the object that has more negative coordinates 241 with the first one being the object that has more negative coordinates
243 in the joint's reference frame. Since the objects must be physical, 242 in the joint's reference frame. Since the objects must be physical,
244 the empty-node itself escapes detection. Because the objects must be 243 the empty-node itself escapes detection. Because the objects must be
245 physical, =(joint-targets)= must be called /after/ =(physical!)= is 244 physical, =joint-targets= must be called /after/ =physical!= is
246 called. 245 called.
247 246
248 #+name: joints-3 247 #+name: joints-3
249 #+begin_src clojure 248 #+begin_src clojure
250 (defn joint-targets 249 (defn joint-targets
398 pivot-a pivot-b 397 pivot-a pivot-b
399 joint-rotation)) 398 joint-rotation))
400 (println-repl "could not find joint meta-data!")))) 399 (println-repl "could not find joint meta-data!"))))
401 #+end_src 400 #+end_src
402 401
403 Creating joints is now a matter of applying =(connect)= to each joint 402 Creating joints is now a matter of applying =connect= to each joint
404 node. 403 node.
405 404
406 #+name: joints-5 405 #+name: joints-5
407 #+begin_src clojure 406 #+begin_src clojure
408 (defn joints! 407 (defn joints!
414 (fn [joint] 413 (fn [joint]
415 (let [[obj-a obj-b] (joint-targets creature joint)] 414 (let [[obj-a obj-b] (joint-targets creature joint)]
416 (connect obj-a obj-b joint))) 415 (connect obj-a obj-b joint)))
417 (joints creature)))) 416 (joints creature))))
418 #+end_src 417 #+end_src
419
420 418
421 ** Round 3 419 ** Round 3
422 420
423 Now we can test the hand in all its glory. 421 Now we can test the hand in all its glory.
424 422
444 #(do (set-gravity % Vector3f/ZERO) %) 442 #(do (set-gravity % Vector3f/ZERO) %)
445 setup) 443 setup)
446 no-op)) 444 no-op))
447 #+end_src 445 #+end_src
448 446
449 =(physical!)= makes the hand solid, then =(joints!)= connects each 447 =physical!= makes the hand solid, then =joints!= connects each
450 piece together. 448 piece together.
451 449
452 #+begin_html 450 #+begin_html
453 <div class="figure"> 451 <div class="figure">
454 <center> 452 <center>
465 for debug purposes. You can see that they correspond to the empty 463 for debug purposes. You can see that they correspond to the empty
466 nodes in the blender file. 464 nodes in the blender file.
467 465
468 * Wrap-Up! 466 * Wrap-Up!
469 467
470 It is convienent to combine =(physical!)= and =(joints!)= into one 468 It is convienent to combine =physical!= and =joints!= into one
471 function that completely creates the creature's physical body. 469 function that completely creates the creature's physical body.
472 470
473 #+name: joints-6 471 #+name: joints-6
474 #+begin_src clojure 472 #+begin_src clojure
475 (defn body! 473 (defn body!