Mercurial > cortex
diff 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 diff
1.1 --- a/org/integration.org Thu Feb 16 12:48:51 2012 -0700 1.2 +++ b/org/integration.org Thu Feb 16 20:05:54 2012 -0700 1.3 @@ -96,53 +96,106 @@ 1.4 (def full 9001) 1.5 ;; the systax here is [keyframe body-part force] 1.6 (def wiggle-each-finger-tip 1.7 - [[300 :pointer-3-f 50] 1.8 + [[300 :pinky-3-f 50] 1.9 + [320 :pinky-2-f 80] 1.10 + [340 :pinky-1-f 100] 1.11 1.12 + [310 :ring-3-f 100] 1.13 + [330 :ring-2-f 120] 1.14 + [350 :ring-1-f 140] 1.15 1.16 - [400 :middle-3-f full] 1.17 - [401 :middle-3-f 50] 1.18 + [330 :middle-3-f 120] 1.19 + [340 :middle-2-f 120] 1.20 + [360 :middle-1-f 30] 1.21 1.22 - [600 :ring-3-f full] 1.23 - [601 :ring-3-f 40] 1.24 + [350 :pointer-3-f 120] 1.25 + [360 :pointer-2-f 120] 1.26 + [380 :pointer-1-f 30] 1.27 1.28 - [800 :pinky-3-f full] 1.29 - [801 :pinky-3-f 50] 1.30 + [800 :pinky-3-f 0] 1.31 + [800 :pinky-2-f 0] 1.32 + [800 :pinky-1-f 0] 1.33 1.34 - [1300 :pointer-1-f full] 1.35 - [1300 :pointer-2-f full] 1.36 - [1300 :pointer-3-f 0] 1.37 + [800 :ring-3-f 0] 1.38 + [800 :ring-2-f 0] 1.39 + [800 :ring-1-f 0] 1.40 1.41 - [1289 :middle-1-f full] 1.42 - [1289 :middle-2-f full] 1.43 - [1289 :middle-3-f 0] 1.44 - 1.45 - [1310 :pointer-1-f 0] 1.46 - [1310 :pointer-2-f 0] 1.47 - [1310 :pointer-3-f 0] 1.48 + [800 :middle-3-f 0] 1.49 + [800 :middle-2-f 0] 1.50 + [800 :middle-1-f 0] 1.51 1.52 - [1310 :middle-1-f 0] 1.53 - [1310 :middle-2-f 0] 1.54 - [1310 :middle-3-f 0] 1.55 + [800 :pointer-3-f 0] 1.56 + [800 :pointer-2-f 0] 1.57 + [800 :pointer-1-f 0] 1.58 1.59 1.60 + [800 :pinky-3-e 50] 1.61 + [800 :pinky-2-e 80] 1.62 + [800 :pinky-1-e 100] 1.63 1.64 + [800 :ring-3-e 100] 1.65 + [800 :ring-2-e 120] 1.66 + [800 :ring-1-e 140] 1.67 + 1.68 + [800 :middle-3-e 120] 1.69 + [800 :middle-2-e 120] 1.70 + [800 :middle-1-e 30] 1.71 + 1.72 + [800 :pointer-3-e 120] 1.73 + [800 :pointer-2-e 120] 1.74 + [800 :pointer-1-e 30] 1.75 + 1.76 + [870 :pinky-3-e 0] 1.77 + [870 :pinky-2-e 0] 1.78 + [870 :pinky-1-e 0] 1.79 + 1.80 + [870 :ring-3-e 0] 1.81 + [870 :ring-2-e 0] 1.82 + [870 :ring-1-e 0] 1.83 + 1.84 + [870 :middle-3-e 0] 1.85 + [870 :middle-2-e 0] 1.86 + [870 :middle-1-e 0] 1.87 + 1.88 + [870 :pointer-3-e 0] 1.89 + [870 :pointer-2-e 0] 1.90 + [870 :pointer-1-e 0] 1.91 + 1.92 + [1500 :pointer-1-f full] 1.93 + [1500 :pointer-2-f full] 1.94 + [1500 :pointer-3-f full] 1.95 + 1.96 + [1500 :middle-1-f full] 1.97 + [1500 :middle-2-f full] 1.98 + [1500 :middle-3-f full] 1.99 + 1.100 + [1510 :pointer-1-f 0] 1.101 + [1510 :pointer-2-f 0] 1.102 + [1510 :pointer-3-f 0] 1.103 + 1.104 + [1510 :middle-1-f 0] 1.105 + [1510 :middle-2-f 0] 1.106 + [1510 :middle-3-f 0] 1.107 ]) 1.108 1.109 -(defn gen-summon-ball [] 1.110 - (let [wait (atom 20)] 1.111 +(defn gen-summon-ball [debug?] 1.112 + (let [wait (atom 1100)] 1.113 (fn [world] 1.114 (if (= 0 (swap! wait dec)) 1.115 (let [brick 1.116 (box 0.8 0.8 0.8 :mass 0.05 1.117 - :position (Vector3f. 0 0 0.5) 1.118 - :color (ColorRGBA/Red))] 1.119 - 1.120 - (.addControl 1.121 - brick 1.122 - (proxy [AbstractControl] [] 1.123 - (controlUpdate [tpf] 1.124 - (println-repl (.getWorldTranslation brick))) 1.125 - (controlRender [_ _]))) 1.126 + :position (Vector3f. -0.5 0 0.5) 1.127 + :color (ColorRGBA/Red)) 1.128 + bell (AudioNode. (asset-manager) 1.129 + "Sounds/pure.wav" false)] 1.130 + (.play bell) 1.131 + (if debug? 1.132 + (.addControl 1.133 + brick 1.134 + (proxy [AbstractControl] [] 1.135 + (controlUpdate [tpf] 1.136 + (println-repl (.getWorldTranslation brick))) 1.137 + (controlRender [_ _])))) 1.138 (add-element world brick)))))) 1.139 1.140 1.141 @@ -158,7 +211,7 @@ 1.142 0 ;;thumb-2.0011 #<Vector3f (-0.10567085, 0.83862597, 0.53435963)> 1.143 0 ;;middle-11 #<Vector3f (0.99999994, 0.0, 0.0)> 1.144 0 ;;middle-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.145 - 1 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.146 + 0 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.147 0 ;;pointer-31 #<Vector3f (0.99999994, 0.0, 0.0)> 1.148 0 ;;middle-21 #<Vector3f (0.99999994, 0.0, 0.0)> 1.149 0 ;;middle-21 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.150 @@ -180,26 +233,29 @@ 1.151 0 ;;pinky-11 #<Vector3f (0.99999994, 0.0, 0.0)> 1.152 ]) 1.153 1.154 +(import com.aurellem.capture.Capture) 1.155 + 1.156 (defn test-everything! 1.157 ([] (test-everything! false)) 1.158 ([record?] 1.159 (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 1.160 1.161 - bell (AudioNode. (asset-manager) 1.162 - "Sounds/pure.wav" false) 1.163 + base (File. "/home/r/proj/cortex/render/hand") 1.164 + 1.165 + 1.166 creature (doto (load-blender-model hand) 1.167 (body!)) 1.168 1.169 - summon-ball (gen-summon-ball) 1.170 + summon-ball (gen-summon-ball false) 1.171 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.172 - ;;touch (touch! creature) 1.173 - ;;touch-display (view-touch) 1.174 + touch (touch! creature) 1.175 + touch-display (view-touch) 1.176 1.177 - ;;vision (vision! creature) 1.178 - ;;vision-display (view-vision) 1.179 + vision (vision! creature) 1.180 + vision-display (view-vision) 1.181 1.182 - ;;hearing (hearing! creature) 1.183 - ;;hearing-display (view-hearing) 1.184 + hearing (hearing! creature) 1.185 + hearing-display (view-hearing) 1.186 1.187 prop (proprioception! creature) 1.188 prop-display (view-proprioception) 1.189 @@ -216,17 +272,14 @@ 1.190 (box 10 2 10 :position (Vector3f. 0 -9 0) 1.191 :color ColorRGBA/Gray :mass 0) 1.192 me]) 1.193 - (merge standard-debug-controls 1.194 - {"key-return" 1.195 - (fn [_ value] 1.196 - (if value 1.197 - (.play bell)))}) 1.198 - 1.199 + standard-debug-controls 1.200 + 1.201 (fn [world] 1.202 (.setTimer world (RatchetTimer. 60)) 1.203 (position-camera 1.204 - world (Vector3f. 7.7101235, 6.3628435, -14.15047) 1.205 - (Quaternion. 0.3644328, -0.2558489, 0.104854375, 0.8892332)) 1.206 + world (Vector3f. -0.13217318, 5.816415, -5.3089414) 1.207 + (Quaternion. 0.55685693, 0.0042774677, -0.0028673497, 0.83059245)) 1.208 + 1.209 (light-up-everything world) 1.210 (enable-debug world) 1.211 (add-camera! world 1.212 @@ -234,20 +287,337 @@ 1.213 (.getChild 1.214 (.getChild creature "eyes") "eye")) 1.215 (comp (view-image) BufferedImage!)) 1.216 - (speed-up world) 1.217 - ) 1.218 + 1.219 + (if record? 1.220 + (Capture/captureVideo 1.221 + world (File. base "main"))) 1.222 + (if record? 1.223 + (Capture/captureAudio 1.224 + world (File. base "main.wav")))) 1.225 (fn [world tpf] 1.226 - ;;(prop-display (prop)) 1.227 - ;;(touch-display (map #(% (.getRootNode world)) touch)) 1.228 - ;;(vision-display (map #(% world) vision)) 1.229 - ;;(hearing-display (map #(% world) hearing)) 1.230 + (prop-display 1.231 + (prop) 1.232 + (if record? (File. base "proprio"))) 1.233 + (touch-display 1.234 + (map #(% (.getRootNode world)) touch) 1.235 + (if record? (File. base "touch"))) 1.236 + (vision-display 1.237 + (map #(% world) vision) 1.238 + (if record? (File. base "vision"))) 1.239 + (hearing-display 1.240 + (map #(% world) hearing) 1.241 + (if record? (File. base "hearing"))) 1.242 + (muscle-display 1.243 + (control-script muscles) 1.244 + (if record? (File. base "muscle"))) 1.245 + 1.246 (summon-ball world) 1.247 - ;;(muscle-display 1.248 - (control-script muscles) 1.249 - ;;) 1.250 - 1.251 + 1.252 (.setLocalTranslation me (.getLocation (.getCamera world))) 1.253 (fix-display world)))))) 1.254 + 1.255 + 1.256 +(comment 1.257 +;; list of touch targets 1.258 +0 middle-11 1.259 +1 middle-21 1.260 +2 middle-31 1.261 +3 pinky-11 1.262 +4 pinky-21 1.263 +5 pinky-31 1.264 +6 pointer-11 1.265 +7 pointer-21 1.266 +8 pointer-31 1.267 +9 ring-11 1.268 +10 ring-21 1.269 +11 ring-31 1.270 +12 thumb-11 1.271 +13 thumb-2.0011 1.272 + 1.273 + 1.274 +;; list of vision targets 1.275 +0 :all 1.276 +1 :green 1.277 +2 :blue 1.278 +3 :red 1.279 + 1.280 +;; list of proprio targets 1.281 +0 middle-11 -> middle-21 1.282 +1 middle-21 -> middle-31 1.283 +2 thumb-11 -> thumb-2.0011 1.284 +3 pointer-11 -> pointer-21 1.285 +4 pointer-21 -> pointer-31 1.286 +5 ring-21 -> ring-31 1.287 +6 ring-11 -> ring-21 1.288 +7 pinky-21 -> pinky-31 1.289 +8 pinky-11 -> pinky-21 1.290 +9 middle-11 -> palm1 1.291 +10 pinky-11 -> palm1 1.292 +11 palm1 -> pointer-11 1.293 +12 palm1 -> ring-11 1.294 +13 palm1 -> thumb-11 1.295 + 1.296 + 1.297 +;; list of muscle targets 1.298 +0 :pointer-2-e 1.299 +1 :pointer-2-f 1.300 +2 :thumb-1 1.301 +3 :thumb-1 1.302 +4 :pointer-1-e 1.303 +5 :pointer-1-f 1.304 +6 :thumb-2-e 1.305 +7 :thumb-2-f 1.306 +8 :middle-1-e 1.307 +9 :middle-1-f 1.308 +10 :pointer-3-f 1.309 +11 :pointer-3-e 1.310 +12 :middle-2-e 1.311 +13 :middle-2-f 1.312 +14 :middle-3-f 1.313 +15 :middle-3-e 1.314 +16 :pinky-2-e 1.315 +17 :pinky-2-f 1.316 +18 :pinky-3-f 1.317 +19 :pinky-3-e 1.318 +20 :ring-3-e 1.319 +21 :ring-3-f 1.320 +22 :ring-2-f 1.321 +23 :ring-2-e 1.322 +24 :ring-1-e 1.323 +25 :ring-1-f 1.324 +26 :thumb-1-e 1.325 +27 :thumb-1-f 1.326 +28 :pinky-1-f 1.327 +29 :pinky-1-e 1.328 +) 1.329 + 1.330 + 1.331 + 1.332 +;; rotate touch 180 1.333 + 1.334 +;; rotate mucles 90 counter-clockwise 1.335 +;; scale muscles to 15x60 1.336 + 1.337 +finger width : 113 1.338 +finger height : 357 1.339 + 1.340 +thumb width : 113 1.341 + 1.342 +pinky --- 0,195 1.343 +ring --- 111,100 1.344 +middle --- 228,0 1.345 +pointer -- 436,96 1.346 +thumb --- 486,420 1.347 + 1.348 + 1.349 + 1.350 +within a finger (coordinates of top left corner (x,y)): 1.351 + 1.352 +tip-flexor : 0,7 1.353 +tip-extensor : 98,7 1.354 +tip : 18,0 1.355 + 1.356 +joint-2-3 : 32,79 1.357 + 1.358 +mid-flexor : 19,131 1.359 +mid-extensor : 80,131 1.360 +mid : 30,133 1.361 + 1.362 +joint-1-2 : 32,193 1.363 + 1.364 +base-flexor : 19,245 1.365 +base-extensor : 80,245 1.366 +base : 39,247 1.367 + 1.368 +joint-palm-1 : 32,307 1.369 + 1.370 + 1.371 +Thumb is the same as finger, except it has two more pieces 1.372 + 1.373 +extra-flexor-1 : 2,131 1.374 +extra-flexor-2 : 100,131 1.375 + 1.376 +;; rotate entire thumb 45 degrees clockwise 1.377 + 1.378 +within vision 1.379 +gray -- 165,577 1.380 +green -- 278,577 1.381 +blue -- 165,682 1.382 +red -- 278,682 1.383 + 1.384 +entire hand : 809, 22 1.385 +main view : 78,202 1.386 +hearing : 784,819 1.387 + 1.388 +hand-size: 688x769 1.389 + 1.390 + 1.391 +total image size: 1.392 +1600x894 1.393 + 1.394 +(def base (File. "/home/r/proj/cortex/render/hand")) 1.395 + 1.396 + 1.397 + 1.398 +(defn prepare-muscle [muscle] 1.399 + ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"]) 1.400 + 1.401 +(defn prepare-touch [touch] 1.402 + ["(" touch "-rotate" "180" ")"]) 1.403 + 1.404 +(defn generate-top-finger [tip-flexor tip-extensor tip 1.405 + joint-2-3 1.406 + mid-flexor mid-extensor mid 1.407 + joint-1-2] 1.408 + ["(" 1.409 + "-size" "113x357" "xc:transparent" 1.410 + (prepare-muscle tip-flexor) "-geometry" "+0+7" "-composite" 1.411 + (prepare-muscle tip-extensor) "-geometry" "+98+7" "-composite" 1.412 + (prepare-touch tip) "-geometry" "+18+0" "-composite" 1.413 + 1.414 + joint-2-3 "-geometry" "+32+79" "-composite" 1.415 + 1.416 + (prepare-muscle mid-flexor) "-geometry" "+19+131" "-composite" 1.417 + (prepare-muscle mid-extensor) "-geometry" "+80+131" "-composite" 1.418 + (prepare-touch mid) "-geometry" "+39+133" "-composite" 1.419 + 1.420 + joint-1-2 "-geometry" "+32+193" "-composite" 1.421 + ")"]) 1.422 + 1.423 +(defn generate-finger 1.424 + [tip-flexor tip-extensor tip 1.425 + joint-2-3 1.426 + mid-flexor mid-extensor mid 1.427 + joint-1-2 1.428 + base-flexor base-extensor base 1.429 + joint-palm-1] 1.430 + ["(" 1.431 + "-size" "113x357" "xc:transparent" 1.432 + (generate-top-finger 1.433 + tip-flexor tip-extensor tip 1.434 + joint-2-3 1.435 + mid-flexor mid-extensor mid 1.436 + joint-1-2) "-geometry" "+0+0" "-composite" 1.437 + (prepare-muscle base-flexor) "-geometry" "+19+245" "-composite" 1.438 + (prepare-muscle base-extensor) "-geometry" "+80+245" "-composite" 1.439 + (prepare-touch base) "-geometry" "+39+247" "-composite" 1.440 + joint-palm-1 "-geometry" "+32+307" "-composite" 1.441 + ")"]) 1.442 + 1.443 +(defn generate-thumb 1.444 + [tip-flexor tip-extensor tip 1.445 + joint-1-2 1.446 + mid-flexor mid-extensor mid-flexor-2 mid-extensor-2 mid 1.447 + joint-palm-1] 1.448 + ["(" 1.449 + "-size" "113x357" "xc:transparent" 1.450 + (generate-top-finger 1.451 + tip-flexor tip-extensor tip 1.452 + joint-1-2 1.453 + mid-flexor mid-extensor mid 1.454 + joint-palm-1) "-geometry" "+0+0" "-composite" 1.455 + (prepare-muscle mid-flexor-2) "-geometry" "+2+131" "-composite" 1.456 + (prepare-muscle mid-extensor-2) "-geometry" "+100+131" "-composite" 1.457 + ")"]) 1.458 + 1.459 +pinky --- 0,195 1.460 +ring --- 111,100 1.461 +middle --- 228,0 1.462 +pointer -- 436,96 1.463 +thumb --- 486,420 1.464 + 1.465 + 1.466 +(defn generate-hand 1.467 + [pinky-pieces 1.468 + ring-pieces 1.469 + middle-pieces 1.470 + pointer-pieces 1.471 + thumb-pieces] 1.472 + ["(" 1.473 + "-size" "688x769" "xc:transparent" 1.474 + (apply generate-finger pinky-pieces) 1.475 + "-geometry" "+0+195" "-composite" 1.476 + (apply generate-finger ring-pieces) 1.477 + "-geometry" "+111+100" "-composite" 1.478 + (apply generate-finger middle-pieces) 1.479 + "-geometry" "+228+0" "-composite" 1.480 + "(" (apply generate-thumb thumb-pieces) "-background" "#00000000" 1.481 + "-rotate" "45" ")" 1.482 + "-geometry" "+300+420" "-composite" 1.483 + (apply generate-finger pointer-pieces) 1.484 + "-geometry" "+350+96" "-composite" 1.485 + ")"]) 1.486 + 1.487 +(defn generate-vision 1.488 + [all green blue red] 1.489 + ["(" 1.490 + "-size" "204x192" "xc:transparent" 1.491 + all "-geometry" "+0+0" "-composite" 1.492 + green "-geometry" "+113+0" "-composite" 1.493 + blue "-geometry" "+0+105" "-composite" 1.494 + red "-geometry" "+113+105" "-composite" 1.495 + ")"]) 1.496 + 1.497 + 1.498 + 1.499 +(def test-muscle (File. base "muscle/0/0000000.png")) 1.500 +(def test-proprio (File. base "proprio/0/0000000.png")) 1.501 +(def test-tip (File. base "touch/2/0000000.png")) 1.502 +(def test-mid (File. base "touch/0/0000000.png")) 1.503 +(def test-vision (File. base "vision/0/0000000.png")) 1.504 +(def test-hearing (File. base "hearing/0/0000000.png")) 1.505 +(def test-main (File. base "main/0000000.png")) 1.506 + 1.507 + 1.508 +(def test-target (File. base "output.png")) 1.509 + 1.510 +(def background (File. base "background.png")) 1.511 + 1.512 +(use 'clojure.contrib.shell-out) 1.513 +(defn final-image [muscle proprio tip mid vision hearing main] 1.514 + (let [[muscle proprio tip mid vision hearing main] (map #(.getCanonicalPath %) 1.515 + [muscle proprio tip mid vision 1.516 + hearing main]) 1.517 + finger-pieces [muscle muscle tip 1.518 + proprio 1.519 + muscle muscle mid 1.520 + proprio 1.521 + muscle muscle mid 1.522 + proprio] 1.523 + thumb-pieces [muscle muscle tip 1.524 + proprio 1.525 + muscle muscle muscle muscle mid 1.526 + proprio]] 1.527 + 1.528 + 1.529 + (apply 1.530 + sh 1.531 + (flatten 1.532 + ["convert" 1.533 + (.getCanonicalPath background) 1.534 + (generate-hand finger-pieces 1.535 + finger-pieces 1.536 + finger-pieces 1.537 + finger-pieces 1.538 + thumb-pieces) 1.539 + "-geometry" "+809+22" "-composite" 1.540 + 1.541 + (generate-vision vision vision vision vision) 1.542 + "-geometry" "+974+599" "-composite" 1.543 + 1.544 + hearing 1.545 + "-geometry" "+784+819" "-composite" 1.546 + 1.547 + main 1.548 + "-geometry" "+78+202" "-composite" 1.549 + 1.550 + (.getCanonicalPath test-target)])))) 1.551 + 1.552 + 1.553 + 1.554 + 1.555 + 1.556 + 1.557 #+end_src 1.558 1.559 #+results: integration