changeset 93:7b739503836a

saving work
author Robert McIntyre <rlm@mit.edu>
date Mon, 09 Jan 2012 19:14:47 -0700
parents e70ec4bba96b
children 69174ed0f9f6
files assets/Models/creature1/tip.png assets/Models/creature1/try-again.blend org/test-creature.org
diffstat 3 files changed, 46 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/creature1/tip.png has changed
     2.1 Binary file assets/Models/creature1/try-again.blend has changed
     3.1 --- a/org/test-creature.org	Mon Jan 09 06:05:29 2012 -0700
     3.2 +++ b/org/test-creature.org	Mon Jan 09 19:14:47 2012 -0700
     3.3 @@ -295,7 +295,7 @@
     3.4       ;;(com.aurellem.capture.Capture/captureVideo
     3.5       ;; world (file-str "/home/r/proj/ai-videos/hand"))
     3.6       (.setTimer world (NanoTimer.))
     3.7 -     ;;(set-gravity world (Vector3f. 0 0 0))
     3.8 +     (set-gravity world (Vector3f. 0 0 0))
     3.9       (speed-up world)
    3.10       )
    3.11     no-op
    3.12 @@ -334,6 +334,12 @@
    3.13       (.get UV-buffer (* vertex-index 2))
    3.14       (.get UV-buffer (+ 1 (* vertex-index 2))))))
    3.15  
    3.16 +(defn tri-uv-coord
    3.17 +  "Get the uv-cooridnates of the triangle's verticies."
    3.18 +  [#^Mesh mesh #^Triangle triangle]
    3.19 +  (map (partial uv-coord mesh)
    3.20 +       (triangle-indices mesh (.getIndex triangle))))
    3.21 +
    3.22  (defn touch-receptor-image
    3.23    "Return the touch-sensor distribution image in ImagePlus format."
    3.24    [#^Geometry obj]
    3.25 @@ -416,12 +422,32 @@
    3.26      (same-side? vert-3 vert-1 vert-2 p)))
    3.27  
    3.28  
    3.29 -(defn white? [color]
    3.30 -  (and 
    3.31 -   (= (:r color) 255)
    3.32 -   (= (:b color) 255)
    3.33 -   (= (:g color) 255)))
    3.34 -                        
    3.35 +(defn analyze-triangle [#^Geometry obj #^Triangle tri]
    3.36 +  ;; first, calculate the transformation matrix that will take us
    3.37 +  ;; from uv-coordinates to the real world coordinates
    3.38 +  (let [mesh (.getMesh obj)
    3.39 +        world [(.get1 tri) (.get2 tri) (.get3 tri)]
    3.40 +        uv    (tri-uv-coord mesh tri)
    3.41 +
    3.42 +    
    3.43 +
    3.44 +    
    3.45 +   (println-repl world uv)))
    3.46 +  
    3.47 +  
    3.48 +  
    3.49 +
    3.50 +
    3.51 +(defn tactile-coords* 
    3.52 +  [#^Geometry obj]
    3.53 +  (let
    3.54 +      [tris (triangles obj)
    3.55 +       mesh (.getMesh obj)
    3.56 +       
    3.57 +    
    3.58 +  )
    3.59 +
    3.60 +
    3.61  
    3.62  ;; for each triangle in the mesh,
    3.63  ;; get the normal to the triangle,
    3.64 @@ -435,6 +461,7 @@
    3.65          uv-coord (partial uv-coord mesh)
    3.66          triangle-indices (partial triangle-indices mesh)
    3.67          receptors (touch-receptor-image obj)
    3.68 +        tris (triangles obj)
    3.69          ]
    3.70      (map
    3.71       (fn [[tri-1 tri-2 tri-3]]
    3.72 @@ -462,28 +489,19 @@
    3.73               ]
    3.74  
    3.75           (.setRoi receptors min-x min-y (- max-x min-x) (- max-y min-y))
    3.76 -         (let [processor  (.crop (.getProcessor receptors))
    3.77 -               image (frame (.getBufferedImage processor))]
    3.78 -           (with-meta
    3.79 -             (filter-keys
    3.80 -              (fn [[x y]]
    3.81 -                (inside-triangle?
    3.82 -                 (.subtract image-1 left-corner)
    3.83 -                 (.subtract image-2 left-corner)
    3.84 -                 (.subtract image-3 left-corner)
    3.85 -                 (Vector2f. x y)))
    3.86 -              
    3.87 -              
    3.88 -              (filter-vals white? image))
    3.89 -             {:image
    3.90 -              (comment
    3.91 -                (.getBufferedImage
    3.92 -                 (doto processor
    3.93 -                   (.flipVertical))))
    3.94 -               }
    3.95 -           ))
    3.96 +         (let [processor  (.crop (.getProcessor receptors))]
    3.97 +           (map
    3.98 +            #(.add left-corner %)
    3.99 +            
   3.100 +            (filter 
   3.101 +             (partial
   3.102 +              inside-triangle?
   3.103 +              (.subtract image-1 left-corner)
   3.104 +              (.subtract image-2 left-corner)
   3.105 +              (.subtract image-3 left-corner))
   3.106 +             (white-coordinates processor))))
   3.107           )) (map triangle-indices (range num-triangles)))))
   3.108 -    
   3.109 +
   3.110  
   3.111  
   3.112