comparison org/vision.org @ 335:5dcd44576cbc

add BufferedImage to Viewable Protocol
author Robert McIntyre <rlm@mit.edu>
date Fri, 20 Jul 2012 13:02:58 -0500
parents 702b5c78c2de
children fdc98824d69b
comparison
equal deleted inserted replaced
334:c264ebf683b4 335:5dcd44576cbc
574 z-axis 574 z-axis
575 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue 575 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue
576 :position (Vector3f. 0 -5 0)) 576 :position (Vector3f. 0 -5 0))
577 timer (RatchetTimer. 60)] 577 timer (RatchetTimer. 60)]
578 578
579 (world (nodify [(floor) the-worm x-axis y-axis z-axis me]) 579 (world
580 (assoc standard-debug-controls 580 (nodify [(floor) the-worm x-axis y-axis z-axis me])
581 "key-r" (colored-cannon-ball ColorRGBA/Red) 581 (assoc standard-debug-controls
582 "key-b" (colored-cannon-ball ColorRGBA/Blue) 582 "key-r" (colored-cannon-ball ColorRGBA/Red)
583 "key-g" (colored-cannon-ball ColorRGBA/Green)) 583 "key-b" (colored-cannon-ball ColorRGBA/Blue)
584 (fn [world] 584 "key-g" (colored-cannon-ball ColorRGBA/Green))
585 (light-up-everything world) 585 (fn [world]
586 (speed-up world) 586 (light-up-everything world)
587 (.setTimer world timer) 587 (speed-up world)
588 (display-dilated-time world timer) 588 (.setTimer world timer)
589 ;; add a view from the worm's perspective 589 (display-dilated-time world timer)
590 (if record? 590 ;; add a view from the worm's perspective
591 (Capture/captureVideo 591 (if record?
592 world 592 (Capture/captureVideo
593 (File. 593 world
594 "/home/r/proj/cortex/render/worm-vision/main-view"))) 594 (File.
595 595 "/home/r/proj/cortex/render/worm-vision/main-view")))
596 (add-camera! 596
597 world 597 (add-camera!
598 (add-eye! the-worm 598 world
599 (.getChild 599 (add-eye! the-worm
600 (.getChild the-worm "eyes") "eye")) 600 (.getChild
601 (comp 601 (.getChild the-worm "eyes") "eye"))
602 (view-image 602 (comp
603 (if record? 603 (view-image
604 (File. 604 (if record?
605 "/home/r/proj/cortex/render/worm-vision/worm-view"))) 605 (File.
606 BufferedImage!)) 606 "/home/r/proj/cortex/render/worm-vision/worm-view")))
607 607 BufferedImage!))
608 (set-gravity world Vector3f/ZERO)) 608 (set-gravity world Vector3f/ZERO))
609 609
610 (fn [world _ ] 610 (fn [world _ ]
611 (.setLocalTranslation me (.getLocation (.getCamera world))) 611 (.setLocalTranslation me (.getLocation (.getCamera world)))
612 (vision-display 612 (vision-display
613 (map #(% world) vision) 613 (map #(% world) vision)
614 (if record? (File. "/home/r/proj/cortex/render/worm-vision"))) 614 (if record?
615 (fix-display world)))))) 615 (File. "/home/r/proj/cortex/render/worm-vision")))
616 #+end_src 616 (fix-display world)
617 )))))
618 #+end_src
619
620 #+RESULTS: test-2
621 | | #'cortex.test.vision/test-worm-vision |
622
617 623
618 The world consists of the worm and a flat gray floor. I can shoot red, 624 The world consists of the worm and a flat gray floor. I can shoot red,
619 green, blue and white cannonballs at the worm. The worm is initially 625 green, blue and white cannonballs at the worm. The worm is initially
620 looking down at the floor, and there is no gravity. My perspective 626 looking down at the floor, and there is no gravity. My perspective
621 (the Main View), the worm's perspective (Worm View) and the 4 sensor 627 (the Main View), the worm's perspective (Worm View) and the 4 sensor