Mercurial > cortex
view 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 |
line wrap: on
line source
1 (ns org.aurellem.worm-learn2 "General worm creation framework."3 {:author "Robert McIntyre"}4 (:use (cortex world util import body sense5 hearing touch vision proprioception movement))6 (:import (com.jme3.math ColorRGBA Vector3f))7 (:import java.io.File)8 (:import com.jme3.audio.AudioNode)9 (:import com.aurellem.capture.RatchetTimer)10 (:import (com.aurellem.capture Capture IsoTimer))11 (:import (com.jme3.math Vector3f ColorRGBA)))14 (dorun (cortex.import/mega-import-jme3))15 (rlm.rlm-commands/help)18 (defn worm-segment []19 (load-blender-model "Models/worm-segment/worm-segment.blend"))22 (defn worm []23 (load-blender-model "Models/worm-segment/worm.blend"))26 (defn gen-worm27 "create a creature acceptable for testing as a replacement for the28 worm."29 []30 (nodify31 "worm"32 [(nodify33 "eyes"34 [(doto35 (Node. "eye1")36 (.setLocalTranslation (Vector3f. 0 -1.1 0))37 (.setUserData39 "eye"40 "(let [retina41 \"Models/test-creature/retina-small.png\"]42 {:all retina :red retina43 :green retina :blue retina})"))])44 (box45 0.2 0.2 0.246 :name "worm-segment"47 :position (Vector3f. 0 0 0)48 :color ColorRGBA/Orange)]))51 (defn test-basic-touch52 "Testing touch:53 You should see a cube fall onto a table. There is a cross-shaped54 display which reports the cube's sensation of touch. This display55 should change when the cube hits the table, and whenever you hit56 the cube with balls.58 Keys:59 <space> : fire ball"60 ([] (test-basic-touch false))61 ([record?]62 (let [head (doto (worm) (body!))63 touch (touch! head)64 touch-display (view-touch)]65 (world66 (nodify [head67 (box 10 1 10 :position (Vector3f. 0 -10 0)68 :color ColorRGBA/Gray :mass 0)])70 standard-debug-controls72 (fn [world]73 (let [timer (IsoTimer. 60)]74 (.setTimer world timer)75 (display-dilated-time world timer))76 (if record?77 (Capture/captureVideo78 world79 (File. "/home/r/proj/cortex/render/touch-cube/main-view/")))80 (speed-up world)81 (light-up-everything world))83 (fn [world tpf]84 (touch-display85 (map #(% (.getRootNode world)) touch)86 (if record?87 (File. "/home/r/proj/cortex/render/touch-cube/touch/"))))))))