comparison org/skin.org @ 13:0eb2eac53361

progress!!
author Robert McIntyre <rlm@mit.edu>
date Sun, 23 Oct 2011 11:22:06 -0700
parents 22c6878a1bc0
children 3aa1ee6c6308
comparison
equal deleted inserted replaced
12:22c6878a1bc0 13:0eb2eac53361
113 113
114 (defn collision-debug [node result] 114 (defn collision-debug [node result]
115 (println-repl "contact point: " (.getContactPoint result)) 115 (println-repl "contact point: " (.getContactPoint result))
116 ) 116 )
117 117
118 (def init-node 118 (defn update-ray-debug [node ray]
119 (fn [debug-node rays] 119 (.setLocalTranslation (.getChild node 1) (.getOrigin ray)))
120
121
122 (defn init-node
123 [debug-node rays]
124 (println-repl "Init touch debug node.")
120 (.detachAllChildren debug-node) 125 (.detachAllChildren debug-node)
121 (for [ray rays] 126 (dorun
122 (.attachChild debug-node (ray-debug ray ColorRGBA/Gray)) 127 (for [ray rays]
123 (.attachChild debug-node (ray-origin-debug ray ColorRGBA/Gray)) 128 (do
124 129 (.attachChild
125 130 debug-node
126 131 (doto (Node.)
127 (defn manage-ray-debug-node [debug-node ray color] 132 (.attachChild (ray-debug ray ColorRGBA/Gray))
128 133 (.attachChild (ray-origin-debug ray ColorRGBA/Gray))))))))
129 134
130 135
131 ) 136 (defn manage-ray-debug-node [debug-node geom touch-data limit]
132 137 (let [rays (normal-rays limit geom)]
133 138 (if (not= (count (.getChildren debug-node)) (count touch-data))
134 139 (init-node debug-node rays))
135 (defn touch-percieve [limit geom node debug-node] 140 (dorun
141 (for [n (range (count touch-data))]
142 (update-ray-debug (.getChild debug-node n) (nth rays n))))))
143
144
145 (defn touch-percieve [limit geom node]
136 (let [normals (normal-rays limit geom)] 146 (let [normals (normal-rays limit geom)]
137 147
138 (doall 148 (doall
139 (for [ray normals] 149 (for [ray normals]
140 (do 150 (do
239 (enable-debug world) 249 (enable-debug world)
240 ;; (set-accuracy world (/ 1 60)) 250 ;; (set-accuracy world (/ 1 60))
241 ) 251 )
242 252
243 (fn [& _] 253 (fn [& _]
244 (println-repl 254 (let [touch-data (touch-percieve 0.2 b node)]
245 (touch-percieve 0.2 b node debug-node) 255 (println-repl touch-data)
246 ) 256 (manage-ray-debug-node debug-node b touch-data 0.2))
247 (Thread/sleep 10) 257 (Thread/sleep 10)
248 ;;(touch-print controls) 258 ;;(touch-print controls)
249 ;;(color-touch controls) 259 ;;(color-touch controls)
250 )))) 260 ))))
251 261