comparison 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
comparison
equal deleted inserted replaced
297:d1206b11ae2d 298:85f3ff3e3f26
94 :pinky-1-e]) 94 :pinky-1-e])
95 95
96 (def full 9001) 96 (def full 9001)
97 ;; the systax here is [keyframe body-part force] 97 ;; the systax here is [keyframe body-part force]
98 (def wiggle-each-finger-tip 98 (def wiggle-each-finger-tip
99 [[300 :pointer-3-f 50] 99 [[300 :pinky-3-f 50]
100 100 [320 :pinky-2-f 80]
101 101 [340 :pinky-1-f 100]
102 [400 :middle-3-f full] 102
103 [401 :middle-3-f 50] 103 [310 :ring-3-f 100]
104 104 [330 :ring-2-f 120]
105 [600 :ring-3-f full] 105 [350 :ring-1-f 140]
106 [601 :ring-3-f 40] 106
107 107 [330 :middle-3-f 120]
108 [800 :pinky-3-f full] 108 [340 :middle-2-f 120]
109 [801 :pinky-3-f 50] 109 [360 :middle-1-f 30]
110 110
111 [1300 :pointer-1-f full] 111 [350 :pointer-3-f 120]
112 [1300 :pointer-2-f full] 112 [360 :pointer-2-f 120]
113 [1300 :pointer-3-f 0] 113 [380 :pointer-1-f 30]
114 114
115 [1289 :middle-1-f full] 115 [800 :pinky-3-f 0]
116 [1289 :middle-2-f full] 116 [800 :pinky-2-f 0]
117 [1289 :middle-3-f 0] 117 [800 :pinky-1-f 0]
118
119 [800 :ring-3-f 0]
120 [800 :ring-2-f 0]
121 [800 :ring-1-f 0]
122
123 [800 :middle-3-f 0]
124 [800 :middle-2-f 0]
125 [800 :middle-1-f 0]
126
127 [800 :pointer-3-f 0]
128 [800 :pointer-2-f 0]
129 [800 :pointer-1-f 0]
130
118 131
119 [1310 :pointer-1-f 0] 132 [800 :pinky-3-e 50]
120 [1310 :pointer-2-f 0] 133 [800 :pinky-2-e 80]
121 [1310 :pointer-3-f 0] 134 [800 :pinky-1-e 100]
122 135
123 [1310 :middle-1-f 0] 136 [800 :ring-3-e 100]
124 [1310 :middle-2-f 0] 137 [800 :ring-2-e 120]
125 [1310 :middle-3-f 0] 138 [800 :ring-1-e 140]
126 139
140 [800 :middle-3-e 120]
141 [800 :middle-2-e 120]
142 [800 :middle-1-e 30]
143
144 [800 :pointer-3-e 120]
145 [800 :pointer-2-e 120]
146 [800 :pointer-1-e 30]
147
148 [870 :pinky-3-e 0]
149 [870 :pinky-2-e 0]
150 [870 :pinky-1-e 0]
151
152 [870 :ring-3-e 0]
153 [870 :ring-2-e 0]
154 [870 :ring-1-e 0]
155
156 [870 :middle-3-e 0]
157 [870 :middle-2-e 0]
158 [870 :middle-1-e 0]
159
160 [870 :pointer-3-e 0]
161 [870 :pointer-2-e 0]
162 [870 :pointer-1-e 0]
163
164 [1500 :pointer-1-f full]
165 [1500 :pointer-2-f full]
166 [1500 :pointer-3-f full]
127 167
128 168 [1500 :middle-1-f full]
169 [1500 :middle-2-f full]
170 [1500 :middle-3-f full]
171
172 [1510 :pointer-1-f 0]
173 [1510 :pointer-2-f 0]
174 [1510 :pointer-3-f 0]
175
176 [1510 :middle-1-f 0]
177 [1510 :middle-2-f 0]
178 [1510 :middle-3-f 0]
129 ]) 179 ])
130 180
131 (defn gen-summon-ball [] 181 (defn gen-summon-ball [debug?]
132 (let [wait (atom 20)] 182 (let [wait (atom 1100)]
133 (fn [world] 183 (fn [world]
134 (if (= 0 (swap! wait dec)) 184 (if (= 0 (swap! wait dec))
135 (let [brick 185 (let [brick
136 (box 0.8 0.8 0.8 :mass 0.05 186 (box 0.8 0.8 0.8 :mass 0.05
137 :position (Vector3f. 0 0 0.5) 187 :position (Vector3f. -0.5 0 0.5)
138 :color (ColorRGBA/Red))] 188 :color (ColorRGBA/Red))
139 189 bell (AudioNode. (asset-manager)
140 (.addControl 190 "Sounds/pure.wav" false)]
141 brick 191 (.play bell)
142 (proxy [AbstractControl] [] 192 (if debug?
143 (controlUpdate [tpf] 193 (.addControl
144 (println-repl (.getWorldTranslation brick))) 194 brick
145 (controlRender [_ _]))) 195 (proxy [AbstractControl] []
196 (controlUpdate [tpf]
197 (println-repl (.getWorldTranslation brick)))
198 (controlRender [_ _]))))
146 (add-element world brick)))))) 199 (add-element world brick))))))
147 200
148 201
149 (def control-list 202 (def control-list
150 [ 203 [
156 0 ;;pointer-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 209 0 ;;pointer-11 #<Vector3f (-0.99999994, 0.0, 0.0)>
157 0 ;;thumb-2.0011 #<Vector3f (-0.71705645, -0.44753736, -0.5343599)> 210 0 ;;thumb-2.0011 #<Vector3f (-0.71705645, -0.44753736, -0.5343599)>
158 0 ;;thumb-2.0011 #<Vector3f (-0.10567085, 0.83862597, 0.53435963)> 211 0 ;;thumb-2.0011 #<Vector3f (-0.10567085, 0.83862597, 0.53435963)>
159 0 ;;middle-11 #<Vector3f (0.99999994, 0.0, 0.0)> 212 0 ;;middle-11 #<Vector3f (0.99999994, 0.0, 0.0)>
160 0 ;;middle-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 213 0 ;;middle-11 #<Vector3f (-0.99999994, 0.0, 0.0)>
161 1 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 214 0 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)>
162 0 ;;pointer-31 #<Vector3f (0.99999994, 0.0, 0.0)> 215 0 ;;pointer-31 #<Vector3f (0.99999994, 0.0, 0.0)>
163 0 ;;middle-21 #<Vector3f (0.99999994, 0.0, 0.0)> 216 0 ;;middle-21 #<Vector3f (0.99999994, 0.0, 0.0)>
164 0 ;;middle-21 #<Vector3f (-0.99999994, 0.0, 0.0)> 217 0 ;;middle-21 #<Vector3f (-0.99999994, 0.0, 0.0)>
165 0 ;;middle-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 218 0 ;;middle-31 #<Vector3f (-0.99999994, 0.0, 0.0)>
166 0 ;;middle-31 #<Vector3f (0.99999994, 0.0, 0.0)> 219 0 ;;middle-31 #<Vector3f (0.99999994, 0.0, 0.0)>
178 0 ;;thumb-11 #<Vector3f (-0.8032993, -0.2722854, -0.5296895)> 231 0 ;;thumb-11 #<Vector3f (-0.8032993, -0.2722854, -0.5296895)>
179 0 ;;pinky-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 232 0 ;;pinky-11 #<Vector3f (-0.99999994, 0.0, 0.0)>
180 0 ;;pinky-11 #<Vector3f (0.99999994, 0.0, 0.0)> 233 0 ;;pinky-11 #<Vector3f (0.99999994, 0.0, 0.0)>
181 ]) 234 ])
182 235
236 (import com.aurellem.capture.Capture)
237
183 (defn test-everything! 238 (defn test-everything!
184 ([] (test-everything! false)) 239 ([] (test-everything! false))
185 ([record?] 240 ([record?]
186 (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 241 (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
187 242
188 bell (AudioNode. (asset-manager) 243 base (File. "/home/r/proj/cortex/render/hand")
189 "Sounds/pure.wav" false) 244
245
190 creature (doto (load-blender-model hand) 246 creature (doto (load-blender-model hand)
191 (body!)) 247 (body!))
192 248
193 summon-ball (gen-summon-ball) 249 summon-ball (gen-summon-ball false)
194 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;; 250 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
195 ;;touch (touch! creature) 251 touch (touch! creature)
196 ;;touch-display (view-touch) 252 touch-display (view-touch)
197 253
198 ;;vision (vision! creature) 254 vision (vision! creature)
199 ;;vision-display (view-vision) 255 vision-display (view-vision)
200 256
201 ;;hearing (hearing! creature) 257 hearing (hearing! creature)
202 ;;hearing-display (view-hearing) 258 hearing-display (view-hearing)
203 259
204 prop (proprioception! creature) 260 prop (proprioception! creature)
205 prop-display (view-proprioception) 261 prop-display (view-proprioception)
206 262
207 control-script (motor-control-program 263 control-script (motor-control-program
214 (world 270 (world
215 (nodify [creature 271 (nodify [creature
216 (box 10 2 10 :position (Vector3f. 0 -9 0) 272 (box 10 2 10 :position (Vector3f. 0 -9 0)
217 :color ColorRGBA/Gray :mass 0) 273 :color ColorRGBA/Gray :mass 0)
218 me]) 274 me])
219 (merge standard-debug-controls 275 standard-debug-controls
220 {"key-return" 276
221 (fn [_ value]
222 (if value
223 (.play bell)))})
224
225 (fn [world] 277 (fn [world]
226 (.setTimer world (RatchetTimer. 60)) 278 (.setTimer world (RatchetTimer. 60))
227 (position-camera 279 (position-camera
228 world (Vector3f. 7.7101235, 6.3628435, -14.15047) 280 world (Vector3f. -0.13217318, 5.816415, -5.3089414)
229 (Quaternion. 0.3644328, -0.2558489, 0.104854375, 0.8892332)) 281 (Quaternion. 0.55685693, 0.0042774677, -0.0028673497, 0.83059245))
282
230 (light-up-everything world) 283 (light-up-everything world)
231 (enable-debug world) 284 (enable-debug world)
232 (add-camera! world 285 (add-camera! world
233 (add-eye! creature 286 (add-eye! creature
234 (.getChild 287 (.getChild
235 (.getChild creature "eyes") "eye")) 288 (.getChild creature "eyes") "eye"))
236 (comp (view-image) BufferedImage!)) 289 (comp (view-image) BufferedImage!))
237 (speed-up world) 290
238 ) 291 (if record?
292 (Capture/captureVideo
293 world (File. base "main")))
294 (if record?
295 (Capture/captureAudio
296 world (File. base "main.wav"))))
239 (fn [world tpf] 297 (fn [world tpf]
240 ;;(prop-display (prop)) 298 (prop-display
241 ;;(touch-display (map #(% (.getRootNode world)) touch)) 299 (prop)
242 ;;(vision-display (map #(% world) vision)) 300 (if record? (File. base "proprio")))
243 ;;(hearing-display (map #(% world) hearing)) 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")))
313
244 (summon-ball world) 314 (summon-ball world)
245 ;;(muscle-display 315
246 (control-script muscles)
247 ;;)
248
249 (.setLocalTranslation me (.getLocation (.getCamera world))) 316 (.setLocalTranslation me (.getLocation (.getCamera world)))
250 (fix-display world)))))) 317 (fix-display world))))))
318
319
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
336
337
338 ;; list of vision targets
339 0 :all
340 1 :green
341 2 :blue
342 3 :red
343
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
359
360
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 )
393
394
395
396 ;; rotate touch 180
397
398 ;; rotate mucles 90 counter-clockwise
399 ;; scale muscles to 15x60
400
401 finger width : 113
402 finger height : 357
403
404 thumb width : 113
405
406 pinky --- 0,195
407 ring --- 111,100
408 middle --- 228,0
409 pointer -- 436,96
410 thumb --- 486,420
411
412
413
414 within a finger (coordinates of top left corner (x,y)):
415
416 tip-flexor : 0,7
417 tip-extensor : 98,7
418 tip : 18,0
419
420 joint-2-3 : 32,79
421
422 mid-flexor : 19,131
423 mid-extensor : 80,131
424 mid : 30,133
425
426 joint-1-2 : 32,193
427
428 base-flexor : 19,245
429 base-extensor : 80,245
430 base : 39,247
431
432 joint-palm-1 : 32,307
433
434
435 Thumb is the same as finger, except it has two more pieces
436
437 extra-flexor-1 : 2,131
438 extra-flexor-2 : 100,131
439
440 ;; rotate entire thumb 45 degrees clockwise
441
442 within vision
443 gray -- 165,577
444 green -- 278,577
445 blue -- 165,682
446 red -- 278,682
447
448 entire hand : 809, 22
449 main view : 78,202
450 hearing : 784,819
451
452 hand-size: 688x769
453
454
455 total image size:
456 1600x894
457
458 (def base (File. "/home/r/proj/cortex/render/hand"))
459
460
461
462 (defn prepare-muscle [muscle]
463 ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"])
464
465 (defn prepare-touch [touch]
466 ["(" touch "-rotate" "180" ")"])
467
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"
477
478 joint-2-3 "-geometry" "+32+79" "-composite"
479
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"
483
484 joint-1-2 "-geometry" "+32+193" "-composite"
485 ")"])
486
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 ")"])
506
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 ")"])
522
523 pinky --- 0,195
524 ring --- 111,100
525 middle --- 228,0
526 pointer -- 436,96
527 thumb --- 486,420
528
529
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 ")"])
550
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 ")"])
560
561
562
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"))
570
571
572 (def test-target (File. base "output.png"))
573
574 (def background (File. base "background.png"))
575
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]]
591
592
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"
604
605 (generate-vision vision vision vision vision)
606 "-geometry" "+974+599" "-composite"
607
608 hearing
609 "-geometry" "+784+819" "-composite"
610
611 main
612 "-geometry" "+78+202" "-composite"
613
614 (.getCanonicalPath test-target)]))))
615
616
617
618
619
620
251 #+end_src 621 #+end_src
252 622
253 #+results: integration 623 #+results: integration
254 : #'cortex.integration/test-everything! 624 : #'cortex.integration/test-everything!
255 625