# HG changeset patch # User Robert McIntyre # Date 1321436570 25200 # Node ID 37a3256e1ed3999bcb7c0854de80c4a4705bd0be # Parent 8b571c137f81ff57236c28ffcacb8d3099027d79 problems resolved diff -r 8b571c137f81 -r 37a3256e1ed3 assets/Models/anim2/simple-worm.blend Binary file assets/Models/anim2/simple-worm.blend has changed diff -r 8b571c137f81 -r 37a3256e1ed3 org/body.org --- a/org/body.org Tue Nov 15 23:18:37 2011 -0700 +++ b/org/body.org Wed Nov 16 02:42:50 2011 -0700 @@ -291,45 +291,64 @@ (.getFloatBuffer worm-mesh VertexBuffer$Type/Position) index)) -(defn vec-pos [index] - (let [offset (* index 3)] - (Vector3f. (position offset) - (position (inc offset)) - (position (inc(inc offset)))))) - (defn bones [index] (.get (.getData (.getBuffer mesh VertexBuffer$Type/BoneIndex)) index)) -(defn bone-control-color [index] - (get {[1 0 0 0] ColorRGBA/Red - [1 2 0 0] ColorRGBA/Magenta - [2 0 0 0] ColorRGBA/Blue} - (vec (map (comp int bones) (range (* index 4) (+ (* index 4) 4)))) - ColorRGBA/White)) - (defn bone-weights [index] (.get (.getFloatBuffer mesh VertexBuffer$Type/BoneWeight) index)) + + +(defn vertex-bones [vertex] + (vec (map (comp int bones) (range (* vertex 4) (+ (* vertex 4) 4))))) + +(defn vertex-weights [vertex] + (vec (map (comp float bone-weights) (range (* vertex 4) (+ (* vertex 4) 4))))) + +(defn vertex-position [index] + (let [offset (* index 3)] + (Vector3f. (position offset) + (position (inc offset)) + (position (inc(inc offset)))))) + +(def vertex-info (juxt vertex-position vertex-bones vertex-weights)) + +(defn bone-control-color [index] + (get {[1 0 0 0] ColorRGBA/Red + [1 2 0 0] ColorRGBA/Magenta + [2 0 0 0] ColorRGBA/Blue} + (vertex-bones index) + ColorRGBA/White)) + (defn influence-color [index bone-num] (get {(float 0) ColorRGBA/Blue (float 0.5) ColorRGBA/Green (float 1) ColorRGBA/Red} - (bone-weights (+ (* 4 index) bone-num)))) + ;; find the weight of the desired bone + ((zipmap (vertex-bones index)(vertex-weights index)) + bone-num) + ColorRGBA/Blue)) + + + + +(def worm-vertices (set (map vertex-info (range 60)))) + (defn test-info [] (let [points (Node.)] (dorun (map #(.attachChild points %) (map #(sphere 0.01 - :position (vec-pos %) - :color (influence-color % 0) + :position (vertex-position %) + :color (influence-color % 1) :physical? false) - (range 12)))) + (range 60)))) (view points)))