(ns cortex.test.movement (:use (cortex world util sense body movement)) (:use cortex.test.body) (:import java.io.File) (:import java.awt.image.BufferedImage) (:import com.jme3.scene.Node) (:import (com.jme3.math Quaternion Vector3f)) (:import (com.aurellem.capture Capture RatchetTimer IsoTimer)) (:import com.jme3.bullet.control.RigidBodyControl)) (in-ns 'cortex.test.movement) (defn test-worm-movement "Testing movement: You should see the worm suspended in mid air and a display on the right which shows the current relative power being exerted by the muscle. As you increase muscle strength, the bar should fill with red, and the worm's upper segment should move. Keys: h : increase muscle exertion n : decrease muscle exertion" ([] (test-worm-movement false)) ([record?] (let [creature (doto (worm) (body!)) muscle-exertion (atom 0) muscles (movement! creature) muscle-display (view-movement)] (.setMass (.getControl (.getChild creature "worm-11") RigidBodyControl) (float 0)) (world (nodify [creature (floor)]) (merge standard-debug-controls {"key-h" (fn [_ value] (if value (swap! muscle-exertion (partial + 20)))) "key-n" (fn [_ value] (if value (swap! muscle-exertion (fn [v] (- v 20)))))}) (fn [world] (let [timer (RatchetTimer. 60)] (.setTimer world timer) (display-dilated-time world timer)) (if record? (Capture/captureVideo world (File. "/home/r/proj/cortex/render/worm-muscles/main-view"))) (light-up-everything world) (enable-debug world) (set-gravity world (Vector3f. 0 0 0)) (.setLocation (.getCamera world) (Vector3f. -4.912815, 2.004171, 0.15710819)) (.setRotation (.getCamera world) (Quaternion. 0.13828252, 0.65516764, -0.12370994, 0.7323449))) (fn [world tpf] (muscle-display (map #(% @muscle-exertion) muscles) (if record? (File. "/home/r/proj/cortex/render/worm-muscles/muscles"))))))))