comparison 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
comparison
equal deleted inserted replaced
396:0898d93a39ef 397:72ee485d9179
4 (:use (cortex world util import body sense 4 (:use (cortex world util import body sense
5 hearing touch vision proprioception movement)) 5 hearing touch vision proprioception movement))
6 (:import (com.jme3.math ColorRGBA Vector3f)) 6 (:import (com.jme3.math ColorRGBA Vector3f))
7 (:import java.io.File) 7 (:import java.io.File)
8 (:import com.jme3.audio.AudioNode) 8 (:import com.jme3.audio.AudioNode)
9 (:import com.aurellem.capture.RatchetTimer)) 9 (:import com.aurellem.capture.RatchetTimer)
10 (:import (com.aurellem.capture Capture IsoTimer))
11 (:import (com.jme3.math Vector3f ColorRGBA)))
12
10 13
11 (dorun (cortex.import/mega-import-jme3)) 14 (dorun (cortex.import/mega-import-jme3))
12 (rlm.rlm-commands/help) 15 (rlm.rlm-commands/help)
13 16
14 17
18 (defn worm-segment []
19 (load-blender-model "Models/worm-segment/worm-segment.blend"))
15 20
16 21
22 (defn worm-segment []
23 (load-blender-model "Models/test-touch/touch-cube.blend"))
17 24
25
26 (defn gen-worm
27 "create a creature acceptable for testing as a replacement for the
28 worm."
29 []
30 (nodify
31 "worm"
32 [(nodify
33 "eyes"
34 [(doto
35 (Node. "eye1")
36 (.setLocalTranslation (Vector3f. 0 -1.1 0))
37 (.setUserData
38
39 "eye"
40 "(let [retina
41 \"Models/test-creature/retina-small.png\"]
42 {:all retina :red retina
43 :green retina :blue retina})"))])
44 (box
45 0.2 0.2 0.2
46 :name "worm-segment"
47 :position (Vector3f. 0 0 0)
48 :color ColorRGBA/Orange)]))
49
50
51 (defn test-basic-touch
52 "Testing touch:
53 You should see a cube fall onto a table. There is a cross-shaped
54 display which reports the cube's sensation of touch. This display
55 should change when the cube hits the table, and whenever you hit
56 the cube with balls.
57
58 Keys:
59 <space> : fire ball"
60 ([] (test-basic-touch false))
61 ([record?]
62 (let [head (doto (worm-segment) (body!))
63 touch (touch! head)
64 touch-display (view-touch)]
65 (world
66 (nodify [head
67 (box 10 1 10 :position (Vector3f. 0 -10 0)
68 :color ColorRGBA/Gray :mass 0)])
69
70 standard-debug-controls
71
72 (fn [world]
73 (let [timer (IsoTimer. 60)]
74 (.setTimer world timer)
75 (display-dilated-time world timer))
76 (if record?
77 (Capture/captureVideo
78 world
79 (File. "/home/r/proj/cortex/render/touch-cube/main-view/")))
80 (speed-up world)
81 (light-up-everything world))
82
83 (fn [world tpf]
84 (touch-display
85 (map #(% (.getRootNode world)) touch)
86 (if record?
87 (File. "/home/r/proj/cortex/render/touch-cube/touch/"))))))))