comparison org/skin.org @ 12:22c6878a1bc0

going to great debug view of new raycasting touch
author Robert McIntyre <rlm@mit.edu>
date Sun, 23 Oct 2011 11:03:52 -0700
parents a149692d3d1f
children 0eb2eac53361
comparison
equal deleted inserted replaced
11:a149692d3d1f 12:22c6878a1bc0
105 (map 105 (map
106 (fn [tri] 106 (fn [tri]
107 (doto 107 (doto
108 (Ray. (get-ray-origin geom tri) 108 (Ray. (get-ray-origin geom tri)
109 (get-ray-direction geom tri)) 109 (get-ray-direction geom tri))
110 110 (.setLimit limit)))
111 (.setLimit limit)
112 )
113 )
114 (triangles geom)))) 111 (triangles geom))))
115 112
116 113
117 (defn collision-debug [node result] 114 (defn collision-debug [node result]
118 (println-repl "contact point: " (.getContactPoint result)) 115 (println-repl "contact point: " (.getContactPoint result))
119 ) 116 )
120 117
118 (def init-node
119 (fn [debug-node rays]
120 (.detachAllChildren debug-node)
121 (for [ray rays]
122 (.attachChild debug-node (ray-debug ray ColorRGBA/Gray))
123 (.attachChild debug-node (ray-origin-debug ray ColorRGBA/Gray))
124
125
126
127 (defn manage-ray-debug-node [debug-node ray color]
128
129
130
131 )
132
133
134
121 (defn touch-percieve [limit geom node debug-node] 135 (defn touch-percieve [limit geom node debug-node]
122 (let [normals (normal-rays limit geom)] 136 (let [normals (normal-rays limit geom)]
123 (.detachAllChildren debug-node) 137
124 (doall 138 (doall
125 (for [ray normals] 139 (for [ray normals]
126 (do 140 (do
127 (let [results (CollisionResults.)] 141 (let [results (CollisionResults.)]
128 (.collideWith node ray results) 142 (.collideWith node ray results)
129 (let [answer (count (filter #(not (= geom (.getGeometry %))) results)) 143 (let [answer (count (filter #(not (= geom (.getGeometry %))) results))
130 ;;color (contact-color answer) 144 ;;color (contact-color answer)
131 ] 145 ]
132 ;;(dorun (map #(println-repl (.getName (.getGeometry %))) results)) 146 ;;(dorun (map #(println-repl (.getName (.getGeometry %))) results))
133 ;;(.attachChild debug-node (ray-debug ray color)) 147
134 ;;(.attachChild debug-node (ray-origin-debug ray color))
135
136 148
137 ;;(println-repl (.size results) "results for " ray) 149 ;;(println-repl (.size results) "results for " ray)
138 ;;(doall (map (partial collision-debug node) results)) 150 ;;(doall (map (partial collision-debug node) results))
139 answer 151 answer
140 ))))))) 152 )))))))
208 f (transparent-floor) 220 f (transparent-floor)
209 ;;controls 221 ;;controls
210 ;;(make-touch-sphere b) 222 ;;(make-touch-sphere b)
211 ;;(make-touch b) 223 ;;(make-touch b)
212 debug-node (Node.) 224 debug-node (Node.)
213 node (doto (Node.) (.attachChild b) (.attachChild f) 225 node (doto (Node.) (.attachChild b) (.attachChild f))
214 (.attachChild debug-node))] 226 root-node (doto (Node.) (.attachChild node)
227 (.attachChild debug-node))
228 ]
215 229
216 (world 230 (world
217 node 231 root-node
218 {"key-return" (fire-cannon-ball)} 232 {"key-return" (fire-cannon-ball)}
219 ;;no-op 233 ;;no-op
220 (fn [world] 234 (fn [world]
221 ;; (Capture/SimpleCaptureVideo 235 ;; (Capture/SimpleCaptureVideo
222 ;; world 236 ;; world