comparison org/test-creature.org @ 85:00ab1f10266f

creatig cone joints for hand
author Robert McIntyre <rlm@mit.edu>
date Sat, 07 Jan 2012 01:32:15 -0700
parents 4f5e2c629e45
children af1bb43661f9
comparison
equal deleted inserted replaced
84:4f5e2c629e45 85:00ab1f10266f
178 (.setLimit limit-1 limit-2)))) 178 (.setLimit limit-1 limit-2))))
179 (= :cone joint-type) 179 (= :cone joint-type)
180 (do 180 (do
181 (let [limit-xz (:limit-xz constraints) 181 (let [limit-xz (:limit-xz constraints)
182 limit-xy (:limit-xy constraints) 182 limit-xy (:limit-xy constraints)
183 twist (:twist constraints)] 183 twist (:twist constraints)
184 rotation (.toRotationMatrix (.getWorldRotation joint))]
184 185
185 (println-repl "creating CONE joint") 186 (println-repl "creating CONE joint")
186 (let [frame-a 187 (println-repl rotation)
187 (.toRotationMatrix 188 (println-repl
188 (doto (Quaternion.) 189 "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0)))
189 (.fromAngleAxis 190 (println-repl
190 (float 191 "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0)))
191 (.angleBetween 192 (println-repl
192 (.normalize pivot-a) Vector3f/UNIT_X)) 193 "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1)))
193 (.normalize 194 (doto
194 (.cross pivot-a 195 (ConeJoint.
195 Vector3f/UNIT_X))))) 196 control-a
196 ] 197 control-b
197 (println-repl "pivot-a" pivot-a) 198 pivot-a
198 (println-repl 199 pivot-b
199 "angle between pivot-a and UNIT_X is" 200 rotation
200 (.angleBetween Vector3f/UNIT_X (.normalize pivot-a))) 201 rotation
201 (println-repl "frame-a:" frame-a) 202 )
202 (println-repl 203 (.setLimit (float limit-xz)
203 "frame-a moves Vector3f/UNIT_X to" 204 (float limit-xy)
204 (.mult frame-a Vector3f/UNIT_X )) 205 (float twist)))))
205
206
207 (doto
208 (ConeJoint.
209 control-a
210 control-b
211 pivot-a
212 pivot-b
213
214
215 ;; frame-in-A
216 ;;frame-a
217 ;;frame-a
218
219 (.toRotationMatrix
220 (doto (Quaternion.)
221 (.fromAngles
222 0 0 (* -0.5 (/ Math/PI 2)))))
223
224
225 ;; frame-in-B
226 (.toRotationMatrix
227 (doto (Quaternion.)
228 (.fromAngles
229 0 0 (* -0.5 (/ Math/PI 2)))))
230
231
232 )
233 (.setLimit (float limit-xz)
234 (float limit-xy)
235 (float twist))))))
236 true 206 true
237 (println-repl 207 (println-repl
238 "joint-type" joint-type "not recognized"))) 208 "joint-type" joint-type "not recognized")))
239 209
240 (println-repl "could not find joint meta-data!")))) 210 (println-repl "could not find joint meta-data!"))))
319 (.toRotationMatrix 289 (.toRotationMatrix
320 (.mult 290 (.mult
321 (doto (Quaternion.) 291 (doto (Quaternion.)
322 (.fromAngleAxis 292 (.fromAngleAxis
323 (* 1 (/ Math/PI 4)) 293 (* 1 (/ Math/PI 4))
324 (Vector3f. 0 0 1))) 294 (Vector3f. -1 0 0)))
325 (.mult 295 (doto (Quaternion.)
326 (doto (Quaternion.) 296 (.fromAngleAxis
327 (.fromAngleAxis 297 (* 1 (/ Math/PI 2))
328 (* 2 (/ Math/PI 4)) 298 (Vector3f. 0 0 1)))))
329 (Vector3f. 0 1 0)))
330 (doto (Quaternion.)
331 (.fromAngleAxis
332 (* 1 (/ Math/PI 2))
333 (Vector3f. 0 0 1))))))
334 top-position (.mult joint-rotation (Vector3f. 8 0 0)) 299 top-position (.mult joint-rotation (Vector3f. 8 0 0))
335 300
336 origin (doto 301 origin (doto
337 (sphere 0.1 :physical? false :color ColorRGBA/Cyan 302 (sphere 0.1 :physical? false :color ColorRGBA/Cyan
338 :position top-position)) 303 :position top-position))