Mercurial > cortex
comparison org/touch.org @ 430:5205535237fb
fix skew in self-organizing-touch, work on thesis.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 22 Mar 2014 16:10:34 -0400 |
parents | 4f5a5d5f1613 |
children | 763d13f77e03 |
comparison
equal
deleted
inserted
replaced
429:b5d0f0adf19f | 430:5205535237fb |
---|---|
76 * Implementation Summary | 76 * Implementation Summary |
77 | 77 |
78 To simulate touch there are three conceptual steps. For each solid | 78 To simulate touch there are three conceptual steps. For each solid |
79 object in the creature, you first have to get UV image and scale | 79 object in the creature, you first have to get UV image and scale |
80 parameter which define the position and length of the feelers. Then, | 80 parameter which define the position and length of the feelers. Then, |
81 you use the triangles which compose the mesh and the UV data stored in | 81 you use the triangles which comprise the mesh and the UV data stored in |
82 the mesh to determine the world-space position and orientation of each | 82 the mesh to determine the world-space position and orientation of each |
83 feeler. Then once every frame, update these positions and orientations | 83 feeler. Then once every frame, update these positions and orientations |
84 to match the current position and orientation of the object, and use | 84 to match the current position and orientation of the object, and use |
85 physics collision detection to gather tactile data. | 85 physics collision detection to gather tactile data. |
86 | 86 |
134 data involved with displaying the object. | 134 data involved with displaying the object. |
135 | 135 |
136 A =Mesh= is composed of =Triangles=, and each =Triangle= has three | 136 A =Mesh= is composed of =Triangles=, and each =Triangle= has three |
137 vertices which have coordinates in world space and UV space. | 137 vertices which have coordinates in world space and UV space. |
138 | 138 |
139 Here, =triangles= gets all the world-space triangles which compose a | 139 Here, =triangles= gets all the world-space triangles which comprise a |
140 mesh, while =pixel-triangles= gets those same triangles expressed in | 140 mesh, while =pixel-triangles= gets those same triangles expressed in |
141 pixel coordinates (which are UV coordinates scaled to fit the height | 141 pixel coordinates (which are UV coordinates scaled to fit the height |
142 and width of the UV image). | 142 and width of the UV image). |
143 | 143 |
144 #+name: triangles-2 | 144 #+name: triangles-2 |
150 (triangle-seq | 150 (triangle-seq |
151 (let [scratch (Triangle.)] | 151 (let [scratch (Triangle.)] |
152 (.getTriangle (.getMesh geo) triangle-index scratch) scratch))) | 152 (.getTriangle (.getMesh geo) triangle-index scratch) scratch))) |
153 | 153 |
154 (defn triangles | 154 (defn triangles |
155 "Return a sequence of all the Triangles which compose a given | 155 "Return a sequence of all the Triangles which comprise a given |
156 Geometry." | 156 Geometry." |
157 [#^Geometry geo] | 157 [#^Geometry geo] |
158 (map (partial triangle geo) (range (.getTriangleCount (.getMesh geo))))) | 158 (map (partial triangle geo) (range (.getTriangleCount (.getMesh geo))))) |
159 | 159 |
160 (defn triangle-vertex-indices | 160 (defn triangle-vertex-indices |
238 contain the vertices of the triangle; the last contains the unit | 238 contain the vertices of the triangle; the last contains the unit |
239 normal of the triangle. The bottom row is filled with 1s." | 239 normal of the triangle. The bottom row is filled with 1s." |
240 [#^Triangle t] | 240 [#^Triangle t] |
241 (let [mat (Matrix4f.) | 241 (let [mat (Matrix4f.) |
242 [vert-1 vert-2 vert-3] | 242 [vert-1 vert-2 vert-3] |
243 ((comp vec map) #(.get t %) (range 3)) | 243 (mapv #(.get t %) (range 3)) |
244 unit-normal (do (.calculateNormal t)(.getNormal t)) | 244 unit-normal (do (.calculateNormal t)(.getNormal t)) |
245 vertices [vert-1 vert-2 vert-3 unit-normal]] | 245 vertices [vert-1 vert-2 vert-3 unit-normal]] |
246 (dorun | 246 (dorun |
247 (for [row (range 4) col (range 3)] | 247 (for [row (range 4) col (range 3)] |
248 (do | 248 (do |