# HG changeset patch # User Robert McIntyre # Date 1326607552 25200 # Node ID ee302b65213be25b2adbe39bdbfac5dec3a3a8c8 # Parent 85ee8bb80edf1a6b4a3783e6dd5e299bb36dc45c removed outdated code diff -r 85ee8bb80edf -r ee302b65213b org/test-creature.org --- a/org/test-creature.org Sat Jan 14 21:15:44 2012 -0700 +++ b/org/test-creature.org Sat Jan 14 23:05:52 2012 -0700 @@ -6,7 +6,6 @@ #+SETUPFILE: ../../aurellem/org/setup.org #+INCLUDE: ../../aurellem/org/level-0.org - * objectives - [X] get an overall bitmap-like image for touch - [X] write code to visuliaze this bitmap @@ -34,13 +33,13 @@ disceritise the visual input. I also want to be able to visualize both the sensors and the -effectors in pretty pictures. This semi-retarted creature will by my +effectors in pretty pictures. This semi-retarted creature will be my first attempt at bringing everything together. * The creature's body Still going to do an eve-like body in blender, but due to problems -importing the joints, etc into jMonkeyEngine3, I',m going to do all +importing the joints, etc into jMonkeyEngine3, I'm going to do all the connecting here in clojure code, using the names of the individual components and trial and error. Later, I'll maybe make some sort of creature-building modifications to blender that support whatever @@ -165,20 +164,13 @@ (map first row)) (map second row))) (partition-by second (sort-by second flattened)))) - ;;vi (view-image) relocate (let [min-x (apply min (map first squeezed)) min-y (apply min (map second squeezed))] (map (fn [[x y]] [(- x min-x) (- y min-y)]) - squeezed)) - ] - ;;(vi (points->image points)) - ;;(Thread/sleep 1000) - ;;(vi (points->image flattened)) - ;;(Thread/sleep 1000) - ;;(vi (points->image squeezed)) + squeezed))] relocate )) @@ -905,104 +897,10 @@ (Vector3f. 1 0 0)))))))) -(defn locate-feelers* - "Search the geometry's tactile UV image for touch sensors, returning - their positions in geometry-relative coordinates." - [#^Geometry geo] - (let [uv-image (touch-receptor-image geo) - width (.getWidth uv-image) - height (.getHeight uv-image) - - mesh (.getMesh geo) - mesh-tris (triangles geo) - - ;; for each triangle - sensor-coords - (fn [tri] - ;; translate triangle to uv-pixel-space - (let [uv-tri - (rasterize mesh tri width height) - bounds (vec (triangle-bounds uv-tri))] - - ;; get that part of the picture - - (apply (partial (memfn setRoi) uv-image) bounds) - (let [cutout (.crop (.getProcessor uv-image)) - ;; extract white pixels inside triangle - cutout-tri - (map-triangle - (fn [_ v] - (.subtract - v - (Vector3f. (bounds 0) (bounds 1) (float 0)))) - uv-tri) - whites (filter (partial inside-triangle? cutout-tri) - (map vector2f->vector3f - (white-coordinates cutout))) - ;; translate pixel coordinates to world-space - transform (triangle-transformation cutout-tri tri)] - (map #(.mult transform %) whites))))] - - (for [mesh-tri mesh-tris] - - (let [uv-tri (rasterize mesh mesh-tri width height) - bounding-box (vec (triangle-bounds uv-tri))] - (apply (partial (memfn setRoi) uv-image) bounding-box) - )) - (vec (map sensor-coords mesh-tris)))) - - -(defn tactile-coords [#^Geometry obj] - (let [mesh (.getMesh obj) - num-triangles (.getTriangleCount mesh) - num-verticies (.getVertexCount mesh) - 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]] - (let [width (.getWidth receptors) - height (.getHeight receptors) - uv-1 (uv-coord tri-1) - uv-2 (uv-coord tri-2) - uv-3 (uv-coord tri-3) - x-coords (map #(.getX %) [uv-1 uv-2 uv-3]) - y-coords (map #(.getY %) [uv-1 uv-2 uv-3]) - max-x (Math/ceil (* width (apply max x-coords))) - min-x (Math/floor (* width (apply min x-coords))) - max-y (Math/ceil (* height (apply max y-coords))) - min-y (Math/floor (* height (apply min y-coords))) - - image-1 (Vector2f. (* width (.getX uv-1)) - (* height (.getY uv-1))) - image-2 (Vector2f. (* width (.getX uv-2)) - (* height (.getY uv-2))) - image-3 (Vector2f. (* width (.getX uv-3)) - (* height (.getY uv-3))) - left-corner - (Vector2f. min-x min-y) - ] - - (.setRoi receptors min-x min-y (- max-x min-x) (- max-y min-y)) - (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))))) - #+end_src #+results: body-1 -: #'cortex.silly/test-joint +: #'cortex.silly/tactile-coords * COMMENT purgatory