changeset 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
files assets/Models/creature1/try-again.blend org/test-creature.org
diffstat 2 files changed, 20 insertions(+), 29 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 09:30:47 2012 -0700
     2.2 +++ b/org/test-creature.org	Sat Jan 21 09:55:59 2012 -0700
     2.3 @@ -757,7 +757,7 @@
     2.4  
     2.5  
     2.6  (def presets
     2.7 -  {:all    0x000000
     2.8 +  {:all    0xFFFFFF
     2.9     :red    0xFF0000
    2.10     :blue   0x0000FF
    2.11     :green  0x00FF00})
    2.12 @@ -795,21 +795,17 @@
    2.13      ]))
    2.14  
    2.15  (defn vision
    2.16 +  [#^Node creature & {skip :skip :or {skip 0}}]
    2.17  
    2.18 -  ;; need to create a camera based on UV image,
    2.19 -  ;; update this camera every frame based on the position of this
    2.20 -  ;; geometry. (maybe can get cam to follow the object)
    2.21 -
    2.22 -  ;; use a stack for the continuation to grab the image.
    2.23 -  
    2.24 -
    2.25 -  [#^Geometry eye]
    2.26 -  
    2.27 -
    2.28 -  
    2.29 -
    2.30 -)
    2.31 -
    2.32 +  (reduce
    2.33 +   (fn [[init-a senses-a]
    2.34 +        [init-b senses-b]]
    2.35 +     [(conj init-a init-b)
    2.36 +      (into senses-a senses-b)])
    2.37 +   [[][]]      
    2.38 +   (for [eye (creature-eyes creature)]
    2.39 +     (enable-vision creature eye))))
    2.40 +    
    2.41  
    2.42  (defn blender-creature
    2.43    "Return a creature with all joints in place."
    2.44 @@ -821,11 +817,6 @@
    2.45            (do (println-repl "could not find joints node") []))]
    2.46    (assemble-creature model joints)))
    2.47  
    2.48 -
    2.49 -
    2.50 -
    2.51 -
    2.52 -
    2.53  (defn debug-window
    2.54    "creates function that offers a debug view of sensor data"
    2.55    []
    2.56 @@ -853,8 +844,6 @@
    2.57                     (sensor-data i))))
    2.58          (vi image)))))
    2.59  
    2.60 -
    2.61 -
    2.62  ;;(defn test-touch [world creature]
    2.63  
    2.64  
    2.65 @@ -868,9 +857,8 @@
    2.66          creature (blender-creature thing)
    2.67          touch-nerves (touch creature)
    2.68          touch-debug-windows (map (fn [_] (debug-window)) touch-nerves)
    2.69 -        [init-vision [vision-data]]
    2.70 -        (enable-vision creature (test-eye))
    2.71 -        vision-debug (debug-vision-window)
    2.72 +        [init-vision-fns vision-data] (vision creature)
    2.73 +        vision-debug (map (fn [_] (debug-vision-window)) vision-data)
    2.74          me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
    2.75          ]
    2.76    (world
    2.77 @@ -884,7 +872,7 @@
    2.78     (fn [world]
    2.79       (light-up-everything world)
    2.80       (enable-debug world)
    2.81 -     (init-vision world)
    2.82 +     (map #(% world) init-vision-fns)
    2.83       
    2.84       (add-eye world
    2.85                (attach-eye creature (test-eye))
    2.86 @@ -904,12 +892,15 @@
    2.87      
    2.88       (dorun
    2.89        (map #(%1 (%2 (.getRootNode world)))
    2.90 -           touch-debug-windows touch-nerves)
    2.91 -     )
    2.92 +           touch-debug-windows touch-nerves))
    2.93 +     (dorun
    2.94 +      (map #(%1 (%2))
    2.95 +           vision-debug vision-data))
    2.96 +
    2.97       ;;(println-repl (vision-data))
    2.98       (.setLocalTranslation me (.getLocation (.getCamera world)))
    2.99       
   2.100 -     (vision-debug (vision-data))
   2.101 +
   2.102       )
   2.103     ;;(let [timer (atom 0)]
   2.104     ;;  (fn [_ _]