(ns cortex.test.body (:use (cortex world util body)) (:import (com.aurellem.capture Capture RatchetTimer IsoTimer) (com.jme3.math Quaternion Vector3f ColorRGBA) java.io.File)) (def hand-path "Models/test-creature/hand.blend") (defn hand [] (load-blender-model hand-path)) (defn setup [world] (let [cam (.getCamera world)] (println-repl cam) (.setLocation cam (Vector3f. -6.9015837, 8.644911, 5.6043186)) (.setRotation cam (Quaternion. 0.14046453, 0.85894054, -0.34301838, 0.3533118))) (light-up-everything world) (.setTimer world (RatchetTimer. 60)) world) (defn test-hand-1 ([] (test-hand-1 false)) ([record?] (world (hand) standard-debug-controls (fn [world] (if record? (Capture/captureVideo world (File. "/home/r/proj/cortex/render/body/1"))) (setup world)) no-op))) (in-ns 'cortex.test.body) (def gravity-control {"key-g" (fn [world _] (set-gravity world (Vector3f. 0 -9.81 0))) "key-u" (fn [world _] (set-gravity world Vector3f/ZERO))}) (defn floor [] (box 10 3 10 :position (Vector3f. 0 -10 0) :color ColorRGBA/Gray :mass 0)) (defn test-hand-2 ([] (test-hand-2 false)) ([record?] (world (nodify [(doto (hand) (physical!)) (floor)]) (merge standard-debug-controls gravity-control) (fn [world] (if record? (Capture/captureVideo world (File. "/home/r/proj/cortex/render/body/2"))) (set-gravity world Vector3f/ZERO) (setup world)) no-op))) (in-ns 'cortex.test.body) (def debug-control {"key-h" (fn [world val] (if val (enable-debug world)))}) (defn test-hand-3 ([] (test-hand-3 false)) ([record?] (world (nodify [(doto (hand) (physical!) (joints!)) (floor)]) (merge standard-debug-controls debug-control gravity-control) (comp #(Capture/captureVideo % (File. "/home/r/proj/cortex/render/body/3")) #(do (set-gravity % Vector3f/ZERO) %) setup) no-op))) (in-ns 'cortex.test.body) (defn worm [] (load-blender-model "Models/test-creature/worm.blend")) (defn test-worm "Testing physical bodies: You should see the the worm fall onto a table. You can fire physical balls at it and the worm should move upon being struck. Keys: : fire cannon ball." ([] (test-worm false)) ([record?] (let [timer (RatchetTimer. 60)] (world (nodify [(doto (worm) (body!)) (floor)]) (merge standard-debug-controls debug-control) #(do (speed-up %) (light-up-everything %) (.setTimer % timer) (cortex.util/display-dilated-time % timer) (if record? (Capture/captureVideo % (File. "/home/r/proj/cortex/render/body/4")))) no-op))))