diff org/test-creature.org @ 121:05e60a0ed043

preliminary eyes are fully implemented
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Jan 2012 09:55:59 -0700
parents 83e638955e89
children b591da250afc
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Sat Jan 21 09:30:47 2012 -0700
     1.2 +++ b/org/test-creature.org	Sat Jan 21 09:55:59 2012 -0700
     1.3 @@ -757,7 +757,7 @@
     1.4  
     1.5  
     1.6  (def presets
     1.7 -  {:all    0x000000
     1.8 +  {:all    0xFFFFFF
     1.9     :red    0xFF0000
    1.10     :blue   0x0000FF
    1.11     :green  0x00FF00})
    1.12 @@ -795,21 +795,17 @@
    1.13      ]))
    1.14  
    1.15  (defn vision
    1.16 +  [#^Node creature & {skip :skip :or {skip 0}}]
    1.17  
    1.18 -  ;; need to create a camera based on UV image,
    1.19 -  ;; update this camera every frame based on the position of this
    1.20 -  ;; geometry. (maybe can get cam to follow the object)
    1.21 -
    1.22 -  ;; use a stack for the continuation to grab the image.
    1.23 -  
    1.24 -
    1.25 -  [#^Geometry eye]
    1.26 -  
    1.27 -
    1.28 -  
    1.29 -
    1.30 -)
    1.31 -
    1.32 +  (reduce
    1.33 +   (fn [[init-a senses-a]
    1.34 +        [init-b senses-b]]
    1.35 +     [(conj init-a init-b)
    1.36 +      (into senses-a senses-b)])
    1.37 +   [[][]]      
    1.38 +   (for [eye (creature-eyes creature)]
    1.39 +     (enable-vision creature eye))))
    1.40 +    
    1.41  
    1.42  (defn blender-creature
    1.43    "Return a creature with all joints in place."
    1.44 @@ -821,11 +817,6 @@
    1.45            (do (println-repl "could not find joints node") []))]
    1.46    (assemble-creature model joints)))
    1.47  
    1.48 -
    1.49 -
    1.50 -
    1.51 -
    1.52 -
    1.53  (defn debug-window
    1.54    "creates function that offers a debug view of sensor data"
    1.55    []
    1.56 @@ -853,8 +844,6 @@
    1.57                     (sensor-data i))))
    1.58          (vi image)))))
    1.59  
    1.60 -
    1.61 -
    1.62  ;;(defn test-touch [world creature]
    1.63  
    1.64  
    1.65 @@ -868,9 +857,8 @@
    1.66          creature (blender-creature thing)
    1.67          touch-nerves (touch creature)
    1.68          touch-debug-windows (map (fn [_] (debug-window)) touch-nerves)
    1.69 -        [init-vision [vision-data]]
    1.70 -        (enable-vision creature (test-eye))
    1.71 -        vision-debug (debug-vision-window)
    1.72 +        [init-vision-fns vision-data] (vision creature)
    1.73 +        vision-debug (map (fn [_] (debug-vision-window)) vision-data)
    1.74          me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
    1.75          ]
    1.76    (world
    1.77 @@ -884,7 +872,7 @@
    1.78     (fn [world]
    1.79       (light-up-everything world)
    1.80       (enable-debug world)
    1.81 -     (init-vision world)
    1.82 +     (map #(% world) init-vision-fns)
    1.83       
    1.84       (add-eye world
    1.85                (attach-eye creature (test-eye))
    1.86 @@ -904,12 +892,15 @@
    1.87      
    1.88       (dorun
    1.89        (map #(%1 (%2 (.getRootNode world)))
    1.90 -           touch-debug-windows touch-nerves)
    1.91 -     )
    1.92 +           touch-debug-windows touch-nerves))
    1.93 +     (dorun
    1.94 +      (map #(%1 (%2))
    1.95 +           vision-debug vision-data))
    1.96 +
    1.97       ;;(println-repl (vision-data))
    1.98       (.setLocalTranslation me (.getLocation (.getCamera world)))
    1.99       
   1.100 -     (vision-debug (vision-data))
   1.101 +
   1.102       )
   1.103     ;;(let [timer (atom 0)]
   1.104     ;;  (fn [_ _]