diff org/vision.org @ 283:23aadf376e9d

upgraded to latest jMonkeyEngine, streamlined tests
author Robert McIntyre <rlm@mit.edu>
date Wed, 15 Feb 2012 16:56:01 -0700
parents dbecd276b51a
children 7e7f8d6d9ec5
line wrap: on
line diff
     1.1 --- a/org/vision.org	Wed Feb 15 14:09:20 2012 -0700
     1.2 +++ b/org/vision.org	Wed Feb 15 16:56:01 2012 -0700
     1.3 @@ -453,35 +453,38 @@
     1.4  
     1.5     You should see a rotating cube, and two windows,
     1.6     each displaying a different view of the cube."
     1.7 -  []
     1.8 -  (let [candy
     1.9 -        (box 1 1 1 :physical? false :color ColorRGBA/Blue)]
    1.10 -    (world
    1.11 -     (doto (Node.)
    1.12 -       (.attachChild candy))
    1.13 -     {}
    1.14 -     (fn [world]
    1.15 -       (let [cam (.clone (.getCamera world))
    1.16 -             width (.getWidth cam)
    1.17 -             height (.getHeight cam)]
    1.18 -         (add-camera! world cam 
    1.19 -                      (comp
    1.20 -                       (view-image
    1.21 -                        (File. "/home/r/proj/cortex/render/vision/1"))
    1.22 -                        BufferedImage!))
    1.23 -         (add-camera! world
    1.24 -                  (doto (.clone cam)
    1.25 -                    (.setLocation (Vector3f. -10 0 0))
    1.26 -                    (.lookAt Vector3f/ZERO Vector3f/UNIT_Y))
    1.27 -                  (comp
    1.28 -                   (view-image
    1.29 -                    (File. "/home/r/proj/cortex/render/vision/2"))
    1.30 -                        BufferedImage!))
    1.31 -         ;; This is here to restore the main view
    1.32 +  ([] (test-pipeline false))
    1.33 +  ([record?]
    1.34 +     (let [candy
    1.35 +           (box 1 1 1 :physical? false :color ColorRGBA/Blue)]
    1.36 +       (world
    1.37 +        (doto (Node.)
    1.38 +          (.attachChild candy))
    1.39 +        {}
    1.40 +        (fn [world]
    1.41 +          (let [cam (.clone (.getCamera world))
    1.42 +                width (.getWidth cam)
    1.43 +                height (.getHeight cam)]
    1.44 +            (add-camera! world cam 
    1.45 +                         (comp
    1.46 +                          (view-image
    1.47 +                           (if record?
    1.48 +                             (File. "/home/r/proj/cortex/render/vision/1")))
    1.49 +                          BufferedImage!))
    1.50 +            (add-camera! world
    1.51 +                         (doto (.clone cam)
    1.52 +                           (.setLocation (Vector3f. -10 0 0))
    1.53 +                           (.lookAt Vector3f/ZERO Vector3f/UNIT_Y))
    1.54 +                         (comp
    1.55 +                          (view-image
    1.56 +                           (if record?
    1.57 +                             (File. "/home/r/proj/cortex/render/vision/2")))
    1.58 +                          BufferedImage!))
    1.59 +            ;; This is here to restore the main view
    1.60           ;; after the other views have completed processing
    1.61 -         (add-camera! world (.getCamera world) no-op)))
    1.62 -     (fn [world tpf]
    1.63 -       (.rotate candy (* tpf 0.2) 0 0)))))
    1.64 +            (add-camera! world (.getCamera world) no-op)))
    1.65 +        (fn [world tpf]
    1.66 +          (.rotate candy (* tpf 0.2) 0 0))))))
    1.67  #+end_src
    1.68  
    1.69  #+begin_html
    1.70 @@ -541,60 +544,62 @@
    1.71    (comp #(change-color % color)
    1.72           (fire-cannon-ball)))
    1.73  
    1.74 -(defn test-worm-vision [record] 
    1.75 -  (let [the-worm (doto (worm)(body!))
    1.76 -        vision (vision! the-worm)
    1.77 -        vision-display (view-vision)
    1.78 -        fix-display (gen-fix-display)
    1.79 -        me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
    1.80 -        x-axis
    1.81 -        (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red
    1.82 -             :position (Vector3f. 0 -5 0))
    1.83 -        y-axis
    1.84 -        (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green
    1.85 -             :position (Vector3f. 0 -5 0))
    1.86 -        z-axis
    1.87 -        (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue
    1.88 -             :position (Vector3f. 0 -5 0))
    1.89 -        timer (RatchetTimer. 60)]
    1.90 +(defn test-worm-vision 
    1.91 +  ([] (test-worm-vision false))
    1.92 +  ([record?] 
    1.93 +     (let [the-worm (doto (worm)(body!))
    1.94 +           vision (vision! the-worm)
    1.95 +           vision-display (view-vision)
    1.96 +           fix-display (gen-fix-display)
    1.97 +           me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
    1.98 +           x-axis
    1.99 +           (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red
   1.100 +                :position (Vector3f. 0 -5 0))
   1.101 +           y-axis
   1.102 +           (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green
   1.103 +                :position (Vector3f. 0 -5 0))
   1.104 +           z-axis
   1.105 +           (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue
   1.106 +                :position (Vector3f. 0 -5 0))
   1.107 +           timer (RatchetTimer. 60)]
   1.108  
   1.109 -    (world (nodify [(floor) the-worm x-axis y-axis z-axis me])
   1.110 -           (assoc standard-debug-controls
   1.111 -             "key-r" (colored-cannon-ball ColorRGBA/Red)
   1.112 -             "key-b" (colored-cannon-ball ColorRGBA/Blue)
   1.113 -             "key-g" (colored-cannon-ball ColorRGBA/Green))
   1.114 -           (fn [world]
   1.115 -             (light-up-everything world)
   1.116 -             (speed-up world)
   1.117 -             (.setTimer world timer)
   1.118 -             (display-dialated-time world timer)
   1.119 -             ;; add a view from the worm's perspective
   1.120 -             (if record
   1.121 -               (Capture/captureVideo
   1.122 -                  world
   1.123 -                  (File.
   1.124 -                   "/home/r/proj/cortex/render/worm-vision/main-view")))
   1.125 -             
   1.126 -             (add-camera!
   1.127 -              world
   1.128 -              (add-eye! the-worm
   1.129 -                        (.getChild 
   1.130 -                         (.getChild the-worm "eyes") "eye"))
   1.131 -              (comp
   1.132 -               (view-image
   1.133 -                (if record
   1.134 -                  (File.
   1.135 -                   "/home/r/proj/cortex/render/worm-vision/worm-view")))
   1.136 -               BufferedImage!))
   1.137 -                 
   1.138 -             (set-gravity world Vector3f/ZERO))
   1.139 -               
   1.140 -           (fn [world _ ]
   1.141 -             (.setLocalTranslation me (.getLocation (.getCamera world)))
   1.142 -             (vision-display
   1.143 -              (map #(% world) vision)
   1.144 -              (if record (File. "/home/r/proj/cortex/render/worm-vision")))
   1.145 -             (fix-display world)))))
   1.146 +       (world (nodify [(floor) the-worm x-axis y-axis z-axis me])
   1.147 +              (assoc standard-debug-controls
   1.148 +                "key-r" (colored-cannon-ball ColorRGBA/Red)
   1.149 +                "key-b" (colored-cannon-ball ColorRGBA/Blue)
   1.150 +                "key-g" (colored-cannon-ball ColorRGBA/Green))
   1.151 +              (fn [world]
   1.152 +                (light-up-everything world)
   1.153 +                (speed-up world)
   1.154 +                (.setTimer world timer)
   1.155 +                (display-dialated-time world timer)
   1.156 +                ;; add a view from the worm's perspective
   1.157 +                (if record?
   1.158 +                  (Capture/captureVideo
   1.159 +                   world
   1.160 +                   (File.
   1.161 +                    "/home/r/proj/cortex/render/worm-vision/main-view")))
   1.162 +                
   1.163 +                (add-camera!
   1.164 +                 world
   1.165 +                 (add-eye! the-worm
   1.166 +                           (.getChild 
   1.167 +                            (.getChild the-worm "eyes") "eye"))
   1.168 +                 (comp
   1.169 +                  (view-image
   1.170 +                   (if record?
   1.171 +                     (File.
   1.172 +                      "/home/r/proj/cortex/render/worm-vision/worm-view")))
   1.173 +                  BufferedImage!))
   1.174 +                
   1.175 +                (set-gravity world Vector3f/ZERO))
   1.176 +              
   1.177 +              (fn [world _ ]
   1.178 +                (.setLocalTranslation me (.getLocation (.getCamera world)))
   1.179 +                (vision-display
   1.180 +                 (map #(% world) vision)
   1.181 +                 (if record? (File. "/home/r/proj/cortex/render/worm-vision")))
   1.182 +                (fix-display world))))))
   1.183  #+end_src
   1.184  
   1.185  The world consists of the worm and a flat gray floor. I can shoot red,