comparison org/body.org @ 306:7e7f8d6d9ec5

massive spellchecking
author Robert McIntyre <rlm@mit.edu>
date Sat, 18 Feb 2012 10:59:41 -0700
parents 23aadf376e9d
children 5d448182c807
comparison
equal deleted inserted replaced
305:19c43ec6958d 306:7e7f8d6d9ec5
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, proprioception) 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
9 9
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. Without 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
27 physical body is by using its eyes. Also, armatures do not specify 27 physical body is by using its eyes. Also, armatures do not specify
28 any rotational limits for a joint, making it hard to model elbows, 28 any rotational limits for a joint, making it hard to model elbows,
29 shoulders, etc. 29 shoulders, etc.
30 30
41 "eve-like". The main reason that I use eve-style bodies is so that 41 "eve-like". The main reason that I use eve-style bodies is so that
42 there will be correspondence between the AI's vision and the physical 42 there will be correspondence between the AI's vision and the physical
43 presence of its body. Each individual section is simulated by a 43 presence of its body. Each individual section is simulated by a
44 separate rigid body that corresponds exactly with its visual 44 separate rigid body that corresponds exactly with its visual
45 representation and does not change. Sections are connected by 45 representation and does not change. Sections are connected by
46 invisible joints that are well supported in jMonkyeEngine. Bullet, the 46 invisible joints that are well supported in jMonkeyEngine. Bullet, the
47 physics backend for jMonkeyEngine, can efficiently simulate hundreds 47 physics backend for jMonkeyEngine, can efficiently simulate hundreds
48 of rigid bodies connected by joints. Sections do not have to stay as 48 of rigid bodies connected by joints. Sections do not have to stay as
49 one piece forever; they can be dynamically replaced with multiple 49 one piece forever; they can be dynamically replaced with multiple
50 sections to simulate splitting in two. This could be used to simulate 50 sections to simulate splitting in two. This could be used to simulate
51 retractable claws or EVE's hands, which are able to coalece into one 51 retractable claws or EVE's hands, which are able to coalesce into one
52 object in the movie. 52 object in the movie.
53 53
54 * Solidifying the Body 54 * Solidifying the Body
55 55
56 Here is a hand designed eve-style in blender. 56 Here is a hand designed eve-style in blender.
105 <source src="../video/ghost-hand.ogg" type="video/ogg" 105 <source src="../video/ghost-hand.ogg" type="video/ogg"
106 preload="none" poster="../images/aurellem-1280x480.png" /> 106 preload="none" poster="../images/aurellem-1280x480.png" />
107 </video> 107 </video>
108 </center> 108 </center>
109 <p>The hand model directly loaded from blender. It has no physical 109 <p>The hand model directly loaded from blender. It has no physical
110 presense in the simulation. </p> 110 presence in the simulation. </p>
111 </div> 111 </div>
112 #+end_html 112 #+end_html
113 113
114 You will notice that the hand has no physical presence -- it's a 114 You will notice that the hand has no physical presence -- it's a
115 hologram through which everything passes. Therefore, the first thing 115 hologram through which everything passes. Therefore, the first thing
216 #+attr_html: width="755" 216 #+attr_html: width="755"
217 #+caption: Joints hack in blender. Each empty node here will be transformed into a joint in jMonkeyEngine 217 #+caption: Joints hack in blender. Each empty node here will be transformed into a joint in jMonkeyEngine
218 [[../images/hand-screenshot1.png]] 218 [[../images/hand-screenshot1.png]]
219 219
220 The empty node in the upper right, highlighted in yellow, is the 220 The empty node in the upper right, highlighted in yellow, is the
221 parent node of all the emptys which represent joints. The following 221 parent node of all the empties which represent joints. The following
222 functions must do three things to translate these into real joints: 222 functions must do three things to translate these into real joints:
223 223
224 - Find the children of the "joints" node. 224 - Find the children of the "joints" node.
225 - Determine the two spatials the joint it meant to connect. 225 - Determine the two spatials the joint it meant to connect.
226 - Create the joint based on the meta-data of the empty node. 226 - Create the joint based on the meta-data of the empty node.
239 "Return the children of the creature's \"joints\" node.") 239 "Return the children of the creature's \"joints\" node.")
240 #+end_src 240 #+end_src
241 241
242 ** Joint Targets and Orientation 242 ** Joint Targets and Orientation
243 243
244 This technique for finding a joint's targets is very similiar to 244 This technique for finding a joint's targets is very similar to
245 =cortex.sense/closest-node=. A small cube, centered around the 245 =cortex.sense/closest-node=. A small cube, centered around the
246 empty-node, grows exponentially until it intersects two /physical/ 246 empty-node, grows exponentially until it intersects two /physical/
247 objects. The objects are ordered according to the joint's rotation, 247 objects. The objects are ordered according to the joint's rotation,
248 with the first one being the object that has more negative coordinates 248 with the first one being the object that has more negative coordinates
249 in the joint's reference frame. Since the objects must be physical, 249 in the joint's reference frame. Since the objects must be physical,
281 281
282 ** Generating Joints 282 ** Generating Joints
283 283
284 This section of code iterates through all the different ways of 284 This section of code iterates through all the different ways of
285 specifying joints using blender meta-data and converts each one to the 285 specifying joints using blender meta-data and converts each one to the
286 appropriate jMonkyeEngine joint. 286 appropriate jMonkeyEngine joint.
287 287
288 #+name: joints-4 288 #+name: joints-4
289 #+begin_src clojure 289 #+begin_src clojure
290 (defmulti joint-dispatch 290 (defmulti joint-dispatch
291 "Translate blender pseudo-joints into real JME joints." 291 "Translate blender pseudo-joints into real JME joints."
305 control-b 305 control-b
306 pivot-a 306 pivot-a
307 pivot-b)) 307 pivot-b))
308 308
309 ;; but instead we must do this: 309 ;; but instead we must do this:
310 (println-repl "substuting 6DOF joint for POINT2POINT joint!") 310 (println-repl "substituting 6DOF joint for POINT2POINT joint!")
311 (doto 311 (doto
312 (SixDofJoint. 312 (SixDofJoint.
313 control-a 313 control-a
314 control-b 314 control-b
315 pivot-a 315 pivot-a
473 for debug purposes. You can see that they correspond to the empty 473 for debug purposes. You can see that they correspond to the empty
474 nodes in the blender file. 474 nodes in the blender file.
475 475
476 * Wrap-Up! 476 * Wrap-Up!
477 477
478 It is convienent to combine =physical!= and =joints!= into one 478 It is convenient to combine =physical!= and =joints!= into one
479 function that completely creates the creature's physical body. 479 function that completely creates the creature's physical body.
480 480
481 #+name: joints-6 481 #+name: joints-6
482 #+begin_src clojure 482 #+begin_src clojure
483 (defn body! 483 (defn body!
484 "Endow the creature with a physical body connected with joints. The 484 "Endow the creature with a physical body connected with joints. The
485 particulars of the joints and the masses of each pody part are 485 particulars of the joints and the masses of each body part are
486 determined in blender." 486 determined in blender."
487 [#^Node creature] 487 [#^Node creature]
488 (physical! creature) 488 (physical! creature)
489 (joints! creature)) 489 (joints! creature))
490 #+end_src 490 #+end_src
542 #+name: body-header 542 #+name: body-header
543 #+begin_src clojure 543 #+begin_src clojure
544 (ns cortex.body 544 (ns cortex.body
545 "Assemble a physical creature using the definitions found in a 545 "Assemble a physical creature using the definitions found in a
546 specially prepared blender file. Creates rigid bodies and joints so 546 specially prepared blender file. Creates rigid bodies and joints so
547 that a creature can have a physical presense in the simulation." 547 that a creature can have a physical presence in the simulation."
548 {:author "Robert McIntyre"} 548 {:author "Robert McIntyre"}
549 (:use (cortex world util sense)) 549 (:use (cortex world util sense))
550 (:use clojure.contrib.def) 550 (:use clojure.contrib.def)
551 (:import 551 (:import
552 (com.jme3.math Vector3f Quaternion Vector2f Matrix3f) 552 (com.jme3.math Vector3f Quaternion Vector2f Matrix3f)