comparison org/vision.org @ 340:4f5a5d5f1613

added time dialation display for test suite.
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Jul 2012 11:18:47 -0500
parents d37ccb6c888f
children 2e7d786241d3
comparison
equal deleted inserted replaced
339:0efa36180e8a 340:4f5a5d5f1613
490 (comp 490 (comp
491 (view-image 491 (view-image
492 (if record? 492 (if record?
493 (File. "/home/r/proj/cortex/render/vision/2"))) 493 (File. "/home/r/proj/cortex/render/vision/2")))
494 BufferedImage!)) 494 BufferedImage!))
495 (let [timer (RatchetTimer. 60)]
496 (.setTimer world timer)
497 (display-dilated-time world timer))
495 ;; This is here to restore the main view 498 ;; This is here to restore the main view
496 ;; after the other views have completed processing 499 ;; after the other views have completed processing
497 (add-camera! world (.getCamera world) no-op))) 500 (add-camera! world (.getCamera world) no-op)))
498 (fn [world tpf] 501 (fn [world tpf]
499 (.rotate candy (* tpf 0.2) 0 0)))))) 502 (.rotate candy (* tpf 0.2) 0 0))))))
500 #+end_src 503 #+end_src
504
505 #+results: test-1
506 : #'cortex.test.vision/test-pipeline
501 507
502 #+begin_html 508 #+begin_html
503 <div class="figure"> 509 <div class="figure">
504 <video controls="controls" width="755"> 510 <video controls="controls" width="755">
505 <source src="../video/spinning-cube.ogg" type="video/ogg" 511 <source src="../video/spinning-cube.ogg" type="video/ogg"
597 <space> : fire white ball" 603 <space> : fire white ball"
598 604
599 ([] (test-worm-vision false)) 605 ([] (test-worm-vision false))
600 ([record?] 606 ([record?]
601 (let [the-worm (doto (worm)(body!)) 607 (let [the-worm (doto (worm)(body!))
602 ;;the-worm (gen-worm) 608 vision (vision! the-worm)
603 ;;vision (vision! the-worm) 609 vision-display (view-vision)
604 ;;vision-display (view-vision) 610 fix-display (gen-fix-display)
605 ;;fix-display (gen-fix-display)
606 me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 611 me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
607 x-axis 612 x-axis
608 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red 613 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red
609 :position (Vector3f. 0 -5 0)) 614 :position (Vector3f. 0 -5 0))
610 y-axis 615 y-axis
611 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green 616 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green
612 :position (Vector3f. 0 -5 0)) 617 :position (Vector3f. 0 -5 0))
613 z-axis 618 z-axis
614 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue 619 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue
615 :position (Vector3f. 0 -5 0)) 620 :position (Vector3f. 0 -5 0))
616 timer (RatchetTimer. 60) 621
617 ] 622 ]
618 623
619 (world 624 (world
620 (nodify [(floor) the-worm x-axis y-axis z-axis me]) 625 (nodify [(floor) the-worm x-axis y-axis z-axis me])
621 standard-debug-controls 626 (merge standard-debug-controls
622 ;;"key-r" (colored-cannon-ball ColorRGBA/Red) 627 {"key-r" (colored-cannon-ball ColorRGBA/Red)
623 ;;"key-b" (colored-cannon-ball ColorRGBA/Blue) 628 "key-b" (colored-cannon-ball ColorRGBA/Blue)
624 ;;"key-g" (colored-cannon-ball ColorRGBA/Green)) 629 "key-g" (colored-cannon-ball ColorRGBA/Green)})
625 630
626 (fn [world] 631 (fn [world]
627 (let 632 (light-up-everything world)
628 [eye-pos (Vector3f. 0 30 0) 633 (speed-up world)
629 cam (doto 634 (let [timer (RatchetTimer. 60)]
630 (.clone (.getCamera world)) 635 (.setTimer world timer)
631 (.setLocation eye-pos) 636 (display-dilated-time world timer))
632 (.lookAt Vector3f/ZERO 637 ;; add a view from the worm's perspective
633 Vector3f/UNIT_X)) 638 (if record?
634 639 (Capture/captureVideo
635 bad-cam (doto 640 world
636 ;;saved-cam 641 (File.
637 ;;(.clone (.getCamera world)) 642 "/home/r/proj/cortex/render/worm-vision/main-view")))
638 643
639 (com.jme3.renderer.Camera. 640 480) 644 (add-camera!
640 (.setFrustumPerspective 645 world
641 (float 45) 646 (add-eye! the-worm (first (eyes the-worm)))
642 (float (/ 640 480)) 647 (comp
643 (float 1) 648 (view-image
644 (float 1000)) 649 (if record?
645 650 (File.
646 (.setLocation eye-pos) 651 "/home/r/proj/cortex/render/worm-vision/worm-view")))
647 (.lookAt Vector3f/ZERO 652 BufferedImage!))
648 Vector3f/UNIT_X)) 653
649 654 (set-gravity world Vector3f/ZERO)
650 bad-cam (add-eye! the-worm (first (eyes the-worm))) 655 (add-camera! world (.getCamera world) no-op))
651 ] 656
652 657 (fn [world _]
653 658 (.setLocalTranslation me (.getLocation (.getCamera world)))
654 (light-up-everything world) 659 (vision-display
655 ;;(speed-up world) 660 (map #(% world) vision)
656 (.setTimer world timer)
657 ;;(display-dilated-time world timer)
658 ;; add a view from the worm's perspective
659 (if record? 661 (if record?
660 (Capture/captureVideo 662 (File. "/home/r/proj/cortex/render/worm-vision")))
661 world 663 (fix-display world)
662 (File.
663 "/home/r/proj/cortex/render/worm-vision/main-view")))
664
665 (bind-sense (last (node-seq the-worm)) cam)
666 (bind-sense (last (node-seq the-worm)) bad-cam)
667
668 (add-camera!
669 world
670 bad-cam
671 (comp
672 (view-image
673 (if record?
674 (File.
675 "/home/r/proj/cortex/render/worm-vision/worm-view")))
676 BufferedImage!))
677
678
679
680 (add-camera!
681 world cam
682 (comp
683 (view-image
684 (if record?
685 (File.
686 "/home/r/proj/cortex/render/worm-vision/worm-view")))
687 BufferedImage!))
688 (set-gravity world Vector3f/ZERO)
689 (add-camera! world (.getCamera world) no-op)
690
691 (println-repl cam "\n" bad-cam)
692
693 ))
694
695 (fn [world _ ]
696 (.setLocalTranslation me (.getLocation (.getCamera world)))
697 ;; (vision-display
698 ;; (map #(% world) vision)
699 ;; (if record?
700 ;; (File. "/home/r/proj/cortex/render/worm-vision")))
701 ;;(fix-display world)
702 ))))) 664 )))))
703 #+end_src 665 #+end_src
704 666
705 #+RESULTS: test-2 667 #+RESULTS: test-2
706 : #'cortex.test.vision/test-worm-vision 668 : #'cortex.test.vision/test-worm-vision