changeset 136:47a4d74761f0

fixed some more problems with proprioception
author Robert McIntyre <rlm@mit.edu>
date Wed, 01 Feb 2012 17:39:23 -0700
parents 421cc43441ae
children 39c89ae5c7d0
files assets/Models/creature1/try-again.blend org/body.org
diffstat 2 files changed, 32 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/creature1/try-again.blend has changed
     2.1 --- a/org/body.org	Wed Feb 01 05:43:51 2012 -0700
     2.2 +++ b/org/body.org	Wed Feb 01 17:39:23 2012 -0700
     2.3 @@ -74,17 +74,18 @@
     2.4      (fn []
     2.5        ;; x is the "twist" axis, y and z are the "bend" axes
     2.6        (let [rot-a (.getWorldRotation obj-a)
     2.7 +            ;;inv-a (.inverse rot-a)
     2.8              rot-b (.getWorldRotation obj-b)
     2.9 -            relative (.mult rot-b (.inverse rot-a))
    2.10 +            ;;relative (.mult rot-b inv-a)
    2.11              basis (doto (Matrix3f.)
    2.12 -                    (.setColumn 0 x)
    2.13 -                    (.setColumn 1 y)
    2.14 -                    (.setColumn 2 z))
    2.15 +                    (.setColumn 0 (.mult rot-a x))
    2.16 +                    (.setColumn 1 (.mult rot-a y))
    2.17 +                    (.setColumn 2 (.mult rot-a z)))
    2.18              rotation-about-joint
    2.19              (doto (Quaternion.)
    2.20                (.fromRotationMatrix 
    2.21                 (.mult (.invert basis)
    2.22 -                      (.toRotationMatrix relative))))
    2.23 +                      (.toRotationMatrix rot-b))))
    2.24              [yaw roll pitch]
    2.25              (seq (.toAngles rotation-about-joint nil))]
    2.26          ;;return euler angles of the quaternion around the new basis            
    2.27 @@ -358,13 +359,16 @@
    2.28          joint (join-at-point hand finger (Vector3f. 1.2 2 0 ))
    2.29          creature (nodify [hand finger joint-node])
    2.30          ;; *******************************************
    2.31 +        rot (doto (Quaternion.)
    2.32 +               (.fromAngleAxis (/ Math/PI 4)
    2.33 +                               (Vector3f. 0 0 -1)))
    2.34          hand2 (box 1 0.2 0.2 :position (Vector3f. 0 1.5 -3)
    2.35 -                  :mass 0 :color ColorRGBA/Blue)
    2.36 +                  :mass 0 :color ColorRGBA/Blue :rotation rot)
    2.37          finger2 (box 1 0.2 0.2 :position (Vector3f. 2.4 1.5 -3)
    2.38 -                    :mass 1 :color ColorRGBA/Magenta)
    2.39 +                    :mass 1 :color ColorRGBA/Magenta :rotation rot)
    2.40          joint-node2 (box 0.1 0.05 0.05 :color ColorRGBA/Gray
    2.41                          :position (Vector3f. 1.2 1.5 -3)
    2.42 -                        :physical? false)
    2.43 +                        :physical? false :rotation rot)
    2.44          joint2 (join-at-point hand2 finger2 (Vector3f. 1.2 1.5 -3))
    2.45          creature2 (nodify [hand2 finger2 joint-node2])
    2.46          ;; *******************************************
    2.47 @@ -383,14 +387,17 @@
    2.48          root (nodify [creature creature2 floor])
    2.49          prop (joint-proprioception creature joint-node)
    2.50          prop-view (proprioception-debug-window)]
    2.51 +             
    2.52      
    2.53  
    2.54 +    (.setCollisionGroup
    2.55 +     (.getControl hand RigidBodyControl)
    2.56 +     PhysicsCollisionObject/COLLISION_GROUP_NONE)
    2.57 +    (.setCollisionGroup
    2.58 +     (.getControl hand2 RigidBodyControl)
    2.59 +     PhysicsCollisionObject/COLLISION_GROUP_NONE)
    2.60 +
    2.61      
    2.62 -    (comment
    2.63 -      (.setCollisionGroup
    2.64 -       (.getControl hand RigidBodyControl)
    2.65 -       PhysicsCollisionObject/COLLISION_GROUP_NONE)
    2.66 -      )
    2.67  
    2.68      
    2.69      (world
    2.70 @@ -414,12 +421,18 @@
    2.71               down (Vector3f. 0 0 -1)
    2.72               roll-left (Vector3f. -1 0 0)
    2.73               roll-right (Vector3f. 1 0 0)]
    2.74 -         (if @move-up? (tap finger up force))
    2.75 -         (if @move-down? (tap finger down force))
    2.76 -         (if @move-left? (tap finger left force))
    2.77 -         (if @move-right? (tap finger right force))
    2.78 -         (if @roll-left? (tap finger roll-left (/ force 10)))
    2.79 -         (if @roll-right? (tap finger roll-right (/ force 10))))
    2.80 +         (if @move-up? (do (tap finger up force)
    2.81 +                           (tap finger2 up force)))
    2.82 +         (if @move-down? (do (tap finger down force)
    2.83 +                             (tap finger2 down force)))
    2.84 +         (if @move-left? (do (tap finger left force)
    2.85 +                             (tap finger2 left force)))
    2.86 +         (if @move-right? (do (tap finger right force)
    2.87 +                              (tap finger2 right force)))
    2.88 +         (if @roll-left? (do (tap finger roll-left (/ force 10))
    2.89 +                             (tap finger2 roll-left (/ force 10))))
    2.90 +         (if @roll-right? (do (tap finger roll-right (/ force 10))
    2.91 +                              (tap finger2 roll-right (/ force 10)))))
    2.92         (prop-view (list (prop)))))))
    2.93  
    2.94  #+end_src