diff org/body.org @ 57:37a3256e1ed3

problems resolved
author Robert McIntyre <rlm@mit.edu>
date Wed, 16 Nov 2011 02:42:50 -0700
parents 8b571c137f81
children 25142dad240a
line wrap: on
line diff
     1.1 --- a/org/body.org	Tue Nov 15 23:18:37 2011 -0700
     1.2 +++ b/org/body.org	Wed Nov 16 02:42:50 2011 -0700
     1.3 @@ -291,45 +291,64 @@
     1.4     (.getFloatBuffer worm-mesh VertexBuffer$Type/Position)
     1.5       index))
     1.6  
     1.7 -(defn vec-pos [index]
     1.8 -  (let [offset (* index 3)]
     1.9 -    (Vector3f. (position offset)
    1.10 -               (position (inc offset))
    1.11 -               (position (inc(inc offset))))))
    1.12 -
    1.13  (defn bones [index]
    1.14    (.get
    1.15     (.getData  (.getBuffer mesh VertexBuffer$Type/BoneIndex))
    1.16     index))
    1.17  
    1.18 -(defn bone-control-color [index]
    1.19 -  (get {[1 0 0 0] ColorRGBA/Red
    1.20 -        [1 2 0 0] ColorRGBA/Magenta
    1.21 -        [2 0 0 0] ColorRGBA/Blue}
    1.22 -       (vec (map (comp int bones) (range (* index 4) (+ (* index 4) 4))))
    1.23 -       ColorRGBA/White))
    1.24 -
    1.25  (defn bone-weights [index]
    1.26    (.get
    1.27     (.getFloatBuffer mesh VertexBuffer$Type/BoneWeight)
    1.28     index))
    1.29  
    1.30 +
    1.31 +
    1.32 +(defn vertex-bones [vertex]
    1.33 +  (vec (map (comp int bones) (range (* vertex 4) (+ (* vertex 4) 4)))))
    1.34 +
    1.35 +(defn vertex-weights [vertex]
    1.36 +  (vec (map (comp float bone-weights) (range (* vertex 4) (+ (* vertex 4) 4)))))
    1.37 +
    1.38 +(defn vertex-position [index]
    1.39 +  (let [offset (* index 3)]
    1.40 +    (Vector3f. (position offset)
    1.41 +               (position (inc offset))
    1.42 +               (position (inc(inc offset))))))
    1.43 +
    1.44 +(def vertex-info (juxt vertex-position vertex-bones vertex-weights))
    1.45 +
    1.46 +(defn bone-control-color [index]
    1.47 +  (get {[1 0 0 0] ColorRGBA/Red
    1.48 +        [1 2 0 0] ColorRGBA/Magenta
    1.49 +        [2 0 0 0] ColorRGBA/Blue}
    1.50 +       (vertex-bones index)
    1.51 +       ColorRGBA/White))
    1.52 +
    1.53  (defn influence-color [index bone-num]
    1.54    (get
    1.55     {(float 0)   ColorRGBA/Blue
    1.56      (float 0.5) ColorRGBA/Green
    1.57      (float 1)   ColorRGBA/Red}
    1.58 -   (bone-weights (+ (* 4 index) bone-num))))
    1.59 +     ;; find the weight of the desired bone
    1.60 +   ((zipmap (vertex-bones index)(vertex-weights index))
    1.61 +    bone-num)
    1.62 +   ColorRGBA/Blue))
    1.63 +         
    1.64 +   
    1.65 +   
    1.66 +
    1.67 +(def worm-vertices (set (map vertex-info (range 60))))
    1.68 +
    1.69  
    1.70  (defn test-info []
    1.71    (let [points (Node.)]
    1.72      (dorun
    1.73       (map #(.attachChild points %)
    1.74            (map #(sphere 0.01
    1.75 -                        :position (vec-pos %)
    1.76 -                        :color (influence-color % 0)
    1.77 +                        :position (vertex-position %)
    1.78 +                        :color (influence-color % 1)
    1.79                          :physical? false)
    1.80 -               (range 12))))
    1.81 +               (range 60))))
    1.82      (view points)))
    1.83    
    1.84