rlm@394: (ns org.aurellem.worm-learn rlm@394: "General worm creation framework." rlm@394: {:author "Robert McIntyre"} rlm@394: (:use (cortex world util import body sense rlm@394: hearing touch vision proprioception movement)) rlm@394: (:import (com.jme3.math ColorRGBA Vector3f)) rlm@394: (:import java.io.File) rlm@394: (:import com.jme3.audio.AudioNode) rlm@397: (:import com.aurellem.capture.RatchetTimer) rlm@397: (:import (com.aurellem.capture Capture IsoTimer)) rlm@397: (:import (com.jme3.math Vector3f ColorRGBA))) rlm@397: rlm@394: rlm@394: (dorun (cortex.import/mega-import-jme3)) rlm@394: (rlm.rlm-commands/help) rlm@394: rlm@394: rlm@397: (defn worm-segment [] rlm@397: (load-blender-model "Models/worm-segment/worm-segment.blend")) rlm@394: rlm@394: rlm@398: (defn worm [] rlm@398: (load-blender-model "Models/worm-segment/worm.blend")) rlm@394: rlm@397: rlm@397: (defn gen-worm rlm@397: "create a creature acceptable for testing as a replacement for the rlm@397: worm." rlm@397: [] rlm@397: (nodify rlm@397: "worm" rlm@397: [(nodify rlm@397: "eyes" rlm@397: [(doto rlm@397: (Node. "eye1") rlm@397: (.setLocalTranslation (Vector3f. 0 -1.1 0)) rlm@397: (.setUserData rlm@397: rlm@397: "eye" rlm@397: "(let [retina rlm@397: \"Models/test-creature/retina-small.png\"] rlm@397: {:all retina :red retina rlm@397: :green retina :blue retina})"))]) rlm@397: (box rlm@397: 0.2 0.2 0.2 rlm@397: :name "worm-segment" rlm@397: :position (Vector3f. 0 0 0) rlm@397: :color ColorRGBA/Orange)])) rlm@397: rlm@397: rlm@397: (defn test-basic-touch rlm@397: "Testing touch: rlm@397: You should see a cube fall onto a table. There is a cross-shaped rlm@397: display which reports the cube's sensation of touch. This display rlm@397: should change when the cube hits the table, and whenever you hit rlm@397: the cube with balls. rlm@397: rlm@397: Keys: rlm@397: : fire ball" rlm@397: ([] (test-basic-touch false)) rlm@397: ([record?] rlm@398: (let [head (doto (worm) (body!)) rlm@397: touch (touch! head) rlm@397: touch-display (view-touch)] rlm@397: (world rlm@397: (nodify [head rlm@397: (box 10 1 10 :position (Vector3f. 0 -10 0) rlm@397: :color ColorRGBA/Gray :mass 0)]) rlm@397: rlm@397: standard-debug-controls rlm@397: rlm@397: (fn [world] rlm@397: (let [timer (IsoTimer. 60)] rlm@397: (.setTimer world timer) rlm@397: (display-dilated-time world timer)) rlm@397: (if record? rlm@397: (Capture/captureVideo rlm@397: world rlm@397: (File. "/home/r/proj/cortex/render/touch-cube/main-view/"))) rlm@397: (speed-up world) rlm@397: (light-up-everything world)) rlm@397: rlm@397: (fn [world tpf] rlm@397: (touch-display rlm@397: (map #(% (.getRootNode world)) touch) rlm@397: (if record? rlm@397: (File. "/home/r/proj/cortex/render/touch-cube/touch/"))))))))