diff org/test-creature.org @ 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
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Wed Jan 04 21:03:25 2012 -0700
     1.2 +++ b/org/test-creature.org	Thu Jan 05 02:35:07 2012 -0700
     1.3 @@ -173,31 +173,62 @@
     1.4                           twist    (:twist constraints)]
     1.5                       
     1.6                       (println-repl "creating CONE joint")
     1.7 -                     (doto
     1.8 -                         (ConeJoint.
     1.9 -                          control-a
    1.10 -                          control-b
    1.11 -                          pivot-a
    1.12 -                          pivot-b
    1.13 -                          
    1.14 -                          (doto (Matrix3f.)
    1.15 -                            (.fromStartEndVectors
    1.16 -                             Vector3f/UNIT_X
    1.17 -                             (.normalize
    1.18 -                              (.subtract
    1.19 -                               (.getWorldTranslation joint)
    1.20 -                               (.getWorldTranslation obj-a)))))
    1.21 -                          (doto (Matrix3f.)
    1.22 -                            (.set (.getWorldRotation joint)))
    1.23 -                          
    1.24 -                          )
    1.25 -                       (.setLimit (float limit-xy)
    1.26 -                                  (float limit-yz)
    1.27 -                                  (float twist)))))
    1.28 -                 true
    1.29 -                 (println-repl
    1.30 -                  "joint-type" joint-type "not recognized")))
    1.31 -                 
    1.32 +                     (let [vector-1
    1.33 +                           (.mult (.getWorldRotation joint)
    1.34 +                                  Vector3f/UNIT_X)
    1.35 +                           vector-2
    1.36 +                           (.normalize
    1.37 +                            (.subtract
    1.38 +                             (.getWorldTranslation joint)
    1.39 +                             (.getWorldTranslation obj-a)))
    1.40 +                           ]
    1.41 +                       (println-repl
    1.42 +                        "vector-1 :" vector-1)
    1.43 +                       (println-repl
    1.44 +                        "vector-2 :" vector-2)
    1.45 +                        
    1.46 +                       
    1.47 +                       
    1.48 +                       (doto
    1.49 +                           (ConeJoint.
    1.50 +                            control-a
    1.51 +                            control-b
    1.52 +                            pivot-a
    1.53 +                            pivot-b
    1.54 +                            
    1.55 +                            ;;(doto (Matrix3f.)
    1.56 +                            ;;  (.fromStartEndVectors
    1.57 +                            ;;   Vector3f/UNIT_X
    1.58 +                            ;;   (.normalize
    1.59 +                            ;;    (.subtract
    1.60 +                            ;;     (.getWorldTranslation joint)
    1.61 +                            ;;     (.getWorldTranslation obj-a)))))
    1.62 +                            
    1.63 +                            (.toRotationMatrix (.getWorldRotation joint))
    1.64 +
    1.65 +                            (.toRotationMatrix
    1.66 +                             (.fromAngleAxis (Quaternion.)
    1.67 +                              (.angleBetween Vector3f/UNIT_X pivot-a)
    1.68 +                              (.cross Vector3f/UNIT_X pivot-a)))
    1.69 +                            
    1.70 +                            ;; (doto (Matrix3f.)
    1.71 +                            ;;   (.fromStartEndVectors
    1.72 +                            ;;    Vector3f/UNIT_X
    1.73 +                            ;;    (.normalize
    1.74 +                            ;;     vector-1)))
    1.75 +                            
    1.76 +                            ;; (doto (Matrix3f.)
    1.77 +                            ;;   (.fromStartEndVectors
    1.78 +                            ;;    Vector3f/UNIT_X
    1.79 +                            ;;    vector-2))
    1.80 +                            )
    1.81 +                         (.setLimit (float limit-xy)
    1.82 +                                    (float limit-yz)
    1.83 +                                    (float twist))))))
    1.84 +                   true
    1.85 +                   (println-repl
    1.86 +                    "joint-type" joint-type "not recognized")))
    1.87 +           
    1.88             (println-repl "could not find joint meta-data!")))))
    1.89  
    1.90  (defn assemble-creature [#^Node pieces joints]
    1.91 @@ -241,20 +272,35 @@
    1.92  
    1.93  (def worm "Models/creature1/try-again.blend")
    1.94  
    1.95 +(defn x-ray [#^ColorRGBA color]
    1.96 +  (doto (Material. (asset-manager)
    1.97 +                   "Common/MatDefs/Misc/Unshaded.j3md")
    1.98 +    (.setColor "Color" color)
    1.99 +    (-> (.getAdditionalRenderState)
   1.100 +        (.setDepthTest false))))
   1.101 +
   1.102  (defn test-creature [thing]
   1.103 +  (let [x-axis
   1.104 +        (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red)
   1.105 +        y-axis
   1.106 +        (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green)
   1.107 +        z-axis
   1.108 +        (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue)]
   1.109    (world
   1.110     (nodify [(blender-creature thing)
   1.111              (box 10 2 10 :position (Vector3f. 0 -5.5 0)
   1.112 -                 :color ColorRGBA/Gray :mass 0)])
   1.113 +                 :color ColorRGBA/Gray :mass 0)
   1.114 +            x-axis y-axis z-axis
   1.115 +            ])
   1.116     standard-debug-controls
   1.117     (comp light-up-everything enable-debug
   1.118           (fn [world]
   1.119             (.setTimer world (NanoTimer.))
   1.120 -           ;;(set-gravity world (Vector3f. 0 0 0))
   1.121 +           (set-gravity world (Vector3f. 0 0 0))
   1.122             (speed-up world)
   1.123             world
   1.124             ))
   1.125 -   no-op))
   1.126 +   no-op)))
   1.127  
   1.128  (defn world-setup [joint]
   1.129    (let [top (doto
   1.130 @@ -309,7 +355,7 @@
   1.131              (doto (Matrix3f.)
   1.132                (.fromStartEndVectors Vector3f/UNIT_X
   1.133                                      (.normalize
   1.134 -                                     (Vector3f. 5 5 0))))
   1.135 +                                     (Vector3f. 0 0 -1))))
   1.136              )
   1.137         ;;(.setAngularOnly true)
   1.138