annotate org/worm_learn.clj @ 398:36d492f4deab

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