diff org/test-creature.org @ 119:ebfd62779ab4

color selection enabled
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Jan 2012 08:30:28 -0700
parents 1261444da2c7
children 83e638955e89
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Sat Jan 21 01:08:35 2012 -0700
     1.2 +++ b/org/test-creature.org	Sat Jan 21 08:30:28 2012 -0700
     1.3 @@ -83,11 +83,11 @@
     1.4            width (- (apply max xs) x0)
     1.5            height (- (apply max ys) y0)
     1.6            image (BufferedImage. (inc width) (inc height)
     1.7 -                                BufferedImage/TYPE_4BYTE_ABGR)]
     1.8 +                                BufferedImage/TYPE_INT_RGB)]
     1.9        (dorun
    1.10         (for [x (range (.getWidth image))
    1.11               y (range (.getHeight image))]
    1.12 -         (.setRGB image x y 0xFFFF0000)))
    1.13 +         (.setRGB image x y 0xFF0000)))
    1.14        (dorun 
    1.15         (for [index (range (count points))]
    1.16           (.setRGB image (- (xs index) x0) (- (ys index) y0) -1)))
    1.17 @@ -749,12 +749,21 @@
    1.18          cam (Camera. cam-width cam-height)]
    1.19      (.setLocation cam (.getWorldTranslation eye))
    1.20      (.setRotation cam (.getWorldRotation eye))
    1.21 +    (.setFrustumPerspective
    1.22 +     cam 45 (/ (.getWidth cam) (.getHeight cam))
    1.23 +     1 1000)
    1.24 +                                            
    1.25      (bind-camera target cam)
    1.26      cam))
    1.27  
    1.28  
    1.29  (def presets
    1.30 -  {:gray identity})
    1.31 +  {:all    0x000000
    1.32 +   :red    0xFF0000
    1.33 +   :blue   0x0000FF
    1.34 +   :green  0x00FF00})
    1.35 +
    1.36 +
    1.37  
    1.38  (defn enable-vision
    1.39    "return [init-function sensor-functions] for a particular eye"
    1.40 @@ -770,15 +779,20 @@
    1.41           (fn [r fb bb bi]
    1.42             (if (zero? (rem (swap! counter inc) (inc skip)))
    1.43               (reset! vision-image (BufferedImage! r fb bb bi)))))))
    1.44 -    (vector
    1.45 -     (let [whites (white-coordinates (:gray retinal-map))
    1.46 -           topology (vec (collapse whites))]
    1.47 -     (fn []
    1.48 -       (vector
    1.49 -        topology
    1.50 -        (vec 
    1.51 -         (for [[x y] whites]
    1.52 -           (.getRGB @vision-image x y)))))))
    1.53 +    (vec
    1.54 +     (map
    1.55 +      (fn [[key image]]
    1.56 +        (let [whites (white-coordinates image)
    1.57 +              topology (vec (collapse whites))
    1.58 +              mask (presets key)]
    1.59 +          (fn []
    1.60 +            (vector
    1.61 +             topology
    1.62 +             (vec 
    1.63 +              (for [[x y] whites]
    1.64 +                (bit-xor
    1.65 +                 mask (.getRGB @vision-image x y))))))))
    1.66 +        retinal-map))
    1.67      ]))
    1.68  
    1.69  (defn vision
    1.70 @@ -882,7 +896,7 @@
    1.71       ;;(com.aurellem.capture.Capture/captureVideo
    1.72       ;; world (file-str "/home/r/proj/ai-videos/hand"))
    1.73       ;;(.setTimer world (RatchetTimer. 60))
    1.74 -     ;;(speed-up world)
    1.75 +     (speed-up world)
    1.76       ;;(set-gravity world (Vector3f. 0 0 0))
    1.77       )
    1.78     (fn [world tpf]