changeset 89:cd5151b5e7c3

starting automatic touch for blender models
author Robert McIntyre <rlm@mit.edu>
date Sat, 07 Jan 2012 10:49:49 -0700
parents 3e929630a25f
children 6d7c17c847a3
files assets/Models/creature1/end.png assets/Models/creature1/one.blend assets/Models/creature1/touch.blend assets/Models/creature1/try-again.blend org/test-creature.org
diffstat 5 files changed, 8 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/creature1/end.png has changed
     2.1 Binary file assets/Models/creature1/one.blend has changed
     3.1 Binary file assets/Models/creature1/touch.blend has changed
     4.1 Binary file assets/Models/creature1/try-again.blend has changed
     5.1 --- a/org/test-creature.org	Sat Jan 07 05:24:14 2012 -0700
     5.2 +++ b/org/test-creature.org	Sat Jan 07 10:49:49 2012 -0700
     5.3 @@ -162,14 +162,12 @@
     5.4           hinge-axis)
     5.5        (.setLimit limit-1 limit-2))))
     5.6  
     5.7 -
     5.8  (defmethod joint-dispatch :cone
     5.9    [constraints control-a control-b pivot-a pivot-b rotation]
    5.10    (let [limit-xz (:limit-xz constraints)
    5.11          limit-xy (:limit-xy constraints)
    5.12          twist    (:twist constraints)]
    5.13      
    5.14 -    
    5.15      (println-repl "creating CONE joint")
    5.16      (println-repl rotation)
    5.17      (println-repl
    5.18 @@ -190,17 +188,15 @@
    5.19                   (float limit-xy)
    5.20                   (float twist)))))
    5.21  
    5.22 -
    5.23 -  
    5.24  (defn connect
    5.25    "here are some examples:
    5.26     {:type :point}
    5.27     {:type :hinge  :limit [0 (/ Math/PI 2)] :axis (Vector3f. 0 1 0)}
    5.28     (:axis defaults to (Vector3f. 1 0 0) if not provided for hinge joints)
    5.29  
    5.30 -   {:type :cone   :limit-xz 0]
    5.31 -                  :limit-xy 0]
    5.32 -                  :twist 0]}   (use XZY rotation mode in blender!)"
    5.33 +   {:type :cone :limit-xz 0]
    5.34 +                :limit-xy 0]
    5.35 +                :twist 0]}   (use XZY rotation mode in blender!)"
    5.36    [#^Node obj-a #^Node obj-b #^Node joint]
    5.37    (let [control-a (.getControl obj-a RigidBodyControl)
    5.38          control-b (.getControl obj-b RigidBodyControl)
    5.39 @@ -208,15 +204,16 @@
    5.40          joint-rotation (.toRotationMatrix (.getWorldRotation joint))
    5.41          pivot-a (world-to-local obj-a joint-center)
    5.42          pivot-b (world-to-local obj-b joint-center)]
    5.43 -    ;; A side-effect of creating a joint registers
    5.44 -    ;; it with both physics objects which in turn
    5.45 -    ;; will register the joint with the physics system
    5.46 -    ;; when the simulation is started.
    5.47 +   
    5.48      (if-let [constraints
    5.49               (map-vals
    5.50                eval
    5.51                (read-string
    5.52                 (meta-data joint "joint")))]
    5.53 +      ;; A side-effect of creating a joint registers
    5.54 +      ;; it with both physics objects which in turn
    5.55 +      ;; will register the joint with the physics system
    5.56 +      ;; when the simulation is started.
    5.57        (do
    5.58          (println-repl "creating joint between"
    5.59                        (.getName obj-a) "and" (.getName obj-b))
    5.60 @@ -224,7 +221,6 @@
    5.61                          control-a control-b
    5.62                          pivot-a pivot-b
    5.63                          joint-rotation))
    5.64 -                        
    5.65        (println-repl "could not find joint meta-data!"))))
    5.66  
    5.67  (defn assemble-creature [#^Node pieces joints]
    5.68 @@ -353,8 +349,6 @@
    5.69                      0)))
    5.70    [origin top bottom table]))
    5.71              
    5.72 -
    5.73 -
    5.74  (defn test-joint [joint]
    5.75    (let [[origin top bottom floor] (world-setup joint)
    5.76          control (.getControl top RigidBodyControl)