view org/integration.org @ 298:85f3ff3e3f26

still working on video generation
author Robert McIntyre <rlm@mit.edu>
date Thu, 16 Feb 2012 20:05:54 -0700
parents d1206b11ae2d
children 47fe4f7b74b3
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 )
396 ;; rotate touch 180
398 ;; rotate mucles 90 counter-clockwise
399 ;; scale muscles to 15x60
401 finger width : 113
402 finger height : 357
404 thumb width : 113
406 pinky --- 0,195
407 ring --- 111,100
408 middle --- 228,0
409 pointer -- 436,96
410 thumb --- 486,420
414 within a finger (coordinates of top left corner (x,y)):
416 tip-flexor : 0,7
417 tip-extensor : 98,7
418 tip : 18,0
420 joint-2-3 : 32,79
422 mid-flexor : 19,131
423 mid-extensor : 80,131
424 mid : 30,133
426 joint-1-2 : 32,193
428 base-flexor : 19,245
429 base-extensor : 80,245
430 base : 39,247
432 joint-palm-1 : 32,307
435 Thumb is the same as finger, except it has two more pieces
437 extra-flexor-1 : 2,131
438 extra-flexor-2 : 100,131
440 ;; rotate entire thumb 45 degrees clockwise
442 within vision
443 gray -- 165,577
444 green -- 278,577
445 blue -- 165,682
446 red -- 278,682
448 entire hand : 809, 22
449 main view : 78,202
450 hearing : 784,819
452 hand-size: 688x769
455 total image size:
456 1600x894
458 (def base (File. "/home/r/proj/cortex/render/hand"))
462 (defn prepare-muscle [muscle]
463 ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"])
465 (defn prepare-touch [touch]
466 ["(" touch "-rotate" "180" ")"])
468 (defn generate-top-finger [tip-flexor tip-extensor tip
469 joint-2-3
470 mid-flexor mid-extensor mid
471 joint-1-2]
472 ["("
473 "-size" "113x357" "xc:transparent"
474 (prepare-muscle tip-flexor) "-geometry" "+0+7" "-composite"
475 (prepare-muscle tip-extensor) "-geometry" "+98+7" "-composite"
476 (prepare-touch tip) "-geometry" "+18+0" "-composite"
478 joint-2-3 "-geometry" "+32+79" "-composite"
480 (prepare-muscle mid-flexor) "-geometry" "+19+131" "-composite"
481 (prepare-muscle mid-extensor) "-geometry" "+80+131" "-composite"
482 (prepare-touch mid) "-geometry" "+39+133" "-composite"
484 joint-1-2 "-geometry" "+32+193" "-composite"
485 ")"])
487 (defn generate-finger
488 [tip-flexor tip-extensor tip
489 joint-2-3
490 mid-flexor mid-extensor mid
491 joint-1-2
492 base-flexor base-extensor base
493 joint-palm-1]
494 ["("
495 "-size" "113x357" "xc:transparent"
496 (generate-top-finger
497 tip-flexor tip-extensor tip
498 joint-2-3
499 mid-flexor mid-extensor mid
500 joint-1-2) "-geometry" "+0+0" "-composite"
501 (prepare-muscle base-flexor) "-geometry" "+19+245" "-composite"
502 (prepare-muscle base-extensor) "-geometry" "+80+245" "-composite"
503 (prepare-touch base) "-geometry" "+39+247" "-composite"
504 joint-palm-1 "-geometry" "+32+307" "-composite"
505 ")"])
507 (defn generate-thumb
508 [tip-flexor tip-extensor tip
509 joint-1-2
510 mid-flexor mid-extensor mid-flexor-2 mid-extensor-2 mid
511 joint-palm-1]
512 ["("
513 "-size" "113x357" "xc:transparent"
514 (generate-top-finger
515 tip-flexor tip-extensor tip
516 joint-1-2
517 mid-flexor mid-extensor mid
518 joint-palm-1) "-geometry" "+0+0" "-composite"
519 (prepare-muscle mid-flexor-2) "-geometry" "+2+131" "-composite"
520 (prepare-muscle mid-extensor-2) "-geometry" "+100+131" "-composite"
521 ")"])
523 pinky --- 0,195
524 ring --- 111,100
525 middle --- 228,0
526 pointer -- 436,96
527 thumb --- 486,420
530 (defn generate-hand
531 [pinky-pieces
532 ring-pieces
533 middle-pieces
534 pointer-pieces
535 thumb-pieces]
536 ["("
537 "-size" "688x769" "xc:transparent"
538 (apply generate-finger pinky-pieces)
539 "-geometry" "+0+195" "-composite"
540 (apply generate-finger ring-pieces)
541 "-geometry" "+111+100" "-composite"
542 (apply generate-finger middle-pieces)
543 "-geometry" "+228+0" "-composite"
544 "(" (apply generate-thumb thumb-pieces) "-background" "#00000000"
545 "-rotate" "45" ")"
546 "-geometry" "+300+420" "-composite"
547 (apply generate-finger pointer-pieces)
548 "-geometry" "+350+96" "-composite"
549 ")"])
551 (defn generate-vision
552 [all green blue red]
553 ["("
554 "-size" "204x192" "xc:transparent"
555 all "-geometry" "+0+0" "-composite"
556 green "-geometry" "+113+0" "-composite"
557 blue "-geometry" "+0+105" "-composite"
558 red "-geometry" "+113+105" "-composite"
559 ")"])
563 (def test-muscle (File. base "muscle/0/0000000.png"))
564 (def test-proprio (File. base "proprio/0/0000000.png"))
565 (def test-tip (File. base "touch/2/0000000.png"))
566 (def test-mid (File. base "touch/0/0000000.png"))
567 (def test-vision (File. base "vision/0/0000000.png"))
568 (def test-hearing (File. base "hearing/0/0000000.png"))
569 (def test-main (File. base "main/0000000.png"))
572 (def test-target (File. base "output.png"))
574 (def background (File. base "background.png"))
576 (use 'clojure.contrib.shell-out)
577 (defn final-image [muscle proprio tip mid vision hearing main]
578 (let [[muscle proprio tip mid vision hearing main] (map #(.getCanonicalPath %)
579 [muscle proprio tip mid vision
580 hearing main])
581 finger-pieces [muscle muscle tip
582 proprio
583 muscle muscle mid
584 proprio
585 muscle muscle mid
586 proprio]
587 thumb-pieces [muscle muscle tip
588 proprio
589 muscle muscle muscle muscle mid
590 proprio]]
593 (apply
594 sh
595 (flatten
596 ["convert"
597 (.getCanonicalPath background)
598 (generate-hand finger-pieces
599 finger-pieces
600 finger-pieces
601 finger-pieces
602 thumb-pieces)
603 "-geometry" "+809+22" "-composite"
605 (generate-vision vision vision vision vision)
606 "-geometry" "+974+599" "-composite"
608 hearing
609 "-geometry" "+784+819" "-composite"
611 main
612 "-geometry" "+78+202" "-composite"
614 (.getCanonicalPath test-target)]))))
621 #+end_src
623 #+results: integration
624 : #'cortex.integration/test-everything!
626 * COMMENT purgatory
627 #+begin_src clojure
628 (defn bullet-trans* []
629 (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red
630 :position (Vector3f. 5 0 0)
631 :mass 90)
632 obj-b (sphere 0.5 :color ColorRGBA/Blue
633 :position (Vector3f. -5 0 0)
634 :mass 0)
635 control-a (.getControl obj-a RigidBodyControl)
636 control-b (.getControl obj-b RigidBodyControl)
637 move-up? (atom nil)
638 move-down? (atom nil)
639 move-left? (atom nil)
640 move-right? (atom nil)
641 roll-left? (atom nil)
642 roll-right? (atom nil)
643 force 100
644 swivel
645 (.toRotationMatrix
646 (doto (Quaternion.)
647 (.fromAngleAxis (/ Math/PI 2)
648 Vector3f/UNIT_X)))
649 x-move
650 (doto (Matrix3f.)
651 (.fromStartEndVectors Vector3f/UNIT_X
652 (.normalize (Vector3f. 1 1 0))))
654 timer (atom 0)]
655 (doto
656 (ConeJoint.
657 control-a control-b
658 (Vector3f. -8 0 0)
659 (Vector3f. 2 0 0)
660 ;;swivel swivel
661 ;;Matrix3f/IDENTITY Matrix3f/IDENTITY
662 x-move Matrix3f/IDENTITY
663 )
664 (.setCollisionBetweenLinkedBodys false)
665 (.setLimit (* 1 (/ Math/PI 4)) ;; twist
666 (* 1 (/ Math/PI 4)) ;; swing span in X-Y plane
667 (* 0 (/ Math/PI 4)))) ;; swing span in Y-Z plane
668 (world (nodify
669 [obj-a obj-b])
670 (merge standard-debug-controls
671 {"key-r" (fn [_ pressed?] (reset! move-up? pressed?))
672 "key-t" (fn [_ pressed?] (reset! move-down? pressed?))
673 "key-f" (fn [_ pressed?] (reset! move-left? pressed?))
674 "key-g" (fn [_ pressed?] (reset! move-right? pressed?))
675 "key-v" (fn [_ pressed?] (reset! roll-left? pressed?))
676 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))})
678 (fn [world]
679 (enable-debug world)
680 (set-gravity world Vector3f/ZERO)
681 )
683 (fn [world _]
685 (if @move-up?
686 (.applyForce control-a
687 (Vector3f. force 0 0)
688 (Vector3f. 0 0 0)))
689 (if @move-down?
690 (.applyForce control-a
691 (Vector3f. (- force) 0 0)
692 (Vector3f. 0 0 0)))
693 (if @move-left?
694 (.applyForce control-a
695 (Vector3f. 0 force 0)
696 (Vector3f. 0 0 0)))
697 (if @move-right?
698 (.applyForce control-a
699 (Vector3f. 0 (- force) 0)
700 (Vector3f. 0 0 0)))
702 (if @roll-left?
703 (.applyForce control-a
704 (Vector3f. 0 0 force)
705 (Vector3f. 0 0 0)))
706 (if @roll-right?
707 (.applyForce control-a
708 (Vector3f. 0 0 (- force))
709 (Vector3f. 0 0 0)))
711 (if (zero? (rem (swap! timer inc) 100))
712 (.attachChild
713 (.getRootNode world)
714 (sphere 0.05 :color ColorRGBA/Yellow
715 :physical? false :position
716 (.getWorldTranslation obj-a)))))
717 )
718 ))
720 (defn test-joint [joint]
721 (let [[origin top bottom floor] (world-setup joint)
722 control (.getControl top RigidBodyControl)
723 move-up? (atom false)
724 move-down? (atom false)
725 move-left? (atom false)
726 move-right? (atom false)
727 roll-left? (atom false)
728 roll-right? (atom false)
729 timer (atom 0)]
731 (world
732 (nodify [top bottom floor origin])
733 (merge standard-debug-controls
734 {"key-r" (fn [_ pressed?] (reset! move-up? pressed?))
735 "key-t" (fn [_ pressed?] (reset! move-down? pressed?))
736 "key-f" (fn [_ pressed?] (reset! move-left? pressed?))
737 "key-g" (fn [_ pressed?] (reset! move-right? pressed?))
738 "key-v" (fn [_ pressed?] (reset! roll-left? pressed?))
739 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))})
741 (fn [world]
742 (light-up-everything world)
743 (enable-debug world)
744 (set-gravity world (Vector3f. 0 0 0))
745 )
747 (fn [world _]
748 (if (zero? (rem (swap! timer inc) 100))
749 (do
750 ;; (println-repl @timer)
751 (.attachChild (.getRootNode world)
752 (sphere 0.05 :color ColorRGBA/Yellow
753 :position (.getWorldTranslation top)
754 :physical? false))
755 (.attachChild (.getRootNode world)
756 (sphere 0.05 :color ColorRGBA/LightGray
757 :position (.getWorldTranslation bottom)
758 :physical? false))))
760 (if @move-up?
761 (.applyTorque control
762 (.mult (.getPhysicsRotation control)
763 (Vector3f. 0 0 10))))
764 (if @move-down?
765 (.applyTorque control
766 (.mult (.getPhysicsRotation control)
767 (Vector3f. 0 0 -10))))
768 (if @move-left?
769 (.applyTorque control
770 (.mult (.getPhysicsRotation control)
771 (Vector3f. 0 10 0))))
772 (if @move-right?
773 (.applyTorque control
774 (.mult (.getPhysicsRotation control)
775 (Vector3f. 0 -10 0))))
776 (if @roll-left?
777 (.applyTorque control
778 (.mult (.getPhysicsRotation control)
779 (Vector3f. -1 0 0))))
780 (if @roll-right?
781 (.applyTorque control
782 (.mult (.getPhysicsRotation control)
783 (Vector3f. 1 0 0))))))))
784 #+end_src
787 * COMMENT generate source
788 #+begin_src clojure :tangle ../src/cortex/integration.clj
789 <<integration>>
790 #+end_src