changeset 13:0eb2eac53361

progress!!
author Robert McIntyre <rlm@mit.edu>
date Sun, 23 Oct 2011 11:22:06 -0700
parents 22c6878a1bc0
children 3aa1ee6c6308
files org/skin.org
diffstat 1 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/skin.org	Sun Oct 23 11:03:52 2011 -0700
     1.2 +++ b/org/skin.org	Sun Oct 23 11:22:06 2011 -0700
     1.3 @@ -115,24 +115,34 @@
     1.4    (println-repl "contact point: " (.getContactPoint result))
     1.5    )
     1.6  
     1.7 -(def init-node
     1.8 -  (fn [debug-node rays]
     1.9 +(defn update-ray-debug [node ray]
    1.10 +  (.setLocalTranslation (.getChild node 1) (.getOrigin ray)))
    1.11 +
    1.12 +
    1.13 +(defn init-node
    1.14 +  [debug-node rays]
    1.15 +    (println-repl "Init touch debug node.")
    1.16      (.detachAllChildren debug-node)
    1.17 -    (for [ray rays]
    1.18 -    (.attachChild debug-node (ray-debug ray ColorRGBA/Gray))
    1.19 -    (.attachChild debug-node (ray-origin-debug ray ColorRGBA/Gray))
    1.20 +    (dorun 
    1.21 +     (for [ray rays]
    1.22 +       (do
    1.23 +         (.attachChild
    1.24 +          debug-node 
    1.25 +          (doto (Node.)
    1.26 +            (.attachChild (ray-debug ray ColorRGBA/Gray))
    1.27 +            (.attachChild (ray-origin-debug ray ColorRGBA/Gray))))))))
    1.28  
    1.29 -    
    1.30  
    1.31 -(defn manage-ray-debug-node [debug-node ray color]
    1.32 -  
    1.33 +(defn manage-ray-debug-node [debug-node geom touch-data limit]
    1.34 +  (let [rays (normal-rays limit geom)]
    1.35 +    (if (not= (count (.getChildren debug-node)) (count touch-data))
    1.36 +      (init-node debug-node rays))
    1.37 +    (dorun 
    1.38 +     (for [n (range (count touch-data))]
    1.39 +       (update-ray-debug (.getChild debug-node n) (nth rays n))))))
    1.40  
    1.41  
    1.42 -  )
    1.43 -
    1.44 -
    1.45 -
    1.46 -(defn touch-percieve [limit geom node debug-node]
    1.47 +(defn touch-percieve [limit geom node]
    1.48    (let [normals  (normal-rays limit geom)]
    1.49  
    1.50      (doall
    1.51 @@ -241,9 +251,9 @@
    1.52       )
    1.53  
    1.54       (fn [& _]
    1.55 -       (println-repl
    1.56 -        (touch-percieve 0.2 b node debug-node)
    1.57 -        )
    1.58 +       (let [touch-data (touch-percieve 0.2 b node)]
    1.59 +         (println-repl touch-data)
    1.60 +         (manage-ray-debug-node debug-node b touch-data 0.2))
    1.61         (Thread/sleep 10)
    1.62         ;;(touch-print controls)
    1.63         ;;(color-touch controls)