(ns cortex.test.touch (:use (cortex world util sense body touch)) (:use cortex.test.body) (:import (com.aurellem.capture Capture IsoTimer)) (:import java.io.File) (:import (com.jme3.math Vector3f ColorRGBA))) (in-ns 'cortex.test.touch) (defn touch-cube [] (load-blender-model "Models/test-touch/touch-cube.blend")) (in-ns 'cortex.test.touch) (defn test-basic-touch "Testing touch: You should see a cube fall onto a table. There is a cross-shaped display which reports the cube's sensation of touch. This display should change when the cube hits the table, and whenever you hit the cube with balls. Keys: : fire ball" ([] (test-basic-touch false)) ([record?] (let [the-cube (doto (touch-cube) (body!)) touch (touch! the-cube) touch-display (view-touch)] (world (nodify [the-cube (box 10 1 10 :position (Vector3f. 0 -10 0) :color ColorRGBA/Gray :mass 0)]) standard-debug-controls (fn [world] (let [timer (IsoTimer. 60)] (.setTimer world timer) (display-dilated-time world timer)) (if record? (Capture/captureVideo world (File. "/home/r/proj/cortex/render/touch-cube/main-view/"))) (speed-up world) (light-up-everything world)) (fn [world tpf] (touch-display (map #(% (.getRootNode world)) touch) (if record? (File. "/home/r/proj/cortex/render/touch-cube/touch/")))))))) (in-ns 'cortex.test.touch) (defn test-worm-touch "Testing touch: You will see the worm fall onto a table. There is a display which reports the worm's sense of touch. It should change when the worm hits the table and when you hit it with balls. Keys: : fire ball" ([] (test-worm-touch false)) ([record?] (let [the-worm (doto (worm) (body!)) touch (touch! the-worm) touch-display (view-touch)] (world (nodify [the-worm (floor)]) standard-debug-controls (fn [world] (let [timer (IsoTimer. 60)] (.setTimer world timer) (display-dilated-time world timer)) (if record? (Capture/captureVideo world (File. "/home/r/proj/cortex/render/worm-touch/main-view/"))) (speed-up world) (light-up-everything world)) (fn [world tpf] (touch-display (map #(% (.getRootNode world)) touch) (if record? (File. "/home/r/proj/cortex/render/worm-touch/touch/"))))))))