# HG changeset patch # User Robert McIntyre # Date 1325756107 25200 # Node ID 7af5ef6865393a4f8ef82d3825625cd549843284 # Parent 01dbdb0d55008403131b94e408e366496946ae9a got a finger working! diff -r 01dbdb0d5500 -r 7af5ef686539 assets/Models/creature1/one.blend Binary file assets/Models/creature1/one.blend has changed diff -r 01dbdb0d5500 -r 7af5ef686539 assets/Models/creature1/try-again.blend Binary file assets/Models/creature1/try-again.blend has changed diff -r 01dbdb0d5500 -r 7af5ef686539 org/test-creature.org --- a/org/test-creature.org Wed Jan 04 21:03:25 2012 -0700 +++ b/org/test-creature.org Thu Jan 05 02:35:07 2012 -0700 @@ -173,31 +173,62 @@ twist (:twist constraints)] (println-repl "creating CONE joint") - (doto - (ConeJoint. - control-a - control-b - pivot-a - pivot-b - - (doto (Matrix3f.) - (.fromStartEndVectors - Vector3f/UNIT_X - (.normalize - (.subtract - (.getWorldTranslation joint) - (.getWorldTranslation obj-a))))) - (doto (Matrix3f.) - (.set (.getWorldRotation joint))) - - ) - (.setLimit (float limit-xy) - (float limit-yz) - (float twist))))) - true - (println-repl - "joint-type" joint-type "not recognized"))) - + (let [vector-1 + (.mult (.getWorldRotation joint) + Vector3f/UNIT_X) + vector-2 + (.normalize + (.subtract + (.getWorldTranslation joint) + (.getWorldTranslation obj-a))) + ] + (println-repl + "vector-1 :" vector-1) + (println-repl + "vector-2 :" vector-2) + + + + (doto + (ConeJoint. + control-a + control-b + pivot-a + pivot-b + + ;;(doto (Matrix3f.) + ;; (.fromStartEndVectors + ;; Vector3f/UNIT_X + ;; (.normalize + ;; (.subtract + ;; (.getWorldTranslation joint) + ;; (.getWorldTranslation obj-a))))) + + (.toRotationMatrix (.getWorldRotation joint)) + + (.toRotationMatrix + (.fromAngleAxis (Quaternion.) + (.angleBetween Vector3f/UNIT_X pivot-a) + (.cross Vector3f/UNIT_X pivot-a))) + + ;; (doto (Matrix3f.) + ;; (.fromStartEndVectors + ;; Vector3f/UNIT_X + ;; (.normalize + ;; vector-1))) + + ;; (doto (Matrix3f.) + ;; (.fromStartEndVectors + ;; Vector3f/UNIT_X + ;; vector-2)) + ) + (.setLimit (float limit-xy) + (float limit-yz) + (float twist)))))) + true + (println-repl + "joint-type" joint-type "not recognized"))) + (println-repl "could not find joint meta-data!"))))) (defn assemble-creature [#^Node pieces joints] @@ -241,20 +272,35 @@ (def worm "Models/creature1/try-again.blend") +(defn x-ray [#^ColorRGBA color] + (doto (Material. (asset-manager) + "Common/MatDefs/Misc/Unshaded.j3md") + (.setColor "Color" color) + (-> (.getAdditionalRenderState) + (.setDepthTest false)))) + (defn test-creature [thing] + (let [x-axis + (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red) + y-axis + (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) + z-axis + (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue)] (world (nodify [(blender-creature thing) (box 10 2 10 :position (Vector3f. 0 -5.5 0) - :color ColorRGBA/Gray :mass 0)]) + :color ColorRGBA/Gray :mass 0) + x-axis y-axis z-axis + ]) standard-debug-controls (comp light-up-everything enable-debug (fn [world] (.setTimer world (NanoTimer.)) - ;;(set-gravity world (Vector3f. 0 0 0)) + (set-gravity world (Vector3f. 0 0 0)) (speed-up world) world )) - no-op)) + no-op))) (defn world-setup [joint] (let [top (doto @@ -309,7 +355,7 @@ (doto (Matrix3f.) (.fromStartEndVectors Vector3f/UNIT_X (.normalize - (Vector3f. 5 5 0)))) + (Vector3f. 0 0 -1)))) ) ;;(.setAngularOnly true)