Mercurial > cortex
diff org/worm_learn.clj @ 397:72ee485d9179
smaller worm segment.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 03 Mar 2014 23:24:28 -0500 |
parents | b86bc9430119 |
children | 36d492f4deab |
line wrap: on
line diff
1.1 --- a/org/worm_learn.clj Mon Mar 03 23:04:02 2014 -0500 1.2 +++ b/org/worm_learn.clj Mon Mar 03 23:24:28 2014 -0500 1.3 @@ -6,12 +6,82 @@ 1.4 (:import (com.jme3.math ColorRGBA Vector3f)) 1.5 (:import java.io.File) 1.6 (:import com.jme3.audio.AudioNode) 1.7 - (:import com.aurellem.capture.RatchetTimer)) 1.8 + (:import com.aurellem.capture.RatchetTimer) 1.9 + (:import (com.aurellem.capture Capture IsoTimer)) 1.10 + (:import (com.jme3.math Vector3f ColorRGBA))) 1.11 + 1.12 1.13 (dorun (cortex.import/mega-import-jme3)) 1.14 (rlm.rlm-commands/help) 1.15 1.16 1.17 +(defn worm-segment [] 1.18 + (load-blender-model "Models/worm-segment/worm-segment.blend")) 1.19 1.20 1.21 +(defn worm-segment [] 1.22 + (load-blender-model "Models/test-touch/touch-cube.blend")) 1.23 1.24 + 1.25 +(defn gen-worm 1.26 + "create a creature acceptable for testing as a replacement for the 1.27 + worm." 1.28 + [] 1.29 + (nodify 1.30 + "worm" 1.31 + [(nodify 1.32 + "eyes" 1.33 + [(doto 1.34 + (Node. "eye1") 1.35 + (.setLocalTranslation (Vector3f. 0 -1.1 0)) 1.36 + (.setUserData 1.37 + 1.38 + "eye" 1.39 + "(let [retina 1.40 + \"Models/test-creature/retina-small.png\"] 1.41 + {:all retina :red retina 1.42 + :green retina :blue retina})"))]) 1.43 + (box 1.44 + 0.2 0.2 0.2 1.45 + :name "worm-segment" 1.46 + :position (Vector3f. 0 0 0) 1.47 + :color ColorRGBA/Orange)])) 1.48 + 1.49 + 1.50 +(defn test-basic-touch 1.51 + "Testing touch: 1.52 + You should see a cube fall onto a table. There is a cross-shaped 1.53 + display which reports the cube's sensation of touch. This display 1.54 + should change when the cube hits the table, and whenever you hit 1.55 + the cube with balls. 1.56 + 1.57 + Keys: 1.58 + <space> : fire ball" 1.59 + ([] (test-basic-touch false)) 1.60 + ([record?] 1.61 + (let [head (doto (worm-segment) (body!)) 1.62 + touch (touch! head) 1.63 + touch-display (view-touch)] 1.64 + (world 1.65 + (nodify [head 1.66 + (box 10 1 10 :position (Vector3f. 0 -10 0) 1.67 + :color ColorRGBA/Gray :mass 0)]) 1.68 + 1.69 + standard-debug-controls 1.70 + 1.71 + (fn [world] 1.72 + (let [timer (IsoTimer. 60)] 1.73 + (.setTimer world timer) 1.74 + (display-dilated-time world timer)) 1.75 + (if record? 1.76 + (Capture/captureVideo 1.77 + world 1.78 + (File. "/home/r/proj/cortex/render/touch-cube/main-view/"))) 1.79 + (speed-up world) 1.80 + (light-up-everything world)) 1.81 + 1.82 + (fn [world tpf] 1.83 + (touch-display 1.84 + (map #(% (.getRootNode world)) touch) 1.85 + (if record? 1.86 + (File. "/home/r/proj/cortex/render/touch-cube/touch/"))))))))