comparison 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
comparison
equal deleted inserted replaced
282:2ad29b68ff22 283:23aadf376e9d
451 object from different angles and displaying both of those views in 451 object from different angles and displaying both of those views in
452 JFrames. 452 JFrames.
453 453
454 You should see a rotating cube, and two windows, 454 You should see a rotating cube, and two windows,
455 each displaying a different view of the cube." 455 each displaying a different view of the cube."
456 [] 456 ([] (test-pipeline false))
457 (let [candy 457 ([record?]
458 (box 1 1 1 :physical? false :color ColorRGBA/Blue)] 458 (let [candy
459 (world 459 (box 1 1 1 :physical? false :color ColorRGBA/Blue)]
460 (doto (Node.) 460 (world
461 (.attachChild candy)) 461 (doto (Node.)
462 {} 462 (.attachChild candy))
463 (fn [world] 463 {}
464 (let [cam (.clone (.getCamera world)) 464 (fn [world]
465 width (.getWidth cam) 465 (let [cam (.clone (.getCamera world))
466 height (.getHeight cam)] 466 width (.getWidth cam)
467 (add-camera! world cam 467 height (.getHeight cam)]
468 (comp 468 (add-camera! world cam
469 (view-image 469 (comp
470 (File. "/home/r/proj/cortex/render/vision/1")) 470 (view-image
471 BufferedImage!)) 471 (if record?
472 (add-camera! world 472 (File. "/home/r/proj/cortex/render/vision/1")))
473 (doto (.clone cam) 473 BufferedImage!))
474 (.setLocation (Vector3f. -10 0 0)) 474 (add-camera! world
475 (.lookAt Vector3f/ZERO Vector3f/UNIT_Y)) 475 (doto (.clone cam)
476 (comp 476 (.setLocation (Vector3f. -10 0 0))
477 (view-image 477 (.lookAt Vector3f/ZERO Vector3f/UNIT_Y))
478 (File. "/home/r/proj/cortex/render/vision/2")) 478 (comp
479 BufferedImage!)) 479 (view-image
480 ;; This is here to restore the main view 480 (if record?
481 (File. "/home/r/proj/cortex/render/vision/2")))
482 BufferedImage!))
483 ;; This is here to restore the main view
481 ;; after the other views have completed processing 484 ;; after the other views have completed processing
482 (add-camera! world (.getCamera world) no-op))) 485 (add-camera! world (.getCamera world) no-op)))
483 (fn [world tpf] 486 (fn [world tpf]
484 (.rotate candy (* tpf 0.2) 0 0))))) 487 (.rotate candy (* tpf 0.2) 0 0))))))
485 #+end_src 488 #+end_src
486 489
487 #+begin_html 490 #+begin_html
488 <div class="figure"> 491 <div class="figure">
489 <video controls="controls" width="755"> 492 <video controls="controls" width="755">
539 542
540 (defn colored-cannon-ball [color] 543 (defn colored-cannon-ball [color]
541 (comp #(change-color % color) 544 (comp #(change-color % color)
542 (fire-cannon-ball))) 545 (fire-cannon-ball)))
543 546
544 (defn test-worm-vision [record] 547 (defn test-worm-vision
545 (let [the-worm (doto (worm)(body!)) 548 ([] (test-worm-vision false))
546 vision (vision! the-worm) 549 ([record?]
547 vision-display (view-vision) 550 (let [the-worm (doto (worm)(body!))
548 fix-display (gen-fix-display) 551 vision (vision! the-worm)
549 me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 552 vision-display (view-vision)
550 x-axis 553 fix-display (gen-fix-display)
551 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red 554 me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
552 :position (Vector3f. 0 -5 0)) 555 x-axis
553 y-axis 556 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red
554 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green 557 :position (Vector3f. 0 -5 0))
555 :position (Vector3f. 0 -5 0)) 558 y-axis
556 z-axis 559 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green
557 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue 560 :position (Vector3f. 0 -5 0))
558 :position (Vector3f. 0 -5 0)) 561 z-axis
559 timer (RatchetTimer. 60)] 562 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue
560 563 :position (Vector3f. 0 -5 0))
561 (world (nodify [(floor) the-worm x-axis y-axis z-axis me]) 564 timer (RatchetTimer. 60)]
562 (assoc standard-debug-controls 565
563 "key-r" (colored-cannon-ball ColorRGBA/Red) 566 (world (nodify [(floor) the-worm x-axis y-axis z-axis me])
564 "key-b" (colored-cannon-ball ColorRGBA/Blue) 567 (assoc standard-debug-controls
565 "key-g" (colored-cannon-ball ColorRGBA/Green)) 568 "key-r" (colored-cannon-ball ColorRGBA/Red)
566 (fn [world] 569 "key-b" (colored-cannon-ball ColorRGBA/Blue)
567 (light-up-everything world) 570 "key-g" (colored-cannon-ball ColorRGBA/Green))
568 (speed-up world) 571 (fn [world]
569 (.setTimer world timer) 572 (light-up-everything world)
570 (display-dialated-time world timer) 573 (speed-up world)
571 ;; add a view from the worm's perspective 574 (.setTimer world timer)
572 (if record 575 (display-dialated-time world timer)
573 (Capture/captureVideo 576 ;; add a view from the worm's perspective
574 world 577 (if record?
575 (File. 578 (Capture/captureVideo
576 "/home/r/proj/cortex/render/worm-vision/main-view"))) 579 world
577 580 (File.
578 (add-camera! 581 "/home/r/proj/cortex/render/worm-vision/main-view")))
579 world 582
580 (add-eye! the-worm 583 (add-camera!
581 (.getChild 584 world
582 (.getChild the-worm "eyes") "eye")) 585 (add-eye! the-worm
583 (comp 586 (.getChild
584 (view-image 587 (.getChild the-worm "eyes") "eye"))
585 (if record 588 (comp
586 (File. 589 (view-image
587 "/home/r/proj/cortex/render/worm-vision/worm-view"))) 590 (if record?
588 BufferedImage!)) 591 (File.
589 592 "/home/r/proj/cortex/render/worm-vision/worm-view")))
590 (set-gravity world Vector3f/ZERO)) 593 BufferedImage!))
591 594
592 (fn [world _ ] 595 (set-gravity world Vector3f/ZERO))
593 (.setLocalTranslation me (.getLocation (.getCamera world))) 596
594 (vision-display 597 (fn [world _ ]
595 (map #(% world) vision) 598 (.setLocalTranslation me (.getLocation (.getCamera world)))
596 (if record (File. "/home/r/proj/cortex/render/worm-vision"))) 599 (vision-display
597 (fix-display world))))) 600 (map #(% world) vision)
601 (if record? (File. "/home/r/proj/cortex/render/worm-vision")))
602 (fix-display world))))))
598 #+end_src 603 #+end_src
599 604
600 The world consists of the worm and a flat gray floor. I can shoot red, 605 The world consists of the worm and a flat gray floor. I can shoot red,
601 green, blue and white cannonballs at the worm. The worm is initially 606 green, blue and white cannonballs at the worm. The worm is initially
602 looking down at the floor, and there is no gravity. My perspective 607 looking down at the floor, and there is no gravity. My perspective