comparison org/eyes.org @ 35:5eb5c6f0590b

added reference to capture-video
author Robert McIntyre <rlm@mit.edu>
date Thu, 03 Nov 2011 08:38:41 -0700
parents 183744c179e6
children 91090f8a4414
comparison
equal deleted inserted replaced
34:183744c179e6 35:5eb5c6f0590b
109 panel 109 panel
110 (proxy [JPanel] [] 110 (proxy [JPanel] []
111 (paint 111 (paint
112 [graphics] 112 [graphics]
113 (proxy-super paintComponent graphics) 113 (proxy-super paintComponent graphics)
114 (.drawImage graphics @image 0 0 nil) 114 (.drawImage graphics @image 0 0 nil)))]
115 ))]
116
117 (SwingUtilities/invokeLater 115 (SwingUtilities/invokeLater
118 (fn [] 116 (fn []
119 (.setPreferredSize panel (Dimension. width height)) 117 (.setPreferredSize panel (Dimension. width height))
120 (doto (JFrame. "Eye Camera!") 118 (doto (JFrame. "Eye Camera!")
121 (-> (.getContentPane) (.add panel)) 119 (-> (.getContentPane) (.add panel))
139 {} 137 {}
140 (fn [world] 138 (fn [world]
141 (let [cam (.clone (.getCamera world)) 139 (let [cam (.clone (.getCamera world))
142 width (.getWidth cam) 140 width (.getWidth cam)
143 height (.getHeight cam)] 141 height (.getHeight cam)]
142 (add-eye world cam (view-image width height))
144 (add-eye world 143 (add-eye world
145 (doto (.clone cam) 144 (doto (.clone cam)
146 (.setLocation (Vector3f. -10 0 0)) 145 (.setLocation (Vector3f. -10 0 0))
147 (.lookAt Vector3f/ZERO Vector3f/UNIT_Y)) 146 (.lookAt Vector3f/ZERO Vector3f/UNIT_Y))
148 (view-image width height)) 147 (view-image width height))
149 (add-eye world cam 148 ;; This is here to restore the main view
150 (view-image width height))
151 ;; this is here to restore the main view
152 ;; after the other views have completed processing 149 ;; after the other views have completed processing
153 (add-eye world (.getCamera world) no-op) 150 (add-eye world (.getCamera world) no-op)))
154 ))
155 (fn [world tpf] 151 (fn [world tpf]
156 (.rotate candy (* tpf 0.2) 0 0)))))) 152 (.rotate candy (* tpf 0.2) 0 0))))))
157 #+end_src 153 #+end_src
158 154
159 The example code will create two videos of the same rotating object 155 The example code will create two videos of the same rotating object
160 from different angles. It can be used both for stereoscopic vision 156 from different angles. It can be used both for stereoscopic vision
161 simulation or for simulating multiple creatures, each with their own 157 simulation or for simulating multiple creatures, each with their own
162 sense of vision. 158 sense of vision.
159
160 - As a neat bonus, this idea behind simulated vision also enables one
161 to [[../../cortex/html/capture-video.html][capture live video feeds from jMonkeyEngine]].
163 162
164 163
165 * COMMENT code generation 164 * COMMENT code generation
166 #+begin_src clojure :tangle ../src/cortex/vision.clj 165 #+begin_src clojure :tangle ../src/cortex/vision.clj
167 <<eyes>> 166 <<eyes>>