diff org/body.org @ 53:bb24106cbd6a

many problems solved by tightening up the vertex groups in the blender model
author Robert McIntyre <rlm@mit.edu>
date Tue, 15 Nov 2011 00:24:46 -0700
parents 00d0e1639d4b
children 7bc3b22c507b
line wrap: on
line diff
     1.1 --- a/org/body.org	Mon Nov 14 21:30:23 2011 -0700
     1.2 +++ b/org/body.org	Tue Nov 15 00:24:46 2011 -0700
     1.3 @@ -5,7 +5,7 @@
     1.4  #+SETUPFILE: ../../aurellem/org/setup.org
     1.5  #+INCLUDE: ../../aurellem/org/level-0.org
     1.6  
     1.7 -* Body  
     1.8 +* COMMENT Body  
     1.9  
    1.10  #+srcname: body-main
    1.11  #+begin_src clojure 
    1.12 @@ -112,30 +112,13 @@
    1.13    for AI control with movement and proprioception."
    1.14    [node]
    1.15    (let [skeleton-control (.getControl node SkeletonControl)
    1.16 -        krc (KinematicRagdollControl. (float 0.5))]
    1.17 +        krc (KinematicRagdollControl.)]
    1.18 +    (comment
    1.19      (dorun
    1.20       (map #(.addBoneName krc %)
    1.21 -          ["mid1" "mid2" "mid3" "tail" "head"]
    1.22 -        ;; ["Ulna.L"
    1.23 -        ;;  "Ulna.R"
    1.24 -        ;;  "Chest"
    1.25 -        ;;  "Foot.L"
    1.26 -        ;;  "Foot.R"
    1.27 -        ;;  "Hand.R"
    1.28 -        ;;  "Hand.L"
    1.29 -        ;;  "Neck"
    1.30 -        ;;  "Root"
    1.31 -        ;;  "Stomach"
    1.32 -        ;;  "Waist"
    1.33 -        ;;  "Humerus.L"
    1.34 -        ;;  "Humerus.R"
    1.35 -        ;;  "Thigh.L"
    1.36 -        ;;  "Thigh.R"
    1.37 -        ;;  "Calf.L"
    1.38 -        ;;  "Calf.R"
    1.39 -        ;;  "Clavicle.L"
    1.40 -        ;;  "Clavicle.R"]
    1.41 -        ))
    1.42 +          ["mid2" "tail" "head" "mid1" "mid3" "mid4" "Dummy-Root" ""]
    1.43 +           ;;"mid2" "mid3" "tail" "head"]
    1.44 +        )))
    1.45  
    1.46  
    1.47      
    1.48 @@ -152,21 +135,16 @@
    1.49      (-> (.getAdditionalRenderState)
    1.50          (.setDepthTest false))))
    1.51  
    1.52 -(defn view-skeleton [node]
    1.53 +(defn show-skeleton [node]
    1.54    (let [sd
    1.55  
    1.56          (doto
    1.57              (SkeletonDebugger. "aurellem-skel-debug"
    1.58                                 (skel node))
    1.59            (.setMaterial (green-x-ray)))]
    1.60 -    (view (doto (Node. "view node")
    1.61 -            (.attachChild sd)
    1.62 +    (.attachChild node sd)
    1.63 +    node))
    1.64  
    1.65 -             
    1.66 -             
    1.67 -             
    1.68 -             ;;(.attachChild node)
    1.69 -             ))))
    1.70    
    1.71  
    1.72  (defn init-debug-skel-node
    1.73 @@ -193,13 +171,40 @@
    1.74  
    1.75  (import jme3test.bullet.PhysicsTestHelper)
    1.76  
    1.77 +
    1.78 +(defn test-zzz [the-worm world value]
    1.79 +  (if (not value)
    1.80 +    (let [skeleton (skel the-worm)]
    1.81 +      (println-repl "enabling bones")
    1.82 +      (dorun
    1.83 +       (map
    1.84 +        #(.setUserControl (.getBone skeleton %) true)
    1.85 +        (range (.getBoneCount skeleton))))
    1.86 +
    1.87 +
    1.88 +      (let [b (.getBone skeleton 6)]
    1.89 +        (println-repl "moving " (.getName b))
    1.90 +        (println-repl (.getLocalPosition b))
    1.91 +        (.setUserTransforms b
    1.92 +                            (.add (.getLocalPosition b) Vector3f/UNIT_X)
    1.93 +                            Quaternion/IDENTITY
    1.94 +                            (Vector3f. 1 1 1))
    1.95 +
    1.96 +        )
    1.97 +      
    1.98 +
    1.99 +      
   1.100 +      (println-repl "hi! <3"))))
   1.101 +
   1.102 +
   1.103  (defn test-ragdoll []
   1.104    
   1.105    (let [the-worm
   1.106 -        (body
   1.107 +        
   1.108           ;;(.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml")
   1.109 -         ;;(worm-blender)
   1.110 -         (worm)
   1.111 +         (doto (show-skeleton (worm-blender))
   1.112 +           (.setLocalTranslation (Vector3f. 0 10 0))
   1.113 +         ;;(worm)
   1.114           ;;(oto)
   1.115           ;;(sinbad)
   1.116          )
   1.117 @@ -210,7 +215,9 @@
   1.118       (world
   1.119        (doto (Node.)
   1.120          (.attachChild the-worm))
   1.121 -      {"mouse-left" (fire-cannon-ball)}
   1.122 +      {"key-return" (fire-cannon-ball)
   1.123 +       "key-space" (partial test-zzz the-worm)
   1.124 +       }
   1.125        (fn [world]
   1.126          (light-up-everything world)
   1.127          (PhysicsTestHelper/createPhysicsTestWorld
   1.128 @@ -218,6 +225,7 @@
   1.129           (asset-manager)
   1.130           (.getPhysicsSpace
   1.131            (.getState (.getStateManager world) BulletAppState)))
   1.132 +        (set-gravity world Vector3f/ZERO)
   1.133          ;;(.setTimer world (NanoTimer.))
   1.134          ;;(org.lwjgl.input.Mouse/setGrabbed false)
   1.135          )