Mercurial > cortex
comparison org/skin.org @ 9:7d0c0282c3a7
got positioning right, but there is still a problem
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 23 Oct 2011 01:27:20 -0700 |
parents | 522cf85fdb57 |
children | 0251b7e7609f |
comparison
equal
deleted
inserted
replaced
8:522cf85fdb57 | 9:7d0c0282c3a7 |
---|---|
106 (.localToWorld geom (.getCenter tri) new) | 106 (.localToWorld geom (.getCenter tri) new) |
107 new)) | 107 new)) |
108 | 108 |
109 (defn get-ray-direction | 109 (defn get-ray-direction |
110 [geom tri] | 110 [geom tri] |
111 (let [new (Vector3f.)] | 111 (let [n+c (Vector3f.)] |
112 (.calculateNormal tri) | 112 (.calculateNormal tri) |
113 | 113 (.calculateCenter tri) |
114 (.localToWorld geom (.getNormal tri) new) | 114 (.localToWorld geom (.add (.getCenter tri) (.getNormal tri)) n+c) |
115 (.subtract new (get-ray-origin geom tri)) | 115 (.subtract n+c (get-ray-origin geom tri)) |
116 | |
117 ;;Vector3f/UNIT_Y | |
118 )) | 116 )) |
119 | 117 |
120 (defn ray-origin-debug | 118 (defn ray-origin-debug |
121 [ray] | 119 [ray color] |
122 (make-shape | 120 (make-shape |
123 (assoc base-shape | 121 (assoc base-shape |
124 :shape (Sphere. 5 5 0.05) | 122 :shape (Sphere. 5 5 0.05) |
125 :name "arrow" | 123 :name "arrow" |
126 :color ColorRGBA/Orange | 124 :color color |
127 :texture false | 125 :texture false |
128 :physical? false | 126 :physical? false |
129 :position | 127 :position |
130 (.getOrigin ray)))) | 128 (.getOrigin ray)))) |
131 | 129 |
132 (defn ray-debug [ray] | 130 (defn ray-debug [ray color] |
133 (make-shape | 131 (make-shape |
134 (assoc | 132 (assoc |
135 base-shape | 133 base-shape |
136 :name "debug-ray" | 134 :name "debug-ray" |
137 :physical? false | 135 :physical? false |
158 (.setLimit limit))) | 156 (.setLimit limit))) |
159 (triangles geom)))) | 157 (triangles geom)))) |
160 | 158 |
161 | 159 |
162 (defn collision-debug [node result] | 160 (defn collision-debug [node result] |
163 | |
164 (println-repl "contact point: " (.getContactPoint result)) | 161 (println-repl "contact point: " (.getContactPoint result)) |
165 | |
166 | |
167 ) | 162 ) |
168 | 163 |
169 (defn touch-percieve [limit geom node debug-node] | 164 (defn touch-percieve [limit geom node debug-node] |
170 (let [normals (normal-rays limit geom)] | 165 (let [normals (normal-rays limit geom)] |
171 (.detachAllChildren debug-node) | 166 (.detachAllChildren debug-node) |
172 | |
173 | |
174 (println-repl "---------") | |
175 (doall | 167 (doall |
176 (for [ray normals] | 168 (for [ray normals] |
177 (do | 169 (do |
178 (let [results (CollisionResults.)] | 170 (let [results (CollisionResults.)] |
179 (.attachChild debug-node (ray-debug ray)) | |
180 (.attachChild debug-node (ray-origin-debug ray)) | |
181 (.collideWith geom ray results) | 171 (.collideWith geom ray results) |
172 (let [color (contact-color (.size results))] | |
173 | |
174 (.attachChild debug-node (ray-debug ray color)) | |
175 (.attachChild debug-node (ray-origin-debug ray color)) | |
176 ) | |
182 | 177 |
183 ;;(println-repl (.size results) "results for " ray) | 178 (println-repl (.size results) "results for " ray) |
184 ;;(doall (map (partial collision-debug node) results)) | 179 (doall (map (partial collision-debug node) results)) |
185 (.size results) | 180 (.size results) |
186 )))))) | 181 )))))) |
187 | 182 |
188 (defn make-touch [#^Geometry geom] | 183 (defn make-touch [#^Geometry geom] |
189 (let [tri (Triangle.) | 184 (let [tri (Triangle.) |