changeset 119:ebfd62779ab4

color selection enabled
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Jan 2012 08:30:28 -0700
parents 1261444da2c7
children 83e638955e89
files assets/Models/creature1/try-again.blend org/test-creature.org
diffstat 2 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/creature1/try-again.blend has changed
     2.1 --- a/org/test-creature.org	Sat Jan 21 01:08:35 2012 -0700
     2.2 +++ b/org/test-creature.org	Sat Jan 21 08:30:28 2012 -0700
     2.3 @@ -83,11 +83,11 @@
     2.4            width (- (apply max xs) x0)
     2.5            height (- (apply max ys) y0)
     2.6            image (BufferedImage. (inc width) (inc height)
     2.7 -                                BufferedImage/TYPE_4BYTE_ABGR)]
     2.8 +                                BufferedImage/TYPE_INT_RGB)]
     2.9        (dorun
    2.10         (for [x (range (.getWidth image))
    2.11               y (range (.getHeight image))]
    2.12 -         (.setRGB image x y 0xFFFF0000)))
    2.13 +         (.setRGB image x y 0xFF0000)))
    2.14        (dorun 
    2.15         (for [index (range (count points))]
    2.16           (.setRGB image (- (xs index) x0) (- (ys index) y0) -1)))
    2.17 @@ -749,12 +749,21 @@
    2.18          cam (Camera. cam-width cam-height)]
    2.19      (.setLocation cam (.getWorldTranslation eye))
    2.20      (.setRotation cam (.getWorldRotation eye))
    2.21 +    (.setFrustumPerspective
    2.22 +     cam 45 (/ (.getWidth cam) (.getHeight cam))
    2.23 +     1 1000)
    2.24 +                                            
    2.25      (bind-camera target cam)
    2.26      cam))
    2.27  
    2.28  
    2.29  (def presets
    2.30 -  {:gray identity})
    2.31 +  {:all    0x000000
    2.32 +   :red    0xFF0000
    2.33 +   :blue   0x0000FF
    2.34 +   :green  0x00FF00})
    2.35 +
    2.36 +
    2.37  
    2.38  (defn enable-vision
    2.39    "return [init-function sensor-functions] for a particular eye"
    2.40 @@ -770,15 +779,20 @@
    2.41           (fn [r fb bb bi]
    2.42             (if (zero? (rem (swap! counter inc) (inc skip)))
    2.43               (reset! vision-image (BufferedImage! r fb bb bi)))))))
    2.44 -    (vector
    2.45 -     (let [whites (white-coordinates (:gray retinal-map))
    2.46 -           topology (vec (collapse whites))]
    2.47 -     (fn []
    2.48 -       (vector
    2.49 -        topology
    2.50 -        (vec 
    2.51 -         (for [[x y] whites]
    2.52 -           (.getRGB @vision-image x y)))))))
    2.53 +    (vec
    2.54 +     (map
    2.55 +      (fn [[key image]]
    2.56 +        (let [whites (white-coordinates image)
    2.57 +              topology (vec (collapse whites))
    2.58 +              mask (presets key)]
    2.59 +          (fn []
    2.60 +            (vector
    2.61 +             topology
    2.62 +             (vec 
    2.63 +              (for [[x y] whites]
    2.64 +                (bit-xor
    2.65 +                 mask (.getRGB @vision-image x y))))))))
    2.66 +        retinal-map))
    2.67      ]))
    2.68  
    2.69  (defn vision
    2.70 @@ -882,7 +896,7 @@
    2.71       ;;(com.aurellem.capture.Capture/captureVideo
    2.72       ;; world (file-str "/home/r/proj/ai-videos/hand"))
    2.73       ;;(.setTimer world (RatchetTimer. 60))
    2.74 -     ;;(speed-up world)
    2.75 +     (speed-up world)
    2.76       ;;(set-gravity world (Vector3f. 0 0 0))
    2.77       )
    2.78     (fn [world tpf]