diff org/body.org @ 205:d3a2abfac405

fixed tangling in body.org, added dialated time HUD display in cortex.util
author Robert McIntyre <rlm@mit.edu>
date Thu, 09 Feb 2012 04:15:09 -0700
parents 162b24a82712
children df46a609fed9
line wrap: on
line diff
     1.1 --- a/org/body.org	Wed Feb 08 09:10:23 2012 -0700
     1.2 +++ b/org/body.org	Thu Feb 09 04:15:09 2012 -0700
     1.3 @@ -60,14 +60,8 @@
     1.4  
     1.5  If we load it directly into jMonkeyEngine, we get this:
     1.6  
     1.7 -#+name: test-0
     1.8 +#+name: test-1
     1.9  #+begin_src clojure
    1.10 -(ns cortex.test.body
    1.11 -  (:use (cortex world util body))
    1.12 -  (:import (com.aurellem.capture Capture RatchetTimer)
    1.13 -           (com.jme3.math Quaternion Vector3f)
    1.14 -           java.io.File))
    1.15 -
    1.16  (def hand-path "Models/test-creature/hand.blend")
    1.17  
    1.18  (defn hand [] (load-blender-model hand-path))
    1.19 @@ -150,7 +144,7 @@
    1.20  CollisionShapes for each geometry with the mass specified in that
    1.21  geometry's meta-data.
    1.22  
    1.23 -#+name: test-1
    1.24 +#+name: test-2
    1.25  #+begin_src clojure 
    1.26  (in-ns 'cortex.test.body)
    1.27  
    1.28 @@ -409,6 +403,7 @@
    1.29  Creating joints is now a matter applying =(connect)= to each joint
    1.30  node.
    1.31  
    1.32 +#+name: joints-5
    1.33  #+begin_src clojure
    1.34  (defn joints!
    1.35    "Connect the solid parts of the creature with physical joints. The
    1.36 @@ -427,21 +422,20 @@
    1.37  
    1.38  Now we can test the hand in all its glory.
    1.39  
    1.40 +#+name: test-3
    1.41  #+begin_src clojure 
    1.42  (in-ns 'cortex.test.body)
    1.43  
    1.44  (def debug-control 
    1.45    {"key-h" (fn [world val]
    1.46               (if val (enable-debug world)))
    1.47 -
    1.48 -   "key-u" (fn [world _] (set-gravity world Vector3f/ZERO))
    1.49 -   })
    1.50 +   "key-u" (fn [world _] (set-gravity world Vector3f/ZERO))})
    1.51    
    1.52  (defn test-three []
    1.53    (world (nodify
    1.54            [(doto (hand)
    1.55 -           (physical!)
    1.56 -           (joints!) )
    1.57 +             (physical!)
    1.58 +             (joints!))
    1.59             (floor)])
    1.60           (merge standard-debug-controls debug-control
    1.61                  normal-gravity)
    1.62 @@ -456,7 +450,6 @@
    1.63  =(physical!)= makes the hand solid, then =(joints!)= connects each
    1.64  piece together. 
    1.65  
    1.66 -
    1.67  #+begin_html
    1.68  <div class="figure">
    1.69  <center>
    1.70 @@ -478,7 +471,7 @@
    1.71  It is convienent to combine =(physical!)= and =(joints!)= into one
    1.72  function that completely creates the creature's physical body.
    1.73  
    1.74 -#+name: joints-4
    1.75 +#+name: joints-6
    1.76  #+begin_src clojure
    1.77  (defn body!
    1.78    "Endow the creature with a physical body connected with joints.  The
    1.79 @@ -489,11 +482,55 @@
    1.80    (joints! creature))
    1.81  #+end_src
    1.82  
    1.83 +* The Worm
    1.84 +
    1.85 +Going forward, I will use a model that is less complicated than the
    1.86 +hand. It has two segments and one joint, and I call it the worm. All
    1.87 +of the senses described in the following posts will be applied to this
    1.88 +worm.
    1.89 +
    1.90 +#+name: test-4
    1.91 +#+begin_src clojure 
    1.92 +(in-ns 'cortex.test.body)
    1.93 +
    1.94 +(defn worm-1 []
    1.95 +  (let [timer (RatchetTimer. 60)]
    1.96 +    (world
    1.97 +     (nodify
    1.98 +      [(doto
    1.99 +           (load-blender-model
   1.100 +            "Models/test-creature/worm.blend")
   1.101 +         (body!))
   1.102 +       (floor)])
   1.103 +     (merge standard-debug-controls debug-control)
   1.104 +     #(do
   1.105 +        (speed-up %)
   1.106 +        (light-up-everything %)
   1.107 +        (.setTimer % timer)
   1.108 +        (cortex.util/display-dialated-time % timer)
   1.109 +        (Capture/captureVideo
   1.110 +         % (File. "/home/r/proj/cortex/render/body/4")))
   1.111 +     no-op)))
   1.112 +#+end_src
   1.113 +
   1.114 +#+begin_html
   1.115 +<div class="figure">
   1.116 +<center>
   1.117 +<video controls="controls" width="640">
   1.118 +  <source src="../video/worm-1.ogg" type="video/ogg"
   1.119 +	  preload="none" poster="../images/aurellem-1280x480.png" />
   1.120 +</video>
   1.121 +</center>
   1.122 +<p>This worm model will be the platform onto which future senses will
   1.123 +be grafted.</p>
   1.124 +</div>
   1.125 +#+end_html
   1.126 +
   1.127  * Bookkeeping
   1.128  
   1.129  Header; here for completeness.
   1.130  
   1.131 -#+name: body-0
   1.132 +#+name: body-header
   1.133  #+begin_src clojure
   1.134  (ns cortex.body
   1.135    "Assemble a physical creature using the definitions found in a
   1.136 @@ -514,6 +551,16 @@
   1.137     com.jme3.bullet.collision.shapes.HullCollisionShape))
   1.138  #+end_src
   1.139  
   1.140 +#+name: test-header
   1.141 +#+begin_src clojure
   1.142 +(ns cortex.test.body
   1.143 +  (:use (cortex world util body))
   1.144 +  (:import
   1.145 +   (com.aurellem.capture Capture RatchetTimer)
   1.146 +   (com.jme3.math Quaternion Vector3f ColorRGBA)
   1.147 +   java.io.File))
   1.148 +#+end_src
   1.149 +
   1.150  * Source 
   1.151  
   1.152  Dylan -- I'll fill these in later
   1.153 @@ -525,16 +572,6 @@
   1.154  
   1.155  #+name: test-body
   1.156  #+begin_src clojure
   1.157 -(ns cortex.test.body
   1.158 -  (:use (cortex world util body))
   1.159 -  (:require cortex.silly)
   1.160 -  (:import
   1.161 -   com.jme3.math.Vector3f
   1.162 -   com.jme3.math.ColorRGBA
   1.163 -   com.jme3.bullet.joints.Point2PointJoint
   1.164 -   com.jme3.bullet.control.RigidBodyControl
   1.165 -   com.jme3.system.NanoTimer
   1.166 -   com.jme3.math.Quaternion))
   1.167  
   1.168  (defn worm-segments
   1.169    "Create multiple evenly spaced box segments. They're fabulous!"
   1.170 @@ -1253,11 +1290,21 @@
   1.171  
   1.172  * COMMENT generate Source
   1.173  #+begin_src clojure :tangle ../src/cortex/body.clj
   1.174 -<<joints>>
   1.175 +<<body-header>>
   1.176 +<<body-1>>
   1.177 +<<joints-2>>
   1.178 +<<joints-3>>
   1.179 +<<joints-4>>
   1.180 +<<joints-5>>
   1.181 +<<joints-6>>
   1.182  #+end_src
   1.183  
   1.184  #+begin_src clojure :tangle ../src/cortex/test/body.clj
   1.185 -<<test-0>>
   1.186 +<<test-header>>
   1.187 +<<test-1>>
   1.188 +<<test-2>>
   1.189 +<<test-3>>
   1.190 +<<test-4>>
   1.191  #+end_src  
   1.192  
   1.193