Mercurial > cortex
changeset 80:7af5ef686539
got a finger working!
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 05 Jan 2012 02:35:07 -0700 |
parents | 01dbdb0d5500 |
children | 10f495560c59 |
files | assets/Models/creature1/one.blend assets/Models/creature1/try-again.blend org/test-creature.org |
diffstat | 3 files changed, 75 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
1.1 Binary file assets/Models/creature1/one.blend has changed
2.1 Binary file assets/Models/creature1/try-again.blend has changed
3.1 --- a/org/test-creature.org Wed Jan 04 21:03:25 2012 -0700 3.2 +++ b/org/test-creature.org Thu Jan 05 02:35:07 2012 -0700 3.3 @@ -173,31 +173,62 @@ 3.4 twist (:twist constraints)] 3.5 3.6 (println-repl "creating CONE joint") 3.7 - (doto 3.8 - (ConeJoint. 3.9 - control-a 3.10 - control-b 3.11 - pivot-a 3.12 - pivot-b 3.13 - 3.14 - (doto (Matrix3f.) 3.15 - (.fromStartEndVectors 3.16 - Vector3f/UNIT_X 3.17 - (.normalize 3.18 - (.subtract 3.19 - (.getWorldTranslation joint) 3.20 - (.getWorldTranslation obj-a))))) 3.21 - (doto (Matrix3f.) 3.22 - (.set (.getWorldRotation joint))) 3.23 - 3.24 - ) 3.25 - (.setLimit (float limit-xy) 3.26 - (float limit-yz) 3.27 - (float twist))))) 3.28 - true 3.29 - (println-repl 3.30 - "joint-type" joint-type "not recognized"))) 3.31 - 3.32 + (let [vector-1 3.33 + (.mult (.getWorldRotation joint) 3.34 + Vector3f/UNIT_X) 3.35 + vector-2 3.36 + (.normalize 3.37 + (.subtract 3.38 + (.getWorldTranslation joint) 3.39 + (.getWorldTranslation obj-a))) 3.40 + ] 3.41 + (println-repl 3.42 + "vector-1 :" vector-1) 3.43 + (println-repl 3.44 + "vector-2 :" vector-2) 3.45 + 3.46 + 3.47 + 3.48 + (doto 3.49 + (ConeJoint. 3.50 + control-a 3.51 + control-b 3.52 + pivot-a 3.53 + pivot-b 3.54 + 3.55 + ;;(doto (Matrix3f.) 3.56 + ;; (.fromStartEndVectors 3.57 + ;; Vector3f/UNIT_X 3.58 + ;; (.normalize 3.59 + ;; (.subtract 3.60 + ;; (.getWorldTranslation joint) 3.61 + ;; (.getWorldTranslation obj-a))))) 3.62 + 3.63 + (.toRotationMatrix (.getWorldRotation joint)) 3.64 + 3.65 + (.toRotationMatrix 3.66 + (.fromAngleAxis (Quaternion.) 3.67 + (.angleBetween Vector3f/UNIT_X pivot-a) 3.68 + (.cross Vector3f/UNIT_X pivot-a))) 3.69 + 3.70 + ;; (doto (Matrix3f.) 3.71 + ;; (.fromStartEndVectors 3.72 + ;; Vector3f/UNIT_X 3.73 + ;; (.normalize 3.74 + ;; vector-1))) 3.75 + 3.76 + ;; (doto (Matrix3f.) 3.77 + ;; (.fromStartEndVectors 3.78 + ;; Vector3f/UNIT_X 3.79 + ;; vector-2)) 3.80 + ) 3.81 + (.setLimit (float limit-xy) 3.82 + (float limit-yz) 3.83 + (float twist)))))) 3.84 + true 3.85 + (println-repl 3.86 + "joint-type" joint-type "not recognized"))) 3.87 + 3.88 (println-repl "could not find joint meta-data!"))))) 3.89 3.90 (defn assemble-creature [#^Node pieces joints] 3.91 @@ -241,20 +272,35 @@ 3.92 3.93 (def worm "Models/creature1/try-again.blend") 3.94 3.95 +(defn x-ray [#^ColorRGBA color] 3.96 + (doto (Material. (asset-manager) 3.97 + "Common/MatDefs/Misc/Unshaded.j3md") 3.98 + (.setColor "Color" color) 3.99 + (-> (.getAdditionalRenderState) 3.100 + (.setDepthTest false)))) 3.101 + 3.102 (defn test-creature [thing] 3.103 + (let [x-axis 3.104 + (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red) 3.105 + y-axis 3.106 + (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) 3.107 + z-axis 3.108 + (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue)] 3.109 (world 3.110 (nodify [(blender-creature thing) 3.111 (box 10 2 10 :position (Vector3f. 0 -5.5 0) 3.112 - :color ColorRGBA/Gray :mass 0)]) 3.113 + :color ColorRGBA/Gray :mass 0) 3.114 + x-axis y-axis z-axis 3.115 + ]) 3.116 standard-debug-controls 3.117 (comp light-up-everything enable-debug 3.118 (fn [world] 3.119 (.setTimer world (NanoTimer.)) 3.120 - ;;(set-gravity world (Vector3f. 0 0 0)) 3.121 + (set-gravity world (Vector3f. 0 0 0)) 3.122 (speed-up world) 3.123 world 3.124 )) 3.125 - no-op)) 3.126 + no-op))) 3.127 3.128 (defn world-setup [joint] 3.129 (let [top (doto 3.130 @@ -309,7 +355,7 @@ 3.131 (doto (Matrix3f.) 3.132 (.fromStartEndVectors Vector3f/UNIT_X 3.133 (.normalize 3.134 - (Vector3f. 5 5 0)))) 3.135 + (Vector3f. 0 0 -1)))) 3.136 ) 3.137 ;;(.setAngularOnly true) 3.138