changeset 104:ee302b65213b

removed outdated code
author Robert McIntyre <rlm@mit.edu>
date Sat, 14 Jan 2012 23:05:52 -0700
parents 85ee8bb80edf
children 3334bf15854b
files org/test-creature.org
diffstat 1 files changed, 4 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Sat Jan 14 21:15:44 2012 -0700
     1.2 +++ b/org/test-creature.org	Sat Jan 14 23:05:52 2012 -0700
     1.3 @@ -6,7 +6,6 @@
     1.4  #+SETUPFILE: ../../aurellem/org/setup.org
     1.5  #+INCLUDE: ../../aurellem/org/level-0.org
     1.6  
     1.7 -
     1.8  * objectives
     1.9   - [X] get an overall bitmap-like image for touch
    1.10   - [X] write code to visuliaze this bitmap
    1.11 @@ -34,13 +33,13 @@
    1.12  disceritise the visual input.
    1.13  
    1.14  I also want to be able to visualize both the sensors and the
    1.15 -effectors in pretty pictures. This semi-retarted creature will by my
    1.16 +effectors in pretty pictures. This semi-retarted creature will be my
    1.17  first attempt at bringing everything together.
    1.18  
    1.19  * The creature's body
    1.20  
    1.21  Still going to do an eve-like body in blender, but due to problems
    1.22 -importing the joints, etc into jMonkeyEngine3, I',m going to do all
    1.23 +importing the joints, etc into jMonkeyEngine3, I'm going to do all
    1.24  the connecting here in clojure code, using the names of the individual
    1.25  components and trial and error. Later, I'll maybe make some sort of
    1.26  creature-building modifications to blender that support whatever
    1.27 @@ -165,20 +164,13 @@
    1.28                               (map first row))
    1.29                  (map second row)))
    1.30           (partition-by second (sort-by second flattened))))
    1.31 -       ;;vi (view-image)
    1.32         relocate
    1.33         (let [min-x (apply min (map first squeezed))
    1.34               min-y (apply min (map second squeezed))]
    1.35           (map (fn [[x y]]
    1.36                  [(- x min-x)
    1.37                   (- y min-y)])
    1.38 -              squeezed))
    1.39 -       ]
    1.40 -    ;;(vi (points->image points))
    1.41 -    ;;(Thread/sleep 1000)
    1.42 -    ;;(vi (points->image flattened))
    1.43 -    ;;(Thread/sleep 1000)
    1.44 -    ;;(vi (points->image squeezed))
    1.45 +              squeezed))]
    1.46      relocate
    1.47     ))
    1.48  
    1.49 @@ -905,104 +897,10 @@
    1.50                                (Vector3f. 1 0 0))))))))
    1.51  
    1.52  
    1.53 -(defn locate-feelers*
    1.54 -  "Search the geometry's tactile UV image for touch sensors, returning
    1.55 -  their positions in geometry-relative coordinates."
    1.56 -  [#^Geometry geo]
    1.57 -  (let [uv-image (touch-receptor-image geo)
    1.58 -        width (.getWidth uv-image)
    1.59 -        height (.getHeight uv-image)
    1.60 -
    1.61 -        mesh (.getMesh geo)
    1.62 -        mesh-tris (triangles geo)
    1.63 -
    1.64 -        ;; for each triangle
    1.65 -        sensor-coords
    1.66 -        (fn [tri]
    1.67 -          ;; translate triangle to uv-pixel-space
    1.68 -          (let [uv-tri
    1.69 -                (rasterize mesh tri width height)
    1.70 -                bounds (vec (triangle-bounds uv-tri))]
    1.71 -            
    1.72 -            ;; get that part of the picture
    1.73 -            
    1.74 -            (apply (partial (memfn setRoi) uv-image) bounds)
    1.75 -            (let [cutout (.crop (.getProcessor uv-image))
    1.76 -                  ;; extract white pixels inside triangle
    1.77 -                  cutout-tri
    1.78 -                  (map-triangle
    1.79 -                   (fn [_ v]
    1.80 -                     (.subtract
    1.81 -                      v
    1.82 -                      (Vector3f. (bounds 0) (bounds 1) (float 0))))
    1.83 -                   uv-tri)
    1.84 -                  whites (filter (partial inside-triangle? cutout-tri)
    1.85 -                                 (map vector2f->vector3f
    1.86 -                                      (white-coordinates cutout)))
    1.87 -                  ;; translate pixel coordinates to world-space
    1.88 -                  transform (triangle-transformation cutout-tri tri)]
    1.89 -              (map #(.mult transform %) whites))))]
    1.90 -     
    1.91 -    (for [mesh-tri mesh-tris]
    1.92 -     
    1.93 -      (let [uv-tri (rasterize mesh mesh-tri width height)
    1.94 -            bounding-box (vec (triangle-bounds uv-tri))]
    1.95 -        (apply (partial (memfn setRoi) uv-image) bounding-box)
    1.96 -        ))   
    1.97 -    (vec (map sensor-coords mesh-tris))))
    1.98 -
    1.99 -
   1.100 -(defn tactile-coords [#^Geometry obj]
   1.101 -  (let [mesh (.getMesh obj)
   1.102 -        num-triangles (.getTriangleCount mesh)
   1.103 -        num-verticies (.getVertexCount mesh)
   1.104 -        uv-coord (partial uv-coord mesh)
   1.105 -        triangle-indices (partial triangle-indices mesh)
   1.106 -        receptors (touch-receptor-image obj)
   1.107 -        tris (triangles obj)
   1.108 -        ]
   1.109 -    (map
   1.110 -     (fn [[tri-1 tri-2 tri-3]]
   1.111 -       (let [width (.getWidth receptors)
   1.112 -             height (.getHeight receptors)
   1.113 -             uv-1 (uv-coord tri-1)
   1.114 -             uv-2 (uv-coord tri-2)
   1.115 -             uv-3 (uv-coord tri-3)
   1.116 -             x-coords (map #(.getX %) [uv-1 uv-2 uv-3])
   1.117 -             y-coords (map #(.getY %) [uv-1 uv-2 uv-3])
   1.118 -             max-x (Math/ceil (* width (apply max x-coords)))
   1.119 -             min-x (Math/floor (* width (apply min x-coords)))
   1.120 -             max-y (Math/ceil (* height (apply max y-coords)))
   1.121 -             min-y (Math/floor (* height (apply min y-coords)))
   1.122 -
   1.123 -             image-1 (Vector2f. (* width (.getX uv-1))
   1.124 -                                (* height (.getY uv-1)))
   1.125 -             image-2 (Vector2f. (* width (.getX uv-2))
   1.126 -                                (* height (.getY uv-2)))
   1.127 -             image-3 (Vector2f. (* width (.getX uv-3))
   1.128 -                                (* height (.getY uv-3)))
   1.129 -             left-corner
   1.130 -             (Vector2f. min-x min-y)
   1.131 -             ]
   1.132 -
   1.133 -         (.setRoi receptors min-x min-y (- max-x min-x) (- max-y min-y))
   1.134 -         (let [processor  (.crop (.getProcessor receptors))]
   1.135 -           (map
   1.136 -            #(.add left-corner %)
   1.137 -            
   1.138 -            (filter 
   1.139 -             (partial
   1.140 -              inside-triangle?
   1.141 -              (.subtract image-1 left-corner)
   1.142 -              (.subtract image-2 left-corner)
   1.143 -              (.subtract image-3 left-corner))
   1.144 -             (white-coordinates processor))))
   1.145 -         )) (map triangle-indices (range num-triangles)))))
   1.146 -
   1.147  #+end_src
   1.148  
   1.149  #+results: body-1
   1.150 -: #'cortex.silly/test-joint
   1.151 +: #'cortex.silly/tactile-coords
   1.152  
   1.153  
   1.154  * COMMENT purgatory