comparison org/worm_learn.clj @ 445:47cfbe84f00e

complete images in first third of first chapter.
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Mar 2014 03:18:04 -0400
parents ea0bcd47d55b
children 09b7c8dd4365
comparison
equal deleted inserted replaced
444:ea0bcd47d55b 445:47cfbe84f00e
221 221
222 222
223 (declare phi-space phi-scan) 223 (declare phi-space phi-scan)
224 224
225 (defn debug-experience 225 (defn debug-experience
226 [experiences] 226 [experiences text]
227 (cond 227 (cond
228 (grand-circle? experiences) (println "Grand Circle") 228 (grand-circle? experiences) (.setText text "Grand Circle")
229 (curled? experiences) (println "Curled") 229 (curled? experiences) (.setText text "Curled")
230 (wiggling? experiences) (println "Wiggling") 230 (wiggling? experiences) (.setText text "Wiggling")
231 (resting? experiences) (println "Resting"))) 231 (resting? experiences) (.setText text "Resting")))
232 232
233 233
234 (def standard-world-view 234 (def standard-world-view
235 [(Vector3f. 4.207176, -3.7366982, 3.0816958) 235 [(Vector3f. 4.207176, -3.7366982, 3.0816958)
236 (Quaternion. 0.11118768, 0.87678415, 0.24434438, -0.3989771)]) 236 (Quaternion. 0.11118768, 0.87678415, 0.24434438, -0.3989771)])
275 (.setShadowIntensity (float 0.6)) 275 (.setShadowIntensity (float 0.6))
276 (.setCompareMode PssmShadowRenderer$CompareMode/Software) 276 (.setCompareMode PssmShadowRenderer$CompareMode/Software)
277 (.setFilterMode PssmShadowRenderer$FilterMode/Bilinear))] 277 (.setFilterMode PssmShadowRenderer$FilterMode/Bilinear))]
278 (.addProcessor (.getViewPort world) pssm))) 278 (.addProcessor (.getViewPort world) pssm)))
279 279
280
281 (defn display-text [[x y :as location]]
282 (let []
283 (.setLocalTranslation text 300 (.getLineHeight text) 0)
284 (fn [world]
285
286
287
288
289 (fn [new-text]
280 290
281 (defn worm-world 291 (defn worm-world
282 [& {:keys [record motor-control keybindings view experiences 292 [& {:keys [record motor-control keybindings view experiences
283 worm-model end-frame experience-watch] :as settings}] 293 worm-model end-frame experience-watch] :as settings}]
284 (let [{:keys [record motor-control keybindings view experiences 294 (let [{:keys [record motor-control keybindings view experiences
296 floor 306 floor
297 (box 5 1 5 :position (Vector3f. 0 -10 0) 307 (box 5 1 5 :position (Vector3f. 0 -10 0)
298 :mass 0 308 :mass 0
299 :texture "Textures/aurellem.png" 309 :texture "Textures/aurellem.png"
300 :material "Common/MatDefs/Misc/Unshaded.j3md") 310 :material "Common/MatDefs/Misc/Unshaded.j3md")
301 timer (IsoTimer. 60)] 311 timer (IsoTimer. 60)
312
313 font (.loadFont (asset-manager) "Interface/Fonts/Console.fnt")
314 worm-action (doto (BitmapText. font false)
315 (.setSize 35)
316 (.setColor (ColorRGBA/Black)))]
302 317
303 (world 318 (world
304 (nodify [worm floor]) 319 (nodify [worm floor])
305 (merge standard-debug-controls keybindings) 320 (merge standard-debug-controls keybindings)
306 (fn [world] 321 (fn [world]
322 (.setLocalTranslation
323 worm-action 20 470 0)
324 (.attachChild (.getGuiNode world) worm-action)
325
307 (enable-good-shadows world) 326 (enable-good-shadows world)
308 (.setShadowMode worm RenderQueue$ShadowMode/CastAndReceive) 327 (.setShadowMode worm RenderQueue$ShadowMode/CastAndReceive)
309 (.setShadowMode floor RenderQueue$ShadowMode/Receive) 328 (.setShadowMode floor RenderQueue$ShadowMode/Receive)
310 329
311 (.setBackgroundColor (.getViewPort world) (ColorRGBA/White)) 330 (.setBackgroundColor (.getViewPort world) (ColorRGBA/White))
313 (.setDisplayFps world false) 332 (.setDisplayFps world false)
314 (position-camera world view) 333 (position-camera world view)
315 (.setTimer world timer) 334 (.setTimer world timer)
316 (display-dilated-time world timer) 335 (display-dilated-time world timer)
317 (when record 336 (when record
337 (dir! record)
318 (Capture/captureVideo 338 (Capture/captureVideo
319 world 339 world
320 (dir! (File. record "main-view")))) 340 (dir! (File. record "main-view"))))
321 (speed-up world) 341 (speed-up world)
322 ;;(light-up-everything world) 342 ;;(light-up-everything world)
331 (record-experience! 351 (record-experience!
332 experiences {:touch touch-data 352 experiences {:touch touch-data
333 :proprioception proprioception-data 353 :proprioception proprioception-data
334 :muscle muscle-data})) 354 :muscle muscle-data}))
335 (when experience-watch 355 (when experience-watch
336 (experience-watch @experiences)) 356 (experience-watch @experiences worm-action))
337 (muscle-display 357 (muscle-display
338 muscle-data 358 muscle-data
339 (when record (dir! (File. record "muscle")))) 359 (when record (dir! (File. record "muscle"))))
340 (prop-display 360 (prop-display
341 proprioception-data 361 proprioception-data