# HG changeset patch # User Robert McIntyre # Date 1326161687 25200 # Node ID 7b739503836a5978e5dae3f8047bf4f22e12ce00 # Parent e70ec4bba96b073b75aa2b76406f1cafa3abc36b saving work diff -r e70ec4bba96b -r 7b739503836a assets/Models/creature1/tip.png Binary file assets/Models/creature1/tip.png has changed diff -r e70ec4bba96b -r 7b739503836a assets/Models/creature1/try-again.blend Binary file assets/Models/creature1/try-again.blend has changed diff -r e70ec4bba96b -r 7b739503836a org/test-creature.org --- a/org/test-creature.org Mon Jan 09 06:05:29 2012 -0700 +++ b/org/test-creature.org Mon Jan 09 19:14:47 2012 -0700 @@ -295,7 +295,7 @@ ;;(com.aurellem.capture.Capture/captureVideo ;; world (file-str "/home/r/proj/ai-videos/hand")) (.setTimer world (NanoTimer.)) - ;;(set-gravity world (Vector3f. 0 0 0)) + (set-gravity world (Vector3f. 0 0 0)) (speed-up world) ) no-op @@ -334,6 +334,12 @@ (.get UV-buffer (* vertex-index 2)) (.get UV-buffer (+ 1 (* vertex-index 2)))))) +(defn tri-uv-coord + "Get the uv-cooridnates of the triangle's verticies." + [#^Mesh mesh #^Triangle triangle] + (map (partial uv-coord mesh) + (triangle-indices mesh (.getIndex triangle)))) + (defn touch-receptor-image "Return the touch-sensor distribution image in ImagePlus format." [#^Geometry obj] @@ -416,12 +422,32 @@ (same-side? vert-3 vert-1 vert-2 p))) -(defn white? [color] - (and - (= (:r color) 255) - (= (:b color) 255) - (= (:g color) 255))) - +(defn analyze-triangle [#^Geometry obj #^Triangle tri] + ;; first, calculate the transformation matrix that will take us + ;; from uv-coordinates to the real world coordinates + (let [mesh (.getMesh obj) + world [(.get1 tri) (.get2 tri) (.get3 tri)] + uv (tri-uv-coord mesh tri) + + + + + (println-repl world uv))) + + + + + +(defn tactile-coords* + [#^Geometry obj] + (let + [tris (triangles obj) + mesh (.getMesh obj) + + + ) + + ;; for each triangle in the mesh, ;; get the normal to the triangle, @@ -435,6 +461,7 @@ uv-coord (partial uv-coord mesh) triangle-indices (partial triangle-indices mesh) receptors (touch-receptor-image obj) + tris (triangles obj) ] (map (fn [[tri-1 tri-2 tri-3]] @@ -462,28 +489,19 @@ ] (.setRoi receptors min-x min-y (- max-x min-x) (- max-y min-y)) - (let [processor (.crop (.getProcessor receptors)) - image (frame (.getBufferedImage processor))] - (with-meta - (filter-keys - (fn [[x y]] - (inside-triangle? - (.subtract image-1 left-corner) - (.subtract image-2 left-corner) - (.subtract image-3 left-corner) - (Vector2f. x y))) - - - (filter-vals white? image)) - {:image - (comment - (.getBufferedImage - (doto processor - (.flipVertical)))) - } - )) + (let [processor (.crop (.getProcessor receptors))] + (map + #(.add left-corner %) + + (filter + (partial + inside-triangle? + (.subtract image-1 left-corner) + (.subtract image-2 left-corner) + (.subtract image-3 left-corner)) + (white-coordinates processor)))) )) (map triangle-indices (range num-triangles))))) - +