changeset 57:37a3256e1ed3

problems resolved
author Robert McIntyre <rlm@mit.edu>
date Wed, 16 Nov 2011 02:42:50 -0700
parents 8b571c137f81
children 25142dad240a
files assets/Models/anim2/simple-worm.blend org/body.org
diffstat 2 files changed, 36 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/anim2/simple-worm.blend has changed
     2.1 --- a/org/body.org	Tue Nov 15 23:18:37 2011 -0700
     2.2 +++ b/org/body.org	Wed Nov 16 02:42:50 2011 -0700
     2.3 @@ -291,45 +291,64 @@
     2.4     (.getFloatBuffer worm-mesh VertexBuffer$Type/Position)
     2.5       index))
     2.6  
     2.7 -(defn vec-pos [index]
     2.8 -  (let [offset (* index 3)]
     2.9 -    (Vector3f. (position offset)
    2.10 -               (position (inc offset))
    2.11 -               (position (inc(inc offset))))))
    2.12 -
    2.13  (defn bones [index]
    2.14    (.get
    2.15     (.getData  (.getBuffer mesh VertexBuffer$Type/BoneIndex))
    2.16     index))
    2.17  
    2.18 -(defn bone-control-color [index]
    2.19 -  (get {[1 0 0 0] ColorRGBA/Red
    2.20 -        [1 2 0 0] ColorRGBA/Magenta
    2.21 -        [2 0 0 0] ColorRGBA/Blue}
    2.22 -       (vec (map (comp int bones) (range (* index 4) (+ (* index 4) 4))))
    2.23 -       ColorRGBA/White))
    2.24 -
    2.25  (defn bone-weights [index]
    2.26    (.get
    2.27     (.getFloatBuffer mesh VertexBuffer$Type/BoneWeight)
    2.28     index))
    2.29  
    2.30 +
    2.31 +
    2.32 +(defn vertex-bones [vertex]
    2.33 +  (vec (map (comp int bones) (range (* vertex 4) (+ (* vertex 4) 4)))))
    2.34 +
    2.35 +(defn vertex-weights [vertex]
    2.36 +  (vec (map (comp float bone-weights) (range (* vertex 4) (+ (* vertex 4) 4)))))
    2.37 +
    2.38 +(defn vertex-position [index]
    2.39 +  (let [offset (* index 3)]
    2.40 +    (Vector3f. (position offset)
    2.41 +               (position (inc offset))
    2.42 +               (position (inc(inc offset))))))
    2.43 +
    2.44 +(def vertex-info (juxt vertex-position vertex-bones vertex-weights))
    2.45 +
    2.46 +(defn bone-control-color [index]
    2.47 +  (get {[1 0 0 0] ColorRGBA/Red
    2.48 +        [1 2 0 0] ColorRGBA/Magenta
    2.49 +        [2 0 0 0] ColorRGBA/Blue}
    2.50 +       (vertex-bones index)
    2.51 +       ColorRGBA/White))
    2.52 +
    2.53  (defn influence-color [index bone-num]
    2.54    (get
    2.55     {(float 0)   ColorRGBA/Blue
    2.56      (float 0.5) ColorRGBA/Green
    2.57      (float 1)   ColorRGBA/Red}
    2.58 -   (bone-weights (+ (* 4 index) bone-num))))
    2.59 +     ;; find the weight of the desired bone
    2.60 +   ((zipmap (vertex-bones index)(vertex-weights index))
    2.61 +    bone-num)
    2.62 +   ColorRGBA/Blue))
    2.63 +         
    2.64 +   
    2.65 +   
    2.66 +
    2.67 +(def worm-vertices (set (map vertex-info (range 60))))
    2.68 +
    2.69  
    2.70  (defn test-info []
    2.71    (let [points (Node.)]
    2.72      (dorun
    2.73       (map #(.attachChild points %)
    2.74            (map #(sphere 0.01
    2.75 -                        :position (vec-pos %)
    2.76 -                        :color (influence-color % 0)
    2.77 +                        :position (vertex-position %)
    2.78 +                        :color (influence-color % 1)
    2.79                          :physical? false)
    2.80 -               (range 12))))
    2.81 +               (range 60))))
    2.82      (view points)))
    2.83    
    2.84