Mercurial > cortex
changeset 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 |
files | assets/Models/test-creature/worm.blend org/body.org org/ideas.org org/util.org |
diffstat | 4 files changed, 96 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
1.1 Binary file assets/Models/test-creature/worm.blend has changed
2.1 --- a/org/body.org Wed Feb 08 09:10:23 2012 -0700 2.2 +++ b/org/body.org Thu Feb 09 04:15:09 2012 -0700 2.3 @@ -60,14 +60,8 @@ 2.4 2.5 If we load it directly into jMonkeyEngine, we get this: 2.6 2.7 -#+name: test-0 2.8 +#+name: test-1 2.9 #+begin_src clojure 2.10 -(ns cortex.test.body 2.11 - (:use (cortex world util body)) 2.12 - (:import (com.aurellem.capture Capture RatchetTimer) 2.13 - (com.jme3.math Quaternion Vector3f) 2.14 - java.io.File)) 2.15 - 2.16 (def hand-path "Models/test-creature/hand.blend") 2.17 2.18 (defn hand [] (load-blender-model hand-path)) 2.19 @@ -150,7 +144,7 @@ 2.20 CollisionShapes for each geometry with the mass specified in that 2.21 geometry's meta-data. 2.22 2.23 -#+name: test-1 2.24 +#+name: test-2 2.25 #+begin_src clojure 2.26 (in-ns 'cortex.test.body) 2.27 2.28 @@ -409,6 +403,7 @@ 2.29 Creating joints is now a matter applying =(connect)= to each joint 2.30 node. 2.31 2.32 +#+name: joints-5 2.33 #+begin_src clojure 2.34 (defn joints! 2.35 "Connect the solid parts of the creature with physical joints. The 2.36 @@ -427,21 +422,20 @@ 2.37 2.38 Now we can test the hand in all its glory. 2.39 2.40 +#+name: test-3 2.41 #+begin_src clojure 2.42 (in-ns 'cortex.test.body) 2.43 2.44 (def debug-control 2.45 {"key-h" (fn [world val] 2.46 (if val (enable-debug world))) 2.47 - 2.48 - "key-u" (fn [world _] (set-gravity world Vector3f/ZERO)) 2.49 - }) 2.50 + "key-u" (fn [world _] (set-gravity world Vector3f/ZERO))}) 2.51 2.52 (defn test-three [] 2.53 (world (nodify 2.54 [(doto (hand) 2.55 - (physical!) 2.56 - (joints!) ) 2.57 + (physical!) 2.58 + (joints!)) 2.59 (floor)]) 2.60 (merge standard-debug-controls debug-control 2.61 normal-gravity) 2.62 @@ -456,7 +450,6 @@ 2.63 =(physical!)= makes the hand solid, then =(joints!)= connects each 2.64 piece together. 2.65 2.66 - 2.67 #+begin_html 2.68 <div class="figure"> 2.69 <center> 2.70 @@ -478,7 +471,7 @@ 2.71 It is convienent to combine =(physical!)= and =(joints!)= into one 2.72 function that completely creates the creature's physical body. 2.73 2.74 -#+name: joints-4 2.75 +#+name: joints-6 2.76 #+begin_src clojure 2.77 (defn body! 2.78 "Endow the creature with a physical body connected with joints. The 2.79 @@ -489,11 +482,55 @@ 2.80 (joints! creature)) 2.81 #+end_src 2.82 2.83 +* The Worm 2.84 + 2.85 +Going forward, I will use a model that is less complicated than the 2.86 +hand. It has two segments and one joint, and I call it the worm. All 2.87 +of the senses described in the following posts will be applied to this 2.88 +worm. 2.89 + 2.90 +#+name: test-4 2.91 +#+begin_src clojure 2.92 +(in-ns 'cortex.test.body) 2.93 + 2.94 +(defn worm-1 [] 2.95 + (let [timer (RatchetTimer. 60)] 2.96 + (world 2.97 + (nodify 2.98 + [(doto 2.99 + (load-blender-model 2.100 + "Models/test-creature/worm.blend") 2.101 + (body!)) 2.102 + (floor)]) 2.103 + (merge standard-debug-controls debug-control) 2.104 + #(do 2.105 + (speed-up %) 2.106 + (light-up-everything %) 2.107 + (.setTimer % timer) 2.108 + (cortex.util/display-dialated-time % timer) 2.109 + (Capture/captureVideo 2.110 + % (File. "/home/r/proj/cortex/render/body/4"))) 2.111 + no-op))) 2.112 +#+end_src 2.113 + 2.114 +#+begin_html 2.115 +<div class="figure"> 2.116 +<center> 2.117 +<video controls="controls" width="640"> 2.118 + <source src="../video/worm-1.ogg" type="video/ogg" 2.119 + preload="none" poster="../images/aurellem-1280x480.png" /> 2.120 +</video> 2.121 +</center> 2.122 +<p>This worm model will be the platform onto which future senses will 2.123 +be grafted.</p> 2.124 +</div> 2.125 +#+end_html 2.126 + 2.127 * Bookkeeping 2.128 2.129 Header; here for completeness. 2.130 2.131 -#+name: body-0 2.132 +#+name: body-header 2.133 #+begin_src clojure 2.134 (ns cortex.body 2.135 "Assemble a physical creature using the definitions found in a 2.136 @@ -514,6 +551,16 @@ 2.137 com.jme3.bullet.collision.shapes.HullCollisionShape)) 2.138 #+end_src 2.139 2.140 +#+name: test-header 2.141 +#+begin_src clojure 2.142 +(ns cortex.test.body 2.143 + (:use (cortex world util body)) 2.144 + (:import 2.145 + (com.aurellem.capture Capture RatchetTimer) 2.146 + (com.jme3.math Quaternion Vector3f ColorRGBA) 2.147 + java.io.File)) 2.148 +#+end_src 2.149 + 2.150 * Source 2.151 2.152 Dylan -- I'll fill these in later 2.153 @@ -525,16 +572,6 @@ 2.154 2.155 #+name: test-body 2.156 #+begin_src clojure 2.157 -(ns cortex.test.body 2.158 - (:use (cortex world util body)) 2.159 - (:require cortex.silly) 2.160 - (:import 2.161 - com.jme3.math.Vector3f 2.162 - com.jme3.math.ColorRGBA 2.163 - com.jme3.bullet.joints.Point2PointJoint 2.164 - com.jme3.bullet.control.RigidBodyControl 2.165 - com.jme3.system.NanoTimer 2.166 - com.jme3.math.Quaternion)) 2.167 2.168 (defn worm-segments 2.169 "Create multiple evenly spaced box segments. They're fabulous!" 2.170 @@ -1253,11 +1290,21 @@ 2.171 2.172 * COMMENT generate Source 2.173 #+begin_src clojure :tangle ../src/cortex/body.clj 2.174 -<<joints>> 2.175 +<<body-header>> 2.176 +<<body-1>> 2.177 +<<joints-2>> 2.178 +<<joints-3>> 2.179 +<<joints-4>> 2.180 +<<joints-5>> 2.181 +<<joints-6>> 2.182 #+end_src 2.183 2.184 #+begin_src clojure :tangle ../src/cortex/test/body.clj 2.185 -<<test-0>> 2.186 +<<test-header>> 2.187 +<<test-1>> 2.188 +<<test-2>> 2.189 +<<test-3>> 2.190 +<<test-4>> 2.191 #+end_src 2.192 2.193
3.1 --- a/org/ideas.org Wed Feb 08 09:10:23 2012 -0700 3.2 +++ b/org/ideas.org Thu Feb 09 04:15:09 2012 -0700 3.3 @@ -64,7 +64,7 @@ 3.4 * goals 3.5 3.6 ** have to get done before winston 3.7 - - [ ] write an explination for why greyscale bitmaps for senses is 3.8 + - [X] write an explination for why greyscale bitmaps for senses is 3.9 appropiate -- 1/2 day 3.10 - [X] muscle control -- day 3.11 - [X] proprioception sensor map in the style of the other senses -- day 3.12 @@ -90,36 +90,13 @@ 3.13 3.14 ** don't have to get done before winston 3.15 - [ ] write tests for integration -- 3 days 3.16 - - [ ] usertime/gametime clock HUD display -- day 3.17 + - [X] usertime/gametime clock HUD display -- day 3.18 - [ ] find papers for each of the senses justifying my own 3.19 representation -- week 3.20 - [ ] show sensor maps in HUD display? -- 4 days 3.21 - [ ] show sensor maps in AWT display? -- 2 days 3.22 - [ ] add iteraterator constructs to Vector3f, Vector2f, etc. 3.23 3.24 -* refactoring objectives 3.25 - - [X] consistent, high-quality names 3.26 - - [X] joint-creation function in the style of others, kill blender-creature 3.27 - - [X] docstrings for every function 3.28 - - [X] common image-loading code 3.29 - - [X] refactor display/debug code 3.30 - - [X] refactor the "get the XX nodes functions" 3.31 - 3.32 - 3.33 - 3.34 -these are the sense-functions --- they each take a Node which 3.35 -repepsents the creature 3.36 - 3.37 - 3.38 - - [X] body! 3.39 - - [X] joints! 3.40 - 3.41 - - [X] touch! 3.42 - - [X] hearing! 3.43 - - [X] vision! 3.44 - - [X] proprioception! 3.45 - - [X] movement! 3.46 - 3.47 3.48 ;;In the elder days of Art, 3.49 ;;Builders wrought with greatest care
4.1 --- a/org/util.org Wed Feb 08 09:10:23 2012 -0700 4.2 +++ b/org/util.org Thu Feb 09 04:15:09 2012 -0700 4.3 @@ -475,8 +475,26 @@ 4.4 intilization 4.5 world-loop*])) 4.6 4.7 +(import com.jme3.font.BitmapText) 4.8 +(import com.jme3.scene.control.AbstractControl) 4.9 +(import com.aurellem.capture.IsoTimer) 4.10 4.11 - 4.12 +(defn display-dialated-time 4.13 + "Shows the time as it is flowing in the simulation on a HUD display. 4.14 + Useful for making videos." 4.15 + [world timer] 4.16 + (let [font (.loadFont (asset-manager) "Interface/Fonts/Default.fnt") 4.17 + text (BitmapText. font false)] 4.18 + (.setLocalTranslation text 300 (.getLineHeight text) 0) 4.19 + (.addControl 4.20 + text 4.21 + (proxy [AbstractControl] [] 4.22 + (controlUpdate [tpf] 4.23 + (.setText text (format 4.24 + "%.2f" 4.25 + (float (/ (.getTime timer) 1000))))) 4.26 + (controlRender [_ _]))) 4.27 + (.attachChild (.getGuiNode world) text))) 4.28 #+end_src 4.29 4.30