comparison org/sense.org @ 338:d37ccb6c888f

determined that the laptop cannot support arbitray dimensions when creating cameras. will need to use desktop from here on out when doing actual simulations.
author Robert McIntyre <rlm@mit.edu>
date Fri, 20 Jul 2012 16:40:25 -0500
parents 702b5c78c2de
children 02cc0734a976
comparison
equal deleted inserted replaced
337:fdc98824d69b 338:d37ccb6c888f
12 jMonkeyEngine when blender files are imported with the 12 jMonkeyEngine when blender files are imported with the
13 =BlenderLoader=. =meta-data= extracts these properties. 13 =BlenderLoader=. =meta-data= extracts these properties.
14 14
15 #+name: blender-1 15 #+name: blender-1
16 #+begin_src clojure 16 #+begin_src clojure
17 (in-ns 'cortex.sense)
17 (defn meta-data 18 (defn meta-data
18 "Get the meta-data for a node created with blender." 19 "Get the meta-data for a node created with blender."
19 [blender-node key] 20 [blender-node key]
20 (if-let [data (.getUserData blender-node "properties")] 21 (if-let [data (.getUserData blender-node "properties")]
21 (.findValue data key) nil)) 22 ;; this part is to accomodate weird blender properties
22 #+end_src 23 ;; as well as sensible clojure maps.
24 (.findValue data key)
25 (.getUserData blender-node key)))
26
27 #+end_src
28
29 #+results: blender-1
30 : #'cortex.sense/meta-data
23 31
24 Blender uses a different coordinate system than jMonkeyEngine so it 32 Blender uses a different coordinate system than jMonkeyEngine so it
25 is useful to be able to convert between the two. These only come into 33 is useful to be able to convert between the two. These only come into
26 play when the meta-data of a node refers to a vector in the blender 34 play when the meta-data of a node refers to a vector in the blender
27 coordinate system. 35 coordinate system.
444 Here is some example code which shows how a camera bound to a blue box 452 Here is some example code which shows how a camera bound to a blue box
445 with =bind-sense= moves as the box is buffeted by white cannonballs. 453 with =bind-sense= moves as the box is buffeted by white cannonballs.
446 454
447 #+name: test 455 #+name: test
448 #+begin_src clojure 456 #+begin_src clojure
457 (in-ns 'cortex.test.sense)
458
449 (defn test-bind-sense 459 (defn test-bind-sense
450 "Show a camera that stays in the same relative position to a blue 460 "Show a camera that stays in the same relative position to a blue
451 cube." 461 cube."
452 ([] (test-bind-sense false)) 462 ([] (test-bind-sense false))
453 ([record?] 463 ([record?]
467 Vector3f/UNIT_X))] 477 Vector3f/UNIT_X))]
468 (bind-sense rock cam) 478 (bind-sense rock cam)
469 (.setTimer world (RatchetTimer. 60)) 479 (.setTimer world (RatchetTimer. 60))
470 (if record? 480 (if record?
471 (Capture/captureVideo 481 (Capture/captureVideo
472 world (File. "/home/r/proj/cortex/render/bind-sense0"))) 482 world
483 (File. "/home/r/proj/cortex/render/bind-sense0")))
473 (add-camera! 484 (add-camera!
474 world cam 485 world cam
475 (comp (view-image 486 (comp
476 (if record? 487 (view-image
477 (File. "/home/r/proj/cortex/render/bind-sense1"))) 488 (if record?
489 (File. "/home/r/proj/cortex/render/bind-sense1")))
478 BufferedImage!)) 490 BufferedImage!))
479 (add-camera! world (.getCamera world) no-op))) 491 (add-camera! world (.getCamera world) no-op)))
480 no-op)))) 492 no-op))))
481 #+end_src 493 #+end_src
482 494