view org/integration.org @ 299:47fe4f7b74b3

rendering video for the first time!
author Robert McIntyre <rlm@mit.edu>
date Thu, 16 Feb 2012 21:14:28 -0700
parents 85f3ff3e3f26
children c78917fb0615
line wrap: on
line source
1 #+title:
2 #+author: Robert McIntyre
3 #+email: rlm@mit.edu
4 #+description:
5 #+keywords: simulation, jMonkeyEngine3, clojure
6 #+SETUPFILE: ../../aurellem/org/setup.org
7 #+INCLUDE: ../../aurellem/org/level-0.org
9 * Intro
11 This is the ultimate test which features all of the senses that I've
12 made so far. The blender file for the creature serves as an example of
13 a fully equipped creature in terms of senses. You can find it [[../assets/Models/test-creature/hand.blend][here]].
15 #+name: integration
16 #+begin_src clojure
17 (ns cortex.integration
18 "let's play!"
19 {:author "Robert McIntyre"}
20 (:use (cortex world util body sense
21 hearing touch vision proprioception movement))
22 (:import (com.jme3.math ColorRGBA Vector3f))
23 (:import java.io.File)
24 (:import com.jme3.audio.AudioNode)
25 (:import com.aurellem.capture.RatchetTimer))
27 (dorun (cortex.import/mega-import-jme3))
28 (rlm.rlm-commands/help)
30 (def hand "Models/test-creature/hand.blend")
32 (def output-base (File. "/home/r/proj/cortex/render/hand"))
35 ;; Let the hand fall palm-up
37 ;; it curls its phalanges, starting with the pinky.
39 ;; it lets these fall back down?
41 ;; block falls down onto the hand, accompanied by a sound. The block
42 ;; can be seen by the hand's eye.
44 ;; hand FORCEFULLY catapults the block so that it hits the camera.
47 (defn motor-control-program
48 "Create a function which will execute the motor script"
49 [muscle-positions
50 script]
51 (let [current-frame (atom -1)
52 keyed-script (group-by first script)
53 current-forces (atom {}) ]
54 (fn [effectors]
55 (let [indexed-effectors (vec effectors)]
56 (dorun
57 (for [[_ part force] (keyed-script (swap! current-frame inc))]
58 (swap! current-forces (fn [m] (assoc m part force)))))
59 (doall (map (fn [effector power]
60 (effector (int power)))
61 effectors
62 (map #(@current-forces % 0) muscle-positions)))))))
64 (def muscle-positions
65 [:pointer-2-e
66 :pointer-2-f
67 :thumb-1
68 :thumb-1
69 :pointer-1-e
70 :pointer-1-f
71 :thumb-2-e
72 :thumb-2-f
73 :middle-1-e
74 :middle-1-f
75 :pointer-3-f
76 :pointer-3-e
77 :middle-2-e
78 :middle-2-f
79 :middle-3-f
80 :middle-3-e
81 :pinky-2-e
82 :pinky-2-f
83 :pinky-3-f
84 :pinky-3-e
85 :ring-3-e
86 :ring-3-f
87 :ring-2-f
88 :ring-2-e
89 :ring-1-e
90 :ring-1-f
91 :thumb-1-e
92 :thumb-1-f
93 :pinky-1-f
94 :pinky-1-e])
96 (def full 9001)
97 ;; the systax here is [keyframe body-part force]
98 (def wiggle-each-finger-tip
99 [[300 :pinky-3-f 50]
100 [320 :pinky-2-f 80]
101 [340 :pinky-1-f 100]
103 [310 :ring-3-f 100]
104 [330 :ring-2-f 120]
105 [350 :ring-1-f 140]
107 [330 :middle-3-f 120]
108 [340 :middle-2-f 120]
109 [360 :middle-1-f 30]
111 [350 :pointer-3-f 120]
112 [360 :pointer-2-f 120]
113 [380 :pointer-1-f 30]
115 [800 :pinky-3-f 0]
116 [800 :pinky-2-f 0]
117 [800 :pinky-1-f 0]
119 [800 :ring-3-f 0]
120 [800 :ring-2-f 0]
121 [800 :ring-1-f 0]
123 [800 :middle-3-f 0]
124 [800 :middle-2-f 0]
125 [800 :middle-1-f 0]
127 [800 :pointer-3-f 0]
128 [800 :pointer-2-f 0]
129 [800 :pointer-1-f 0]
132 [800 :pinky-3-e 50]
133 [800 :pinky-2-e 80]
134 [800 :pinky-1-e 100]
136 [800 :ring-3-e 100]
137 [800 :ring-2-e 120]
138 [800 :ring-1-e 140]
140 [800 :middle-3-e 120]
141 [800 :middle-2-e 120]
142 [800 :middle-1-e 30]
144 [800 :pointer-3-e 120]
145 [800 :pointer-2-e 120]
146 [800 :pointer-1-e 30]
148 [870 :pinky-3-e 0]
149 [870 :pinky-2-e 0]
150 [870 :pinky-1-e 0]
152 [870 :ring-3-e 0]
153 [870 :ring-2-e 0]
154 [870 :ring-1-e 0]
156 [870 :middle-3-e 0]
157 [870 :middle-2-e 0]
158 [870 :middle-1-e 0]
160 [870 :pointer-3-e 0]
161 [870 :pointer-2-e 0]
162 [870 :pointer-1-e 0]
164 [1500 :pointer-1-f full]
165 [1500 :pointer-2-f full]
166 [1500 :pointer-3-f full]
168 [1500 :middle-1-f full]
169 [1500 :middle-2-f full]
170 [1500 :middle-3-f full]
172 [1510 :pointer-1-f 0]
173 [1510 :pointer-2-f 0]
174 [1510 :pointer-3-f 0]
176 [1510 :middle-1-f 0]
177 [1510 :middle-2-f 0]
178 [1510 :middle-3-f 0]
179 ])
181 (defn gen-summon-ball [debug?]
182 (let [wait (atom 1100)]
183 (fn [world]
184 (if (= 0 (swap! wait dec))
185 (let [brick
186 (box 0.8 0.8 0.8 :mass 0.05
187 :position (Vector3f. -0.5 0 0.5)
188 :color (ColorRGBA/Red))
189 bell (AudioNode. (asset-manager)
190 "Sounds/pure.wav" false)]
191 (.play bell)
192 (if debug?
193 (.addControl
194 brick
195 (proxy [AbstractControl] []
196 (controlUpdate [tpf]
197 (println-repl (.getWorldTranslation brick)))
198 (controlRender [_ _]))))
199 (add-element world brick))))))
202 (def control-list
203 [
204 0 ;;pointer-21 #<Vector3f (0.99999994, 0.0, 0.0)>
205 0 ;;pointer-21 #<Vector3f (-0.99999994, 0.0, 0.0)>
206 0 ;;thumb-11 #<Vector3f (-0.8802276, -0.39781287, -0.25873658)>
207 0 ;;thumb-11 #<Vector3f (0.8485723, 0.46149826, 0.2587364)>
208 0 ;;pointer-11 #<Vector3f (0.99999994, 0.0, 0.0)>
209 0 ;;pointer-11 #<Vector3f (-0.99999994, 0.0, 0.0)>
210 0 ;;thumb-2.0011 #<Vector3f (-0.71705645, -0.44753736, -0.5343599)>
211 0 ;;thumb-2.0011 #<Vector3f (-0.10567085, 0.83862597, 0.53435963)>
212 0 ;;middle-11 #<Vector3f (0.99999994, 0.0, 0.0)>
213 0 ;;middle-11 #<Vector3f (-0.99999994, 0.0, 0.0)>
214 0 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)>
215 0 ;;pointer-31 #<Vector3f (0.99999994, 0.0, 0.0)>
216 0 ;;middle-21 #<Vector3f (0.99999994, 0.0, 0.0)>
217 0 ;;middle-21 #<Vector3f (-0.99999994, 0.0, 0.0)>
218 0 ;;middle-31 #<Vector3f (-0.99999994, 0.0, 0.0)>
219 0 ;;middle-31 #<Vector3f (0.99999994, 0.0, 0.0)>
220 0 ;;pinky-21 #<Vector3f (0.99999994, 0.0, 0.0)>
221 0 ;;pinky-21 #<Vector3f (-0.99999994, 0.0, 0.0)>
222 0 ;;pinky-31 #<Vector3f (-1, 0.0, 0.0)>
223 0 ;;pinky-31 #<Vector3f (1.0, 0.0, 0.0)>
224 0 ;;ring-31 #<Vector3f (0.99999994, 0.0, 0.0)>
225 0 ;;ring-31 #<Vector3f (-0.99999994, 0.0, 0.0)>
226 0 ;;ring-21 #<Vector3f (-0.99999994, 0.0, 0.0)>
227 0 ;;ring-21 #<Vector3f (0.99999994, 0.0, 0.0)>
228 0 ;;ring-11 #<Vector3f (0.99999994, 0.0, 0.0)>
229 0 ;;ring-11 #<Vector3f (-0.99999994, 0.0, 0.0)>
230 0 ;;thumb-11 #<Vector3f (-0.43154645, 0.7302033, 0.5296894)>
231 0 ;;thumb-11 #<Vector3f (-0.8032993, -0.2722854, -0.5296895)>
232 0 ;;pinky-11 #<Vector3f (-0.99999994, 0.0, 0.0)>
233 0 ;;pinky-11 #<Vector3f (0.99999994, 0.0, 0.0)>
234 ])
236 (import com.aurellem.capture.Capture)
238 (defn test-everything!
239 ([] (test-everything! false))
240 ([record?]
241 (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
243 base (File. "/home/r/proj/cortex/render/hand")
246 creature (doto (load-blender-model hand)
247 (body!))
249 summon-ball (gen-summon-ball false)
250 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
251 touch (touch! creature)
252 touch-display (view-touch)
254 vision (vision! creature)
255 vision-display (view-vision)
257 hearing (hearing! creature)
258 hearing-display (view-hearing)
260 prop (proprioception! creature)
261 prop-display (view-proprioception)
263 control-script (motor-control-program
264 muscle-positions wiggle-each-finger-tip)
265 muscles (movement! creature)
266 muscle-display (view-movement)
267 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
269 fix-display (gen-fix-display)]
270 (world
271 (nodify [creature
272 (box 10 2 10 :position (Vector3f. 0 -9 0)
273 :color ColorRGBA/Gray :mass 0)
274 me])
275 standard-debug-controls
277 (fn [world]
278 (.setTimer world (RatchetTimer. 60))
279 (position-camera
280 world (Vector3f. -0.13217318, 5.816415, -5.3089414)
281 (Quaternion. 0.55685693, 0.0042774677, -0.0028673497, 0.83059245))
283 (light-up-everything world)
284 (enable-debug world)
285 (add-camera! world
286 (add-eye! creature
287 (.getChild
288 (.getChild creature "eyes") "eye"))
289 (comp (view-image) BufferedImage!))
291 (if record?
292 (Capture/captureVideo
293 world (File. base "main")))
294 (if record?
295 (Capture/captureAudio
296 world (File. base "main.wav"))))
297 (fn [world tpf]
298 (prop-display
299 (prop)
300 (if record? (File. base "proprio")))
301 (touch-display
302 (map #(% (.getRootNode world)) touch)
303 (if record? (File. base "touch")))
304 (vision-display
305 (map #(% world) vision)
306 (if record? (File. base "vision")))
307 (hearing-display
308 (map #(% world) hearing)
309 (if record? (File. base "hearing")))
310 (muscle-display
311 (control-script muscles)
312 (if record? (File. base "muscle")))
314 (summon-ball world)
316 (.setLocalTranslation me (.getLocation (.getCamera world)))
317 (fix-display world))))))
320 (comment
321 ;; list of touch targets
322 0 middle-11
323 1 middle-21
324 2 middle-31
325 3 pinky-11
326 4 pinky-21
327 5 pinky-31
328 6 pointer-11
329 7 pointer-21
330 8 pointer-31
331 9 ring-11
332 10 ring-21
333 11 ring-31
334 12 thumb-11
335 13 thumb-2.0011
338 ;; list of vision targets
339 0 :all
340 1 :green
341 2 :blue
342 3 :red
344 ;; list of proprio targets
345 0 middle-11 -> middle-21
346 1 middle-21 -> middle-31
347 2 thumb-11 -> thumb-2.0011
348 3 pointer-11 -> pointer-21
349 4 pointer-21 -> pointer-31
350 5 ring-21 -> ring-31
351 6 ring-11 -> ring-21
352 7 pinky-21 -> pinky-31
353 8 pinky-11 -> pinky-21
354 9 middle-11 -> palm1
355 10 pinky-11 -> palm1
356 11 palm1 -> pointer-11
357 12 palm1 -> ring-11
358 13 palm1 -> thumb-11
361 ;; list of muscle targets
362 0 :pointer-2-e
363 1 :pointer-2-f
364 2 :thumb-1
365 3 :thumb-1
366 4 :pointer-1-e
367 5 :pointer-1-f
368 6 :thumb-2-e
369 7 :thumb-2-f
370 8 :middle-1-e
371 9 :middle-1-f
372 10 :pointer-3-f
373 11 :pointer-3-e
374 12 :middle-2-e
375 13 :middle-2-f
376 14 :middle-3-f
377 15 :middle-3-e
378 16 :pinky-2-e
379 17 :pinky-2-f
380 18 :pinky-3-f
381 19 :pinky-3-e
382 20 :ring-3-e
383 21 :ring-3-f
384 22 :ring-2-f
385 23 :ring-2-e
386 24 :ring-1-e
387 25 :ring-1-f
388 26 :thumb-1-e
389 27 :thumb-1-f
390 28 :pinky-1-f
391 29 :pinky-1-e
392 )
394 (def base (File. "/home/r/proj/cortex/render/hand"))
396 (defn prepare-muscle [muscle]
397 ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"])
399 (defn prepare-touch [touch]
400 ["(" touch "-rotate" "180" ")"])
402 (defn generate-top-finger [tip-flexor tip-extensor tip
403 joint-2-3
404 mid-flexor mid-extensor mid
405 joint-1-2]
406 ["("
407 "-size" "113x357" "xc:transparent"
408 (prepare-muscle tip-flexor) "-geometry" "+0+7" "-composite"
409 (prepare-muscle tip-extensor) "-geometry" "+98+7" "-composite"
410 (prepare-touch tip) "-geometry" "+18+0" "-composite"
412 joint-2-3 "-geometry" "+32+79" "-composite"
414 (prepare-muscle mid-flexor) "-geometry" "+19+131" "-composite"
415 (prepare-muscle mid-extensor) "-geometry" "+80+131" "-composite"
416 (prepare-touch mid) "-geometry" "+39+133" "-composite"
418 joint-1-2 "-geometry" "+32+193" "-composite"
419 ")"])
421 (defn file-names [#^File dir]
422 (map #(.getCanonicalPath %) (next (sort (file-seq dir)))))
424 (defn file-groups [& paths]
425 (apply (partial map list )
426 (map (comp file-names #(File. base %))
427 paths)))
430 (defn pinky []
431 (file-groups
432 "muscle/18"
433 "muscle/19"
434 "touch/5"
435 "proprio/7"
437 "muscle/17"
438 "muscle/16"
439 "touch/4"
440 "proprio/8"
442 "muscle/28"
443 "muscle/29"
444 "touch/3"
445 "proprio/10"))
447 (defn ring []
448 (file-groups
449 "muscle/21"
450 "muscle/20"
451 "touch/11"
452 "proprio/5"
454 "muscle/22"
455 "muscle/23"
456 "touch/10"
457 "proprio/6"
459 "muscle/25"
460 "muscle/24"
461 "touch/9"
462 "proprio/12"))
464 (defn middle []
465 (file-groups
466 "muscle/14"
467 "muscle/15"
468 "touch/2"
469 "proprio/1"
471 "muscle/12"
472 "muscle/13"
473 "touch/1"
474 "proprio/0"
476 "muscle/8"
477 "muscle/9"
478 "touch/0"
479 "proprio/9"))
481 (defn pointer []
482 (file-groups
483 "muscle/10"
484 "muscle/11"
485 "touch/8"
486 "proprio/4"
488 "muscle/1"
489 "muscle/0"
490 "touch/7"
491 "proprio/3"
493 "muscle/5"
494 "muscle/4"
495 "touch/6"
496 "proprio/11"))
498 (defn thumb []
499 (file-groups
500 "muscle/7"
501 "muscle/6"
502 "touch/13"
503 "proprio/2"
505 "muscle/27"
506 "muscle/26"
507 "muscle/3"
508 "muscle/2"
509 "touch/12"
510 "proprio/13"))
512 (defn generate-finger
513 [tip-flexor tip-extensor tip
514 joint-2-3
515 mid-flexor mid-extensor mid
516 joint-1-2
517 base-flexor base-extensor base
518 joint-palm-1]
519 ["("
520 "-size" "113x357" "xc:transparent"
521 (generate-top-finger
522 tip-flexor tip-extensor tip
523 joint-2-3
524 mid-flexor mid-extensor mid
525 joint-1-2) "-geometry" "+0+0" "-composite"
526 (prepare-muscle base-flexor) "-geometry" "+19+245" "-composite"
527 (prepare-muscle base-extensor) "-geometry" "+80+245" "-composite"
528 (prepare-touch base) "-geometry" "+39+247" "-composite"
529 joint-palm-1 "-geometry" "+32+307" "-composite"
530 ")"])
532 (defn generate-thumb
533 [tip-flexor tip-extensor tip
534 joint-1-2
535 mid-flexor mid-extensor mid-flexor-2 mid-extensor-2 mid
536 joint-palm-1]
537 ["("
538 "-size" "113x357" "xc:transparent"
539 (generate-top-finger
540 tip-flexor tip-extensor tip
541 joint-1-2
542 mid-flexor mid-extensor mid
543 joint-palm-1) "-geometry" "+0+0" "-composite"
544 (prepare-muscle mid-flexor-2) "-geometry" "+2+131" "-composite"
545 (prepare-muscle mid-extensor-2) "-geometry" "+100+131" "-composite"
546 ")"])
548 (defn generate-hand
549 [pinky-pieces
550 ring-pieces
551 middle-pieces
552 pointer-pieces
553 thumb-pieces]
554 ["("
555 "-size" "688x769" "xc:transparent"
556 (apply generate-finger pinky-pieces)
557 "-geometry" "+0+195" "-composite"
558 (apply generate-finger ring-pieces)
559 "-geometry" "+111+100" "-composite"
560 (apply generate-finger middle-pieces)
561 "-geometry" "+228+0" "-composite"
562 "(" (apply generate-thumb thumb-pieces) "-background" "#00000000"
563 "-rotate" "45" ")"
564 "-geometry" "+300+420" "-composite"
565 (apply generate-finger pointer-pieces)
566 "-geometry" "+350+96" "-composite"
567 ")"])
569 (defn generate-vision
570 [all green blue red]
571 ["("
572 "-size" "204x192" "xc:transparent"
573 all "-geometry" "+0+0" "-composite"
574 green "-geometry" "+113+0" "-composite"
575 blue "-geometry" "+0+105" "-composite"
576 red "-geometry" "+113+105" "-composite"
577 ")"])
579 (def test-muscle (File. base "muscle/0/0000000.png"))
580 (def test-proprio (File. base "proprio/0/0000000.png"))
581 (def test-tip (File. base "touch/2/0000000.png"))
582 (def test-mid (File. base "touch/0/0000000.png"))
583 (def test-vision (File. base "vision/0/0000000.png"))
584 (def test-hearing (File. base "hearing/0/0000000.png"))
585 (def test-main (File. base "main/0000000.png"))
587 (def test-target (File. base "output.png"))
589 (def background (File. base "background.png"))
591 (use 'clojure.contrib.shell-out)
593 (defn vision []
594 (file-groups
595 "vision/0"
596 "vision/1"
597 "vision/2"
598 "vision/3"))
600 (defn hearing []
601 (file-names (File. base "hearing/0")))
603 (defn main []
604 (file-names (File. base "main")))
606 (defn targets []
607 (map
608 (comp #(.getCanonicalPath %)
609 #(File. (str base "/out/" (format "%07d.png" %))))
610 (range 0 (count (main)))))
613 (defn final-image [main [all red green blue] hearing
614 pinky ring middle pointer thumb target]
615 (println target)
616 (apply
617 sh
618 (flatten
619 ["convert"
620 (.getCanonicalPath background)
622 (generate-hand pinky ring middle pointer thumb)
623 "-geometry" "+809+22" "-composite"
625 (generate-vision all red green blue)
626 "-geometry" "+974+599" "-composite"
628 hearing
629 "-geometry" "+784+819" "-composite"
631 main
632 "-geometry" "+78+202" "-composite"
634 target])))
636 (defn convert-files []
637 (dorun
638 (pmap final-image
639 (main)
640 (vision)
641 (hearing)
642 (pinky)
643 (ring)
644 (middle)
645 (pointer)
646 (thumb)
647 (targets))))
648 #+end_src
651 #+begin_src sh
652 cd /home/r/proj/cortex/render/hand
654 ffmpeg -r 60 -i out/%07d.png -i main.wav -b:a 128k \
655 -b:v 9000k -c:a libvorbis -c:v libtheora hand.ogg
656 #+end_src
658 #+results: integration
659 : #'cortex.integration/convert-files
661 * COMMENT purgatory
662 #+begin_src clojure
663 (defn bullet-trans* []
664 (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red
665 :position (Vector3f. 5 0 0)
666 :mass 90)
667 obj-b (sphere 0.5 :color ColorRGBA/Blue
668 :position (Vector3f. -5 0 0)
669 :mass 0)
670 control-a (.getControl obj-a RigidBodyControl)
671 control-b (.getControl obj-b RigidBodyControl)
672 move-up? (atom nil)
673 move-down? (atom nil)
674 move-left? (atom nil)
675 move-right? (atom nil)
676 roll-left? (atom nil)
677 roll-right? (atom nil)
678 force 100
679 swivel
680 (.toRotationMatrix
681 (doto (Quaternion.)
682 (.fromAngleAxis (/ Math/PI 2)
683 Vector3f/UNIT_X)))
684 x-move
685 (doto (Matrix3f.)
686 (.fromStartEndVectors Vector3f/UNIT_X
687 (.normalize (Vector3f. 1 1 0))))
689 timer (atom 0)]
690 (doto
691 (ConeJoint.
692 control-a control-b
693 (Vector3f. -8 0 0)
694 (Vector3f. 2 0 0)
695 ;;swivel swivel
696 ;;Matrix3f/IDENTITY Matrix3f/IDENTITY
697 x-move Matrix3f/IDENTITY
698 )
699 (.setCollisionBetweenLinkedBodys false)
700 (.setLimit (* 1 (/ Math/PI 4)) ;; twist
701 (* 1 (/ Math/PI 4)) ;; swing span in X-Y plane
702 (* 0 (/ Math/PI 4)))) ;; swing span in Y-Z plane
703 (world (nodify
704 [obj-a obj-b])
705 (merge standard-debug-controls
706 {"key-r" (fn [_ pressed?] (reset! move-up? pressed?))
707 "key-t" (fn [_ pressed?] (reset! move-down? pressed?))
708 "key-f" (fn [_ pressed?] (reset! move-left? pressed?))
709 "key-g" (fn [_ pressed?] (reset! move-right? pressed?))
710 "key-v" (fn [_ pressed?] (reset! roll-left? pressed?))
711 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))})
713 (fn [world]
714 (enable-debug world)
715 (set-gravity world Vector3f/ZERO)
716 )
718 (fn [world _]
720 (if @move-up?
721 (.applyForce control-a
722 (Vector3f. force 0 0)
723 (Vector3f. 0 0 0)))
724 (if @move-down?
725 (.applyForce control-a
726 (Vector3f. (- force) 0 0)
727 (Vector3f. 0 0 0)))
728 (if @move-left?
729 (.applyForce control-a
730 (Vector3f. 0 force 0)
731 (Vector3f. 0 0 0)))
732 (if @move-right?
733 (.applyForce control-a
734 (Vector3f. 0 (- force) 0)
735 (Vector3f. 0 0 0)))
737 (if @roll-left?
738 (.applyForce control-a
739 (Vector3f. 0 0 force)
740 (Vector3f. 0 0 0)))
741 (if @roll-right?
742 (.applyForce control-a
743 (Vector3f. 0 0 (- force))
744 (Vector3f. 0 0 0)))
746 (if (zero? (rem (swap! timer inc) 100))
747 (.attachChild
748 (.getRootNode world)
749 (sphere 0.05 :color ColorRGBA/Yellow
750 :physical? false :position
751 (.getWorldTranslation obj-a)))))
752 )
753 ))
755 (defn test-joint [joint]
756 (let [[origin top bottom floor] (world-setup joint)
757 control (.getControl top RigidBodyControl)
758 move-up? (atom false)
759 move-down? (atom false)
760 move-left? (atom false)
761 move-right? (atom false)
762 roll-left? (atom false)
763 roll-right? (atom false)
764 timer (atom 0)]
766 (world
767 (nodify [top bottom floor origin])
768 (merge standard-debug-controls
769 {"key-r" (fn [_ pressed?] (reset! move-up? pressed?))
770 "key-t" (fn [_ pressed?] (reset! move-down? pressed?))
771 "key-f" (fn [_ pressed?] (reset! move-left? pressed?))
772 "key-g" (fn [_ pressed?] (reset! move-right? pressed?))
773 "key-v" (fn [_ pressed?] (reset! roll-left? pressed?))
774 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))})
776 (fn [world]
777 (light-up-everything world)
778 (enable-debug world)
779 (set-gravity world (Vector3f. 0 0 0))
780 )
782 (fn [world _]
783 (if (zero? (rem (swap! timer inc) 100))
784 (do
785 ;; (println-repl @timer)
786 (.attachChild (.getRootNode world)
787 (sphere 0.05 :color ColorRGBA/Yellow
788 :position (.getWorldTranslation top)
789 :physical? false))
790 (.attachChild (.getRootNode world)
791 (sphere 0.05 :color ColorRGBA/LightGray
792 :position (.getWorldTranslation bottom)
793 :physical? false))))
795 (if @move-up?
796 (.applyTorque control
797 (.mult (.getPhysicsRotation control)
798 (Vector3f. 0 0 10))))
799 (if @move-down?
800 (.applyTorque control
801 (.mult (.getPhysicsRotation control)
802 (Vector3f. 0 0 -10))))
803 (if @move-left?
804 (.applyTorque control
805 (.mult (.getPhysicsRotation control)
806 (Vector3f. 0 10 0))))
807 (if @move-right?
808 (.applyTorque control
809 (.mult (.getPhysicsRotation control)
810 (Vector3f. 0 -10 0))))
811 (if @roll-left?
812 (.applyTorque control
813 (.mult (.getPhysicsRotation control)
814 (Vector3f. -1 0 0))))
815 (if @roll-right?
816 (.applyTorque control
817 (.mult (.getPhysicsRotation control)
818 (Vector3f. 1 0 0))))))))
819 #+end_src
822 * COMMENT generate source
823 #+begin_src clojure :tangle ../src/cortex/integration.clj
824 <<integration>>
825 #+end_src