diff org/body.org @ 51:2a6ede6d8ad8

problem was that the skeleton was not 'ready'
author Robert McIntyre <rlm@mit.edu>
date Mon, 14 Nov 2011 19:44:30 -0700
parents b1b90c4ab0bf
children 00d0e1639d4b
line wrap: on
line diff
     1.1 --- a/org/body.org	Mon Nov 14 18:46:34 2011 -0700
     1.2 +++ b/org/body.org	Mon Nov 14 19:44:30 2011 -0700
     1.3 @@ -58,7 +58,6 @@
     1.4    (first (seq (.getChildren (load-blender-model
     1.5                               "Models/anim2/worm3.blend")))))
     1.6  
     1.7 -
     1.8  (defprotocol Textual
     1.9    (text [something]
    1.10      "Display a detailed textual analysis of the given object."))
    1.11 @@ -108,18 +107,30 @@
    1.12    node
    1.13    )
    1.14  
    1.15 +(defn
    1.16 +  green-x-ray []
    1.17 +  (doto (Material. (asset-manager)
    1.18 +                   "Common/MatDefs/Misc/Unshaded.j3md")
    1.19 +    (.setColor "Color" ColorRGBA/Green)
    1.20 +    (-> (.getAdditionalRenderState) (.setDepthTest
    1.21 +                                     false))))
    1.22 +
    1.23  (defn view-skeleton [node]
    1.24    (let [sd
    1.25 +
    1.26          (doto
    1.27 -            (SkeletonDebugger. "aurellem-skel-debug" (skel node))
    1.28 -          (.setMaterial
    1.29 -           (doto (Material. (asset-manager)
    1.30 -                            "Common/MatDefs/Misc/Unshaded.j3md")
    1.31 -             (-> (.getAdditionalRenderState) (.setDepthTest
    1.32 -                                              false)))))]
    1.33 -    
    1.34 -    (.attachChild debug-node sd)))
    1.35 +            (SkeletonDebugger. "aurellem-skel-debug"
    1.36 +                               (skel node))
    1.37 +          (.setMaterial (green-x-ray)))]
    1.38 +    (view (doto (Node. "view node")
    1.39 +            (.attachChild sd)
    1.40  
    1.41 +             
    1.42 +             
    1.43 +             
    1.44 +             ;;(.attachChild node)
    1.45 +             ))))
    1.46 +  
    1.47  
    1.48  (defn init-debug-skel-node
    1.49    [f debug-node skeleton]
    1.50 @@ -131,19 +142,26 @@
    1.51                  (println (.getName b)
    1.52                           " -- " (f b)))
    1.53                bones))
    1.54 -  
    1.55 +
    1.56    (dorun
    1.57     (map #(.attachChild
    1.58            debug-node 
    1.59 -          (sphere 0.1
    1.60 -                  :position (f %)
    1.61 -                  :rotation (.getWorldBindRotation %)
    1.62 -                  :physical? false))
    1.63 +          (doto 
    1.64 +              (sphere 0.1
    1.65 +                      :position (f %)
    1.66 +                      :physical? false)
    1.67 +          (.setMaterial (green-x-ray))))
    1.68          bones)))
    1.69      debug-node)
    1.70  
    1.71  (defn skel [node]
    1.72 -  (.getSkeleton (.getControl node SkeletonControl)))
    1.73 +  (doto
    1.74 +      (.getSkeleton
    1.75 +       (.getControl node SkeletonControl))
    1.76 +    ;; this is necessary to force the skeleton to have accurate world
    1.77 +    ;; transforms before it is rendered to the screen. 
    1.78 +    (.resetAndUpdate)))
    1.79 +
    1.80    
    1.81                           
    1.82