diff org/body.org @ 209:e49c690d2bcf

minor edits.
author Robert McIntyre <rlm@mit.edu>
date Thu, 09 Feb 2012 05:02:21 -0700
parents bb3b75bf1664
children 384ed3437948
line wrap: on
line diff
     1.1 --- a/org/body.org	Thu Feb 09 04:36:31 2012 -0700
     1.2 +++ b/org/body.org	Thu Feb 09 05:02:21 2012 -0700
     1.3 @@ -47,8 +47,8 @@
     1.4  of rigid bodies connected by joints. Sections do not have to stay as
     1.5  one piece forever; they can be dynamically replaced with multiple
     1.6  sections to simulate splitting in two. This could be used to simulate
     1.7 -retractable claws or EVE's hands, which could coalece into one object
     1.8 -in the movie.
     1.9 +retractable claws or EVE's hands, which are able to coalece into one
    1.10 +object in the movie.
    1.11  
    1.12  * Solidifying the Body
    1.13  
    1.14 @@ -112,8 +112,8 @@
    1.15  to do is to make it solid.  Blender has physics simulation on par with
    1.16  jMonkeyEngine (they both use bullet as their physics backend), but it
    1.17  can be difficult to translate between the two systems, so for now I
    1.18 -specify the mass of each object in blender and construct the physics
    1.19 -shape based on the mesh in jMonkeyEngine.
    1.20 +specify the mass of each object as meta-data in blender and construct
    1.21 +the physics shape based on the mesh in jMonkeyEngine.
    1.22  
    1.23  #+name: body-1
    1.24  #+begin_src clojure
    1.25 @@ -147,9 +147,11 @@
    1.26  #+begin_src clojure 
    1.27  (in-ns 'cortex.test.body)
    1.28  
    1.29 -(def normal-gravity 
    1.30 +(def gravity-control
    1.31    {"key-g" (fn [world _]
    1.32 -             (set-gravity world (Vector3f. 0 -9.81 0)))})
    1.33 +             (set-gravity world (Vector3f. 0 -9.81 0)))
    1.34 +   "key-u" (fn [world _] (set-gravity world Vector3f/ZERO))})
    1.35 +
    1.36  
    1.37  (defn floor [] 
    1.38    (box 10 3 10 :position (Vector3f. 0 -10 0)
    1.39 @@ -160,7 +162,7 @@
    1.40            [(doto (hand)
    1.41               (physical!))
    1.42            (floor)])
    1.43 -         (merge standard-debug-controls normal-gravity)
    1.44 +         (merge standard-debug-controls gravity-control)
    1.45           (comp
    1.46            #(Capture/captureVideo
    1.47              % (File. "/home/r/proj/cortex/render/body/2"))
    1.48 @@ -186,8 +188,8 @@
    1.49  
    1.50  * Joints
    1.51  
    1.52 -Obviously, an AI is not going to be doing much just lying in pieces on
    1.53 -the floor.  So, the next step to making a proper body is to connect
    1.54 +Obviously, an AI is not going to be doing much while lying in pieces
    1.55 +on the floor.  So, the next step to making a proper body is to connect
    1.56  those pieces together with joints.  jMonkeyEngine has a large array of
    1.57  joints available via bullet, such as Point2Point, Cone, Hinge, and a
    1.58  generic Six Degree of Freedom joint, with or without spring
    1.59 @@ -204,7 +206,7 @@
    1.60  joint is created.
    1.61  
    1.62  #+attr_html: width="755"
    1.63 -#+caption: joints hack in blender. Each empty node here will be transformed into a joint in jMonkeyEngine
    1.64 +#+caption: Joints hack in blender. Each empty node here will be transformed into a joint in jMonkeyEngine
    1.65  [[../images/hand-screenshot1.png]]
    1.66  
    1.67  The empty node in the upper right, highlighted in yellow, is the
    1.68 @@ -216,6 +218,10 @@
    1.69   - Create the joint based on the meta-data of the empty node.
    1.70  
    1.71  ** Finding the Joints 
    1.72 +
    1.73 +The higher order function =(sense-nodes)= from =cortex.sense= simplifies
    1.74 +the first task.
    1.75 +
    1.76  #+name: joints-2 
    1.77  #+begin_src clojure
    1.78  (defvar 
    1.79 @@ -225,8 +231,6 @@
    1.80    "Return the children of the creature's \"joints\" node.")
    1.81  #+end_src
    1.82  
    1.83 -The higher order function =(sense-nodes)= from cortex.sense makes our
    1.84 -first task very easy.
    1.85  
    1.86  ** Joint Targets and Orientation
    1.87  
    1.88 @@ -251,29 +255,26 @@
    1.89        (.collideWith
    1.90         parts
    1.91         (BoundingBox. (.getWorldTranslation joint)
    1.92 -                     radius radius radius)
    1.93 -       results)
    1.94 +                     radius radius radius) results)
    1.95        (let [targets
    1.96              (distinct
    1.97               (map  #(.getGeometry %) results))]
    1.98          (if (>= (count targets) 2)
    1.99            (sort-by
   1.100 -           #(let [v
   1.101 +           #(let [joint-ref-frame-position
   1.102                    (jme-to-blender
   1.103                     (.mult
   1.104                      (.inverse (.getWorldRotation joint))
   1.105                      (.subtract (.getWorldTranslation %)
   1.106                                 (.getWorldTranslation joint))))]
   1.107 -              (println-repl (.getName %) ":" v)
   1.108 -              (.dot (Vector3f. 1 1 1)
   1.109 -                    v))                  
   1.110 +              (.dot (Vector3f. 1 1 1) joint-ref-frame-position))                  
   1.111             (take 2 targets))
   1.112            (recur (float (* radius 2))))))))
   1.113  #+end_src
   1.114  
   1.115  ** Generating Joints
   1.116  
   1.117 -This long chunk of code iterates through all the different ways of
   1.118 +This section of code iterates through all the different ways of
   1.119  specifying joints using blender meta-data and converts each one to the
   1.120  appropriate jMonkyeEngine joint.
   1.121  
   1.122 @@ -398,7 +399,7 @@
   1.123        (println-repl "could not find joint meta-data!"))))
   1.124  #+end_src
   1.125  
   1.126 -Creating joints is now a matter applying =(connect)= to each joint
   1.127 +Creating joints is now a matter of applying =(connect)= to each joint
   1.128  node.
   1.129  
   1.130  #+name: joints-5
   1.131 @@ -426,8 +427,7 @@
   1.132  
   1.133  (def debug-control 
   1.134    {"key-h" (fn [world val]
   1.135 -             (if val (enable-debug world)))
   1.136 -   "key-u" (fn [world _] (set-gravity world Vector3f/ZERO))})
   1.137 +             (if val (enable-debug world)))})
   1.138    
   1.139  (defn test-three []
   1.140    (world (nodify
   1.141 @@ -436,7 +436,7 @@
   1.142               (joints!))
   1.143             (floor)])
   1.144           (merge standard-debug-controls debug-control
   1.145 -                normal-gravity)
   1.146 +                gravity-control)
   1.147           (comp
   1.148            #(Capture/captureVideo
   1.149              % (File. "/home/r/proj/cortex/render/body/3"))
   1.150 @@ -524,10 +524,7 @@
   1.151  </div>
   1.152  #+end_html
   1.153  
   1.154 -* Bookkeeping
   1.155 -
   1.156 -Headers; here for completeness.
   1.157 -
   1.158 +* Headers
   1.159  #+name: body-header
   1.160  #+begin_src clojure
   1.161  (ns cortex.body
   1.162 @@ -563,6 +560,7 @@
   1.163  - [[../src/cortex/body.clj][cortex.body]]
   1.164  - [[../src/cortex/test/body.clj][cortex.test.body]]
   1.165  - [[../assets/Models/test-creature/hand.blend][hand.blend]]
   1.166 +  - [[../assets/Models/test-creature/palm.png][UV-map-1]]
   1.167  - [[../assets/Models/test-creature/worm.blend][worm.blend]]
   1.168    - [[../assets/Models/test-creature/retina-small.png][UV-map-1]]
   1.169    - [[../assets/Models/test-creature/tip.png][UV-map-2]]