comparison org/movement.org @ 296:1eed471e2ebf

first version of a mini motor-control script language
author Robert McIntyre <rlm@mit.edu>
date Thu, 16 Feb 2012 11:04:22 -0700
parents 67a4e92d4628
children 7e7f8d6d9ec5
comparison
equal deleted inserted replaced
295:67a4e92d4628 296:1eed471e2ebf
116 (.mult (.getWorldRotation muscle) Vector3f/UNIT_Y) 116 (.mult (.getWorldRotation muscle) Vector3f/UNIT_Y)
117 strength (muscle-strength muscle) 117 strength (muscle-strength muscle)
118 118
119 pool (motor-pool muscle) 119 pool (motor-pool muscle)
120 pool-integral (reductions + pool) 120 pool-integral (reductions + pool)
121 force-index 121 forces
122 (vec (map #(float (* strength (/ % (last pool-integral)))) 122 (vec (map #(float (* strength (/ % (last pool-integral))))
123 pool-integral)) 123 pool-integral))
124 control (.getControl target RigidBodyControl)] 124 control (.getControl target RigidBodyControl)]
125 (println-repl "adding muscle to" (.getName target)) 125 (println-repl (.getName target) axis)
126 (println-repl "points" axis)
127 (fn [n] 126 (fn [n]
128 (let [pool-index (max 0 (min n (dec (count pool)))) 127 (let [pool-index (max 0 (min n (dec (count pool))))
129 force (force-index pool-index)] 128 force (forces pool-index)]
130 (.applyTorque control (.mult axis force)) 129 (.applyTorque control (.mult axis force))
131 (float (/ force strength)))))) 130 (float (/ force strength))))))
132 131
133 (defn movement! 132 (defn movement!
134 "Endow the creature with the power of movement. Returns a sequence 133 "Endow the creature with the power of movement. Returns a sequence