# HG changeset patch # User Robert McIntyre # Date 1322540555 25200 # Node ID 7b44348af538c585e9f7737ddc75f3e55fc8dbea # Parent e5e627f50a3a46daec87b33c0892b1d8da922da2 cleaning up body code diff -r e5e627f50a3a -r 7b44348af538 org/body.org --- a/org/body.org Mon Nov 28 02:54:48 2011 -0700 +++ b/org/body.org Mon Nov 28 21:22:35 2011 -0700 @@ -16,24 +16,6 @@ (cortex.import/mega-import-jme3) (rlm.rlm-commands/help) -;;(.loadModel -;; (doto (asset-manager) -;; (.registerLoader BlenderModelLoader (into-array String ["blend"]))) -;; "Models/person/person.blend") - -(defn view-model [^String model] - (view - (.loadModel - (doto (asset-manager) - (.registerLoader BlenderModelLoader (into-array String ["blend"]))) - model))) - -(defn load-blender-scene [^String model] - (.loadModel - (doto (asset-manager) - (.registerLoader BlenderLoader (into-array String ["blend"]))) - model)) - (defn load-blender-model [^String model] (.loadModel @@ -41,23 +23,6 @@ (.registerLoader BlenderModelLoader (into-array String ["blend"]))) model)) -(defn worm - [] - (.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml")) - -(defn oto - [] - (.loadModel (asset-manager) "Models/Oto/Oto.mesh.xml")) - -(defn sinbad - [] - (.loadModel (asset-manager) "Models/Sinbad/Sinbad.mesh.xml")) - -(defn worm-blender - [] - (first (seq (.getChildren (load-blender-model - "Models/anim2/simple-worm.blend"))))) - (defn skel [node] (doto (.getSkeleton @@ -105,26 +70,6 @@ (println "...geo..."))) - - -(defn body - "given a node with a SkeletonControl, will produce a body sutiable - for AI control with movement and proprioception." - [node] - (let [skeleton-control (.getControl node SkeletonControl) - krc (KinematicRagdollControl.)] - (comment - (dorun - (map #(.addBoneName krc %) - ["mid2" "tail" "head" "mid1" "mid3" "mid4" "Dummy-Root" ""] - ;;"mid2" "mid3" "tail" "head"] - ))) - (.addControl node krc) - (.setRagdollMode krc) - ) - node - ) - (defn green-x-ray [] (doto (Material. (asset-manager) "Common/MatDefs/Misc/Unshaded.j3md") @@ -132,241 +77,11 @@ (-> (.getAdditionalRenderState) (.setDepthTest false)))) -(defn show-skeleton [node] - (let [sd - (doto - (SkeletonDebugger. "aurellem-skel-debug" - (skel node)) - (.setMaterial (green-x-ray)))] - (.attachChild node sd) - node)) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; this could be a good way to give objects special properties like -;; being eyes and the like - -(.getUserData - (.getChild - (load-blender-model "Models/property/test.blend") 0) - "properties") - -;; the properties are saved along with the blender file. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - -(defn init-debug-skel-node - [f debug-node skeleton] - (let [bones - (map #(.getBone skeleton %) - (range (.getBoneCount skeleton)))] - (dorun (map #(.setUserControl % true) bones)) - (dorun (map (fn [b] - (println (.getName b) - " -- " (f b))) - bones)) - (dorun - (map #(.attachChild - debug-node - (doto - (sphere 0.1 - :position (f %) - :physical? false) - (.setMaterial (green-x-ray)))) - bones))) - debug-node) - -(import jme3test.bullet.PhysicsTestHelper) - - -(defn test-zzz [the-worm world value] - (if (not value) - (let [skeleton (skel the-worm)] - (println-repl "enabling bones") - (dorun - (map - #(.setUserControl (.getBone skeleton %) true) - (range (.getBoneCount skeleton)))) - - - (let [b (.getBone skeleton 2)] - (println-repl "moving " (.getName b)) - (println-repl (.getLocalPosition b)) - (.setUserTransforms b - Vector3f/UNIT_X - Quaternion/IDENTITY - ;;(doto (Quaternion.) - ;; (.fromAngles (/ Math/PI 2) - ;; 0 - ;; 0 - - (Vector3f. 1 1 1)) - ) - - (println-repl "hi! <3")))) - - -(defn test-ragdoll [] - - (let [the-worm - - ;;(.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml") - (doto (show-skeleton (worm-blender)) - (.setLocalTranslation (Vector3f. 0 10 0)) - ;;(worm) - ;;(oto) - ;;(sinbad) - ) - ] - - - (.start - (world - (doto (Node.) - (.attachChild the-worm)) - {"key-return" (fire-cannon-ball) - "key-space" (partial test-zzz the-worm) - } - (fn [world] - (light-up-everything world) - (PhysicsTestHelper/createPhysicsTestWorld - (.getRootNode world) - (asset-manager) - (.getPhysicsSpace - (.getState (.getStateManager world) BulletAppState))) - (set-gravity world Vector3f/ZERO) - ;;(.setTimer world (NanoTimer.)) - ;;(org.lwjgl.input.Mouse/setGrabbed false) - ) - no-op - ) - - - ))) - - - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; here is the ragdoll stuff - -(def worm-mesh (.getMesh (.getChild (worm-blender) 0))) -(def mesh worm-mesh) - -(.getFloatBuffer mesh VertexBuffer$Type/Position) -(.getFloatBuffer mesh VertexBuffer$Type/BoneWeight) -(.getData (.getBuffer mesh VertexBuffer$Type/BoneIndex)) - - -(defn position [index] - (.get - (.getFloatBuffer worm-mesh VertexBuffer$Type/Position) - index)) - -(defn bones [index] - (.get - (.getData (.getBuffer mesh VertexBuffer$Type/BoneIndex)) - index)) - -(defn bone-weights [index] - (.get - (.getFloatBuffer mesh VertexBuffer$Type/BoneWeight) - index)) - - - -(defn vertex-bones [vertex] - (vec (map (comp int bones) (range (* vertex 4) (+ (* vertex 4) 4))))) - -(defn vertex-weights [vertex] - (vec (map (comp float bone-weights) (range (* vertex 4) (+ (* vertex 4) 4))))) - -(defn vertex-position [index] - (let [offset (* index 3)] - (Vector3f. (position offset) - (position (inc offset)) - (position (inc(inc offset)))))) - -(def vertex-info (juxt vertex-position vertex-bones vertex-weights)) - -(defn bone-control-color [index] - (get {[1 0 0 0] ColorRGBA/Red - [1 2 0 0] ColorRGBA/Magenta - [2 0 0 0] ColorRGBA/Blue} - (vertex-bones index) - ColorRGBA/White)) - -(defn influence-color [index bone-num] - (get - {(float 0) ColorRGBA/Blue - (float 0.5) ColorRGBA/Green - (float 1) ColorRGBA/Red} - ;; find the weight of the desired bone - ((zipmap (vertex-bones index)(vertex-weights index)) - bone-num) - ColorRGBA/Blue)) - -(def worm-vertices (set (map vertex-info (range 60)))) - - -(defn test-info [] - (let [points (Node.)] - (dorun - (map #(.attachChild points %) - (map #(sphere 0.01 - :position (vertex-position %) - :color (influence-color % 1) - :physical? false) - (range 60)))) - (view points))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;; eve-style bodies ;;;;;;;; - -(defrecord JointControl [joint physics-space] - PhysicsControl - (setPhysicsSpace [this space] - (dosync - (ref-set (:physics-space this) space)) - (.addJoint space (:joint this))) - (update [this tpf]) - (setSpatial [this spatial]) - (render [this rm vp]) - (getPhysicsSpace [this] (deref (:physics-space this))) - (isEnabled [this] true) - (setEnabled [this state])) - -(defn add-joint - "Add a joint to a particular object. When the object is added to the - PhysicsSpace of a simulation, the joint will also be added" - [object joint] - (let [control (JointControl. joint (ref nil))] - (.addControl object control)) - object) - -(defn hinge-world - [] - (let [sphere1 (sphere) - sphere2 (sphere 1 :position (Vector3f. 3 3 3)) - joint (Point2PointJoint. - (.getControl sphere1 RigidBodyControl) - (.getControl sphere2 RigidBodyControl) - Vector3f/ZERO (Vector3f. 3 3 3))] - (add-joint sphere1 joint) - (doto (Node. "hinge-world") - (.attachChild sphere1) - (.attachChild sphere2)))) - -(defn test-joint [] - (view (hinge-world))) - - (defn worm [segment-length num-segments interstitial-space radius] (letfn [(nth-segment [n] @@ -387,7 +102,6 @@ node)) ([children] (nodify "" children))) - (defn connect-at-midpoint [segmentA segmentB] (let [centerA (.getWorldTranslation segmentA) @@ -395,23 +109,19 @@ midpoint (.mult (.add centerA centerB) (float 0.5)) pivotA (.subtract midpoint centerA) pivotB (.subtract midpoint centerB) - joint (Point2PointJoint. (.getControl segmentA RigidBodyControl) (.getControl segmentB RigidBodyControl) pivotA pivotB)] - (add-joint segmentA joint) segmentB)) - (defn point-worm [] (let [segments (worm 0.2 5 0.1 0.1)] (dorun (map (partial apply connect-at-midpoint) (partition 2 1 segments))) (nodify "worm" segments))) - (defn test-worm [] (.start (world @@ -445,7 +155,7 @@ ;; correspond to some sort of jet or rocket propulseion) (defn node-seq - "take a node and return a seq of all its children + "Take a node and return a seq of all its children recursively. There will be no nodes left in the resulting structure" [#^Node node] @@ -478,8 +188,6 @@ body-control (partial map #(%1 %2) limb-controls)] body-control)) - - (defn test-motor-map "see how torque works." [] @@ -498,8 +206,6 @@ (fn [_ _] (dorun (motor-map [0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0])))))) - - (defn test-torque "see how torque works." [] @@ -527,7 +233,6 @@ (if @move-right? (.applyTorque control (Vector3f. 0 0 1))))))) - (defn worm-pattern [time] [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 @@ -541,37 +246,8 @@ ]) - -;; (defn copier-gen [] -;; (let [count (atom 0)] -;; (fn [in] -;; (swap! count inc) -;; (clojure.contrib.duck-streams/copy -;; in (File. (str "/home/r/tmp/mao-test/clojure-images/" -;; ;;/home/r/tmp/mao-test/clojure-images -;; (format "%08d.png" @count))))))) -;; (defn decrease-framerate [] -;; (map -;; (copier-gen) -;; (sort -;; (map first -;; (partition -;; 4 -;; (filter #(re-matches #".*.png$" (.getCanonicalPath %)) -;; (file-seq -;; (file-str -;; "/home/r/media/anime/mao-temp/images")))))))) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - - ;;;;;;;;;;;;;;;;;; Proprioception ;;;;;;;;;;;;;;;;;;;;;;;; - ;; this is not used as just getting the rotation would be simpler. (defn proprioception-senses "given a control , create a sequence of thunks that will report the @@ -608,8 +284,6 @@ rotated (.mult q basis-1) alpha (.dot basis-1 (.project rotated basis-1)) beta (.dot basis-2 (.project rotated basis-2))] - (println-repl alpha) - (println-repl beta) (Math/atan2 beta alpha))) @@ -638,10 +312,6 @@ (.subtract (.localToWorld object-b (.getPivotB joint) nil) (.getWorldTranslation object-b)))) - rotate-b - (doto (Matrix3f.) - (.fromStartEndVectors arm-b Vector3f/UNIT_X)) - pitch (.angleBetween (.normalize (Vector2f. (.getX arm-b) (.getY arm-b))) @@ -652,10 +322,12 @@ (Vector2f. 1 0)) roll - (.mult - (.getLocalRotation object-b) - (doto (Quaternion.) - (.fromRotationMatrix rotate-a))) + (rot-about-axis + (.mult + (.getLocalRotation object-b) + (doto (Quaternion.) + (.fromRotationMatrix rotate-a))) + arm-b) ] @@ -673,26 +345,6 @@ -(defn proprioception - "Create a proprioception map that reports the rotations of the - various limbs of the creature's body" - [creature] - [#^Node creature] - (let [ - nodes (node-seq creature) - joints - (map - :joint - (filter - #(isa? (class %) JointControl) - (reduce - concat - (map (fn [node] - (map (fn [num] (.getControl node num)) - (range (.getNumControls node)))) - nodes))))] - (fn [] - (reduce concat (map relative-positions (list (first joints))))))) (defn test-worm-control @@ -700,7 +352,7 @@ (let [worm (point-worm) time (atom 0) worm-motor-map (motor-map worm) - body-map (proprioception worm) + ;;body-map (proprioception worm) debug-segments (map #(doto @@ -740,7 +392,7 @@ (drop 1 (node-seq worm)) debug-segments)) (swap! time inc) - (println-repl (with-out-str (clojure.pprint/pprint (doall (body-map))))) + ;;(println-repl (with-out-str (clojure.pprint/pprint (doall (body-map))))) (Thread/sleep 200) (dorun (worm-motor-map (worm-pattern @time))))))) @@ -755,7 +407,7 @@ (let [hand (box 1 0.2 0.2 :position (Vector3f. 0 2 0) :mass 0 :color ColorRGBA/Green) finger (box 1 0.2 0.2 :position (Vector3f. 2.4 2 0) - :mass 1 :color (ColorRGBA. 0.20 0.40 0.99 1.0)) + :mass 1 :color (ColorRGBA. 0.20 0.40 0.99 1.0)) floor (box 10 0.5 10 :position (Vector3f. 0 -5 0) :mass 0 :color ColorRGBA/Gray) @@ -786,7 +438,7 @@ "key-v" (fn [_ pressed?] (reset! roll-left? pressed?)) "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) (fn [world] - (set-gravity world Vector3f/ZERO) + (set-gravity world (Vector3f. 0 0 0)) (.setMoveSpeed (.getFlyByCamera world) 50) (.setRotationSpeed (.getFlyByCamera world) 50) (light-up-everything world) @@ -796,48 +448,372 @@ (if @move-up? (.applyTorque control (.mult (.getPhysicsRotation control) - (Vector3f. 0 0 1)))) + (Vector3f. 0 0 10)))) (if @move-down? (.applyTorque control (.mult (.getPhysicsRotation control) - (Vector3f. 0 0 -1)))) + (Vector3f. 0 0 -10)))) (if @move-left? (.applyTorque control (.mult (.getPhysicsRotation control) - (Vector3f. 0 1 0)))) + (Vector3f. 0 10 0)))) (if @move-right? (.applyTorque control (.mult (.getPhysicsRotation control) - (Vector3f. 0 -1 0)))) + (Vector3f. 0 -10 0)))) (if @roll-left? (.applyTorque control (.mult (.getPhysicsRotation control) - (Vector3f. -0.1 0 0)))) + (Vector3f. -1 0 0)))) (if @roll-right? (.applyTorque control (.mult (.getPhysicsRotation control) - (Vector3f. 0.1 0 0)))) + (Vector3f. 1 0 0)))) (if (= 0 (rem (swap! time inc) 2000)) - (do - ;;(println-repl (.getLocalRotation finger)) - (println-repl (nth (relative-positions joint) 2)))) - - )))) - - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - + (do + + (apply + (comp + println-repl + #(format "pitch: %1.2f\nyaw: %1.2f\nroll: %1.2f\n" %1 %2 %3)) + (relative-positions joint)))))))) #+end_src -#+results: body-main -: #'cortex.body/test-prop +* COMMENT failed-clojure-code +#+begin_src clojure +;;(.loadModel +;; (doto (asset-manager) +;; (.registerLoader BlenderModelLoader (into-array String ["blend"]))) +;; "Models/person/person.blend") + +(defn view-model [^String model] + (view + (.loadModel + (doto (asset-manager) + (.registerLoader BlenderModelLoader (into-array String ["blend"]))) + model))) + +(defn load-blender-scene [^String model] + (.loadModel + (doto (asset-manager) + (.registerLoader BlenderLoader (into-array String ["blend"]))) + model)) + +(defn worm + [] + (.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml")) + +(defn oto + [] + (.loadModel (asset-manager) "Models/Oto/Oto.mesh.xml")) + +(defn sinbad + [] + (.loadModel (asset-manager) "Models/Sinbad/Sinbad.mesh.xml")) + +(defn worm-blender + [] + (first (seq (.getChildren (load-blender-model + "Models/anim2/simple-worm.blend"))))) + +(defn body + "given a node with a SkeletonControl, will produce a body sutiable + for AI control with movement and proprioception." + [node] + (let [skeleton-control (.getControl node SkeletonControl) + krc (KinematicRagdollControl.)] + (comment + (dorun + (map #(.addBoneName krc %) + ["mid2" "tail" "head" "mid1" "mid3" "mid4" "Dummy-Root" ""] + ;;"mid2" "mid3" "tail" "head"] + ))) + (.addControl node krc) + (.setRagdollMode krc) + ) + node + ) +(defn show-skeleton [node] + (let [sd + + (doto + (SkeletonDebugger. "aurellem-skel-debug" + (skel node)) + (.setMaterial (green-x-ray)))] + (.attachChild node sd) + node)) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; this could be a good way to give objects special properties like +;; being eyes and the like + +(.getUserData + (.getChild + (load-blender-model "Models/property/test.blend") 0) + "properties") + +;; the properties are saved along with the blender file. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + + +(defn init-debug-skel-node + [f debug-node skeleton] + (let [bones + (map #(.getBone skeleton %) + (range (.getBoneCount skeleton)))] + (dorun (map #(.setUserControl % true) bones)) + (dorun (map (fn [b] + (println (.getName b) + " -- " (f b))) + bones)) + (dorun + (map #(.attachChild + debug-node + (doto + (sphere 0.1 + :position (f %) + :physical? false) + (.setMaterial (green-x-ray)))) + bones))) + debug-node) + +(import jme3test.bullet.PhysicsTestHelper) + + +(defn test-zzz [the-worm world value] + (if (not value) + (let [skeleton (skel the-worm)] + (println-repl "enabling bones") + (dorun + (map + #(.setUserControl (.getBone skeleton %) true) + (range (.getBoneCount skeleton)))) + + + (let [b (.getBone skeleton 2)] + (println-repl "moving " (.getName b)) + (println-repl (.getLocalPosition b)) + (.setUserTransforms b + Vector3f/UNIT_X + Quaternion/IDENTITY + ;;(doto (Quaternion.) + ;; (.fromAngles (/ Math/PI 2) + ;; 0 + ;; 0 + + (Vector3f. 1 1 1)) + ) + + (println-repl "hi! <3")))) + + +(defn test-ragdoll [] + + (let [the-worm + + ;;(.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml") + (doto (show-skeleton (worm-blender)) + (.setLocalTranslation (Vector3f. 0 10 0)) + ;;(worm) + ;;(oto) + ;;(sinbad) + ) + ] + + + (.start + (world + (doto (Node.) + (.attachChild the-worm)) + {"key-return" (fire-cannon-ball) + "key-space" (partial test-zzz the-worm) + } + (fn [world] + (light-up-everything world) + (PhysicsTestHelper/createPhysicsTestWorld + (.getRootNode world) + (asset-manager) + (.getPhysicsSpace + (.getState (.getStateManager world) BulletAppState))) + (set-gravity world Vector3f/ZERO) + ;;(.setTimer world (NanoTimer.)) + ;;(org.lwjgl.input.Mouse/setGrabbed false) + ) + no-op + ) + + + ))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; here is the ragdoll stuff + +(def worm-mesh (.getMesh (.getChild (worm-blender) 0))) +(def mesh worm-mesh) + +(.getFloatBuffer mesh VertexBuffer$Type/Position) +(.getFloatBuffer mesh VertexBuffer$Type/BoneWeight) +(.getData (.getBuffer mesh VertexBuffer$Type/BoneIndex)) + + +(defn position [index] + (.get + (.getFloatBuffer worm-mesh VertexBuffer$Type/Position) + index)) + +(defn bones [index] + (.get + (.getData (.getBuffer mesh VertexBuffer$Type/BoneIndex)) + index)) + +(defn bone-weights [index] + (.get + (.getFloatBuffer mesh VertexBuffer$Type/BoneWeight) + index)) + + + +(defn vertex-bones [vertex] + (vec (map (comp int bones) (range (* vertex 4) (+ (* vertex 4) 4))))) + +(defn vertex-weights [vertex] + (vec (map (comp float bone-weights) (range (* vertex 4) (+ (* vertex 4) 4))))) + +(defn vertex-position [index] + (let [offset (* index 3)] + (Vector3f. (position offset) + (position (inc offset)) + (position (inc(inc offset)))))) + +(def vertex-info (juxt vertex-position vertex-bones vertex-weights)) + +(defn bone-control-color [index] + (get {[1 0 0 0] ColorRGBA/Red + [1 2 0 0] ColorRGBA/Magenta + [2 0 0 0] ColorRGBA/Blue} + (vertex-bones index) + ColorRGBA/White)) + +(defn influence-color [index bone-num] + (get + {(float 0) ColorRGBA/Blue + (float 0.5) ColorRGBA/Green + (float 1) ColorRGBA/Red} + ;; find the weight of the desired bone + ((zipmap (vertex-bones index)(vertex-weights index)) + bone-num) + ColorRGBA/Blue)) + +(def worm-vertices (set (map vertex-info (range 60)))) + + +(defn test-info [] + (let [points (Node.)] + (dorun + (map #(.attachChild points %) + (map #(sphere 0.01 + :position (vertex-position %) + :color (influence-color % 1) + :physical? false) + (range 60)))) + (view points))) + + +(defrecord JointControl [joint physics-space] + PhysicsControl + (setPhysicsSpace [this space] + (dosync + (ref-set (:physics-space this) space)) + (.addJoint space (:joint this))) + (update [this tpf]) + (setSpatial [this spatial]) + (render [this rm vp]) + (getPhysicsSpace [this] (deref (:physics-space this))) + (isEnabled [this] true) + (setEnabled [this state])) + +(defn add-joint + "Add a joint to a particular object. When the object is added to the + PhysicsSpace of a simulation, the joint will also be added" + [object joint] + (let [control (JointControl. joint (ref nil))] + (.addControl object control)) + object) + + +(defn hinge-world + [] + (let [sphere1 (sphere) + sphere2 (sphere 1 :position (Vector3f. 3 3 3)) + joint (Point2PointJoint. + (.getControl sphere1 RigidBodyControl) + (.getControl sphere2 RigidBodyControl) + Vector3f/ZERO (Vector3f. 3 3 3))] + (add-joint sphere1 joint) + (doto (Node. "hinge-world") + (.attachChild sphere1) + (.attachChild sphere2)))) + + +(defn test-joint [] + (view (hinge-world))) + +;; (defn copier-gen [] +;; (let [count (atom 0)] +;; (fn [in] +;; (swap! count inc) +;; (clojure.contrib.duck-streams/copy +;; in (File. (str "/home/r/tmp/mao-test/clojure-images/" +;; ;;/home/r/tmp/mao-test/clojure-images +;; (format "%08d.png" @count))))))) +;; (defn decrease-framerate [] +;; (map +;; (copier-gen) +;; (sort +;; (map first +;; (partition +;; 4 +;; (filter #(re-matches #".*.png$" (.getCanonicalPath %)) +;; (file-seq +;; (file-str +;; "/home/r/media/anime/mao-temp/images")))))))) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn proprioception + "Create a proprioception map that reports the rotations of the + various limbs of the creature's body" + [creature] + [#^Node creature] + (let [ + nodes (node-seq creature) + joints + (map + :joint + (filter + #(isa? (class %) JointControl) + (reduce + concat + (map (fn [node] + (map (fn [num] (.getControl node num)) + (range (.getNumControls node)))) + nodes))))] + (fn [] + (reduce concat (map relative-positions (list (first joints))))))) + + +#+end_src