Mercurial > cortex
changeset 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 |
files | assets/Models/test-creature/hand.blend org/integration.org |
diffstat | 2 files changed, 429 insertions(+), 59 deletions(-) [+] |
line wrap: on
line diff
1.1 Binary file assets/Models/test-creature/hand.blend has changed
2.1 --- a/org/integration.org Thu Feb 16 12:48:51 2012 -0700 2.2 +++ b/org/integration.org Thu Feb 16 20:05:54 2012 -0700 2.3 @@ -96,53 +96,106 @@ 2.4 (def full 9001) 2.5 ;; the systax here is [keyframe body-part force] 2.6 (def wiggle-each-finger-tip 2.7 - [[300 :pointer-3-f 50] 2.8 + [[300 :pinky-3-f 50] 2.9 + [320 :pinky-2-f 80] 2.10 + [340 :pinky-1-f 100] 2.11 2.12 + [310 :ring-3-f 100] 2.13 + [330 :ring-2-f 120] 2.14 + [350 :ring-1-f 140] 2.15 2.16 - [400 :middle-3-f full] 2.17 - [401 :middle-3-f 50] 2.18 + [330 :middle-3-f 120] 2.19 + [340 :middle-2-f 120] 2.20 + [360 :middle-1-f 30] 2.21 2.22 - [600 :ring-3-f full] 2.23 - [601 :ring-3-f 40] 2.24 + [350 :pointer-3-f 120] 2.25 + [360 :pointer-2-f 120] 2.26 + [380 :pointer-1-f 30] 2.27 2.28 - [800 :pinky-3-f full] 2.29 - [801 :pinky-3-f 50] 2.30 + [800 :pinky-3-f 0] 2.31 + [800 :pinky-2-f 0] 2.32 + [800 :pinky-1-f 0] 2.33 2.34 - [1300 :pointer-1-f full] 2.35 - [1300 :pointer-2-f full] 2.36 - [1300 :pointer-3-f 0] 2.37 + [800 :ring-3-f 0] 2.38 + [800 :ring-2-f 0] 2.39 + [800 :ring-1-f 0] 2.40 2.41 - [1289 :middle-1-f full] 2.42 - [1289 :middle-2-f full] 2.43 - [1289 :middle-3-f 0] 2.44 - 2.45 - [1310 :pointer-1-f 0] 2.46 - [1310 :pointer-2-f 0] 2.47 - [1310 :pointer-3-f 0] 2.48 + [800 :middle-3-f 0] 2.49 + [800 :middle-2-f 0] 2.50 + [800 :middle-1-f 0] 2.51 2.52 - [1310 :middle-1-f 0] 2.53 - [1310 :middle-2-f 0] 2.54 - [1310 :middle-3-f 0] 2.55 + [800 :pointer-3-f 0] 2.56 + [800 :pointer-2-f 0] 2.57 + [800 :pointer-1-f 0] 2.58 2.59 2.60 + [800 :pinky-3-e 50] 2.61 + [800 :pinky-2-e 80] 2.62 + [800 :pinky-1-e 100] 2.63 2.64 + [800 :ring-3-e 100] 2.65 + [800 :ring-2-e 120] 2.66 + [800 :ring-1-e 140] 2.67 + 2.68 + [800 :middle-3-e 120] 2.69 + [800 :middle-2-e 120] 2.70 + [800 :middle-1-e 30] 2.71 + 2.72 + [800 :pointer-3-e 120] 2.73 + [800 :pointer-2-e 120] 2.74 + [800 :pointer-1-e 30] 2.75 + 2.76 + [870 :pinky-3-e 0] 2.77 + [870 :pinky-2-e 0] 2.78 + [870 :pinky-1-e 0] 2.79 + 2.80 + [870 :ring-3-e 0] 2.81 + [870 :ring-2-e 0] 2.82 + [870 :ring-1-e 0] 2.83 + 2.84 + [870 :middle-3-e 0] 2.85 + [870 :middle-2-e 0] 2.86 + [870 :middle-1-e 0] 2.87 + 2.88 + [870 :pointer-3-e 0] 2.89 + [870 :pointer-2-e 0] 2.90 + [870 :pointer-1-e 0] 2.91 + 2.92 + [1500 :pointer-1-f full] 2.93 + [1500 :pointer-2-f full] 2.94 + [1500 :pointer-3-f full] 2.95 + 2.96 + [1500 :middle-1-f full] 2.97 + [1500 :middle-2-f full] 2.98 + [1500 :middle-3-f full] 2.99 + 2.100 + [1510 :pointer-1-f 0] 2.101 + [1510 :pointer-2-f 0] 2.102 + [1510 :pointer-3-f 0] 2.103 + 2.104 + [1510 :middle-1-f 0] 2.105 + [1510 :middle-2-f 0] 2.106 + [1510 :middle-3-f 0] 2.107 ]) 2.108 2.109 -(defn gen-summon-ball [] 2.110 - (let [wait (atom 20)] 2.111 +(defn gen-summon-ball [debug?] 2.112 + (let [wait (atom 1100)] 2.113 (fn [world] 2.114 (if (= 0 (swap! wait dec)) 2.115 (let [brick 2.116 (box 0.8 0.8 0.8 :mass 0.05 2.117 - :position (Vector3f. 0 0 0.5) 2.118 - :color (ColorRGBA/Red))] 2.119 - 2.120 - (.addControl 2.121 - brick 2.122 - (proxy [AbstractControl] [] 2.123 - (controlUpdate [tpf] 2.124 - (println-repl (.getWorldTranslation brick))) 2.125 - (controlRender [_ _]))) 2.126 + :position (Vector3f. -0.5 0 0.5) 2.127 + :color (ColorRGBA/Red)) 2.128 + bell (AudioNode. (asset-manager) 2.129 + "Sounds/pure.wav" false)] 2.130 + (.play bell) 2.131 + (if debug? 2.132 + (.addControl 2.133 + brick 2.134 + (proxy [AbstractControl] [] 2.135 + (controlUpdate [tpf] 2.136 + (println-repl (.getWorldTranslation brick))) 2.137 + (controlRender [_ _])))) 2.138 (add-element world brick)))))) 2.139 2.140 2.141 @@ -158,7 +211,7 @@ 2.142 0 ;;thumb-2.0011 #<Vector3f (-0.10567085, 0.83862597, 0.53435963)> 2.143 0 ;;middle-11 #<Vector3f (0.99999994, 0.0, 0.0)> 2.144 0 ;;middle-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 2.145 - 1 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 2.146 + 0 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 2.147 0 ;;pointer-31 #<Vector3f (0.99999994, 0.0, 0.0)> 2.148 0 ;;middle-21 #<Vector3f (0.99999994, 0.0, 0.0)> 2.149 0 ;;middle-21 #<Vector3f (-0.99999994, 0.0, 0.0)> 2.150 @@ -180,26 +233,29 @@ 2.151 0 ;;pinky-11 #<Vector3f (0.99999994, 0.0, 0.0)> 2.152 ]) 2.153 2.154 +(import com.aurellem.capture.Capture) 2.155 + 2.156 (defn test-everything! 2.157 ([] (test-everything! false)) 2.158 ([record?] 2.159 (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 2.160 2.161 - bell (AudioNode. (asset-manager) 2.162 - "Sounds/pure.wav" false) 2.163 + base (File. "/home/r/proj/cortex/render/hand") 2.164 + 2.165 + 2.166 creature (doto (load-blender-model hand) 2.167 (body!)) 2.168 2.169 - summon-ball (gen-summon-ball) 2.170 + summon-ball (gen-summon-ball false) 2.171 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2.172 - ;;touch (touch! creature) 2.173 - ;;touch-display (view-touch) 2.174 + touch (touch! creature) 2.175 + touch-display (view-touch) 2.176 2.177 - ;;vision (vision! creature) 2.178 - ;;vision-display (view-vision) 2.179 + vision (vision! creature) 2.180 + vision-display (view-vision) 2.181 2.182 - ;;hearing (hearing! creature) 2.183 - ;;hearing-display (view-hearing) 2.184 + hearing (hearing! creature) 2.185 + hearing-display (view-hearing) 2.186 2.187 prop (proprioception! creature) 2.188 prop-display (view-proprioception) 2.189 @@ -216,17 +272,14 @@ 2.190 (box 10 2 10 :position (Vector3f. 0 -9 0) 2.191 :color ColorRGBA/Gray :mass 0) 2.192 me]) 2.193 - (merge standard-debug-controls 2.194 - {"key-return" 2.195 - (fn [_ value] 2.196 - (if value 2.197 - (.play bell)))}) 2.198 - 2.199 + standard-debug-controls 2.200 + 2.201 (fn [world] 2.202 (.setTimer world (RatchetTimer. 60)) 2.203 (position-camera 2.204 - world (Vector3f. 7.7101235, 6.3628435, -14.15047) 2.205 - (Quaternion. 0.3644328, -0.2558489, 0.104854375, 0.8892332)) 2.206 + world (Vector3f. -0.13217318, 5.816415, -5.3089414) 2.207 + (Quaternion. 0.55685693, 0.0042774677, -0.0028673497, 0.83059245)) 2.208 + 2.209 (light-up-everything world) 2.210 (enable-debug world) 2.211 (add-camera! world 2.212 @@ -234,20 +287,337 @@ 2.213 (.getChild 2.214 (.getChild creature "eyes") "eye")) 2.215 (comp (view-image) BufferedImage!)) 2.216 - (speed-up world) 2.217 - ) 2.218 + 2.219 + (if record? 2.220 + (Capture/captureVideo 2.221 + world (File. base "main"))) 2.222 + (if record? 2.223 + (Capture/captureAudio 2.224 + world (File. base "main.wav")))) 2.225 (fn [world tpf] 2.226 - ;;(prop-display (prop)) 2.227 - ;;(touch-display (map #(% (.getRootNode world)) touch)) 2.228 - ;;(vision-display (map #(% world) vision)) 2.229 - ;;(hearing-display (map #(% world) hearing)) 2.230 + (prop-display 2.231 + (prop) 2.232 + (if record? (File. base "proprio"))) 2.233 + (touch-display 2.234 + (map #(% (.getRootNode world)) touch) 2.235 + (if record? (File. base "touch"))) 2.236 + (vision-display 2.237 + (map #(% world) vision) 2.238 + (if record? (File. base "vision"))) 2.239 + (hearing-display 2.240 + (map #(% world) hearing) 2.241 + (if record? (File. base "hearing"))) 2.242 + (muscle-display 2.243 + (control-script muscles) 2.244 + (if record? (File. base "muscle"))) 2.245 + 2.246 (summon-ball world) 2.247 - ;;(muscle-display 2.248 - (control-script muscles) 2.249 - ;;) 2.250 - 2.251 + 2.252 (.setLocalTranslation me (.getLocation (.getCamera world))) 2.253 (fix-display world)))))) 2.254 + 2.255 + 2.256 +(comment 2.257 +;; list of touch targets 2.258 +0 middle-11 2.259 +1 middle-21 2.260 +2 middle-31 2.261 +3 pinky-11 2.262 +4 pinky-21 2.263 +5 pinky-31 2.264 +6 pointer-11 2.265 +7 pointer-21 2.266 +8 pointer-31 2.267 +9 ring-11 2.268 +10 ring-21 2.269 +11 ring-31 2.270 +12 thumb-11 2.271 +13 thumb-2.0011 2.272 + 2.273 + 2.274 +;; list of vision targets 2.275 +0 :all 2.276 +1 :green 2.277 +2 :blue 2.278 +3 :red 2.279 + 2.280 +;; list of proprio targets 2.281 +0 middle-11 -> middle-21 2.282 +1 middle-21 -> middle-31 2.283 +2 thumb-11 -> thumb-2.0011 2.284 +3 pointer-11 -> pointer-21 2.285 +4 pointer-21 -> pointer-31 2.286 +5 ring-21 -> ring-31 2.287 +6 ring-11 -> ring-21 2.288 +7 pinky-21 -> pinky-31 2.289 +8 pinky-11 -> pinky-21 2.290 +9 middle-11 -> palm1 2.291 +10 pinky-11 -> palm1 2.292 +11 palm1 -> pointer-11 2.293 +12 palm1 -> ring-11 2.294 +13 palm1 -> thumb-11 2.295 + 2.296 + 2.297 +;; list of muscle targets 2.298 +0 :pointer-2-e 2.299 +1 :pointer-2-f 2.300 +2 :thumb-1 2.301 +3 :thumb-1 2.302 +4 :pointer-1-e 2.303 +5 :pointer-1-f 2.304 +6 :thumb-2-e 2.305 +7 :thumb-2-f 2.306 +8 :middle-1-e 2.307 +9 :middle-1-f 2.308 +10 :pointer-3-f 2.309 +11 :pointer-3-e 2.310 +12 :middle-2-e 2.311 +13 :middle-2-f 2.312 +14 :middle-3-f 2.313 +15 :middle-3-e 2.314 +16 :pinky-2-e 2.315 +17 :pinky-2-f 2.316 +18 :pinky-3-f 2.317 +19 :pinky-3-e 2.318 +20 :ring-3-e 2.319 +21 :ring-3-f 2.320 +22 :ring-2-f 2.321 +23 :ring-2-e 2.322 +24 :ring-1-e 2.323 +25 :ring-1-f 2.324 +26 :thumb-1-e 2.325 +27 :thumb-1-f 2.326 +28 :pinky-1-f 2.327 +29 :pinky-1-e 2.328 +) 2.329 + 2.330 + 2.331 + 2.332 +;; rotate touch 180 2.333 + 2.334 +;; rotate mucles 90 counter-clockwise 2.335 +;; scale muscles to 15x60 2.336 + 2.337 +finger width : 113 2.338 +finger height : 357 2.339 + 2.340 +thumb width : 113 2.341 + 2.342 +pinky --- 0,195 2.343 +ring --- 111,100 2.344 +middle --- 228,0 2.345 +pointer -- 436,96 2.346 +thumb --- 486,420 2.347 + 2.348 + 2.349 + 2.350 +within a finger (coordinates of top left corner (x,y)): 2.351 + 2.352 +tip-flexor : 0,7 2.353 +tip-extensor : 98,7 2.354 +tip : 18,0 2.355 + 2.356 +joint-2-3 : 32,79 2.357 + 2.358 +mid-flexor : 19,131 2.359 +mid-extensor : 80,131 2.360 +mid : 30,133 2.361 + 2.362 +joint-1-2 : 32,193 2.363 + 2.364 +base-flexor : 19,245 2.365 +base-extensor : 80,245 2.366 +base : 39,247 2.367 + 2.368 +joint-palm-1 : 32,307 2.369 + 2.370 + 2.371 +Thumb is the same as finger, except it has two more pieces 2.372 + 2.373 +extra-flexor-1 : 2,131 2.374 +extra-flexor-2 : 100,131 2.375 + 2.376 +;; rotate entire thumb 45 degrees clockwise 2.377 + 2.378 +within vision 2.379 +gray -- 165,577 2.380 +green -- 278,577 2.381 +blue -- 165,682 2.382 +red -- 278,682 2.383 + 2.384 +entire hand : 809, 22 2.385 +main view : 78,202 2.386 +hearing : 784,819 2.387 + 2.388 +hand-size: 688x769 2.389 + 2.390 + 2.391 +total image size: 2.392 +1600x894 2.393 + 2.394 +(def base (File. "/home/r/proj/cortex/render/hand")) 2.395 + 2.396 + 2.397 + 2.398 +(defn prepare-muscle [muscle] 2.399 + ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"]) 2.400 + 2.401 +(defn prepare-touch [touch] 2.402 + ["(" touch "-rotate" "180" ")"]) 2.403 + 2.404 +(defn generate-top-finger [tip-flexor tip-extensor tip 2.405 + joint-2-3 2.406 + mid-flexor mid-extensor mid 2.407 + joint-1-2] 2.408 + ["(" 2.409 + "-size" "113x357" "xc:transparent" 2.410 + (prepare-muscle tip-flexor) "-geometry" "+0+7" "-composite" 2.411 + (prepare-muscle tip-extensor) "-geometry" "+98+7" "-composite" 2.412 + (prepare-touch tip) "-geometry" "+18+0" "-composite" 2.413 + 2.414 + joint-2-3 "-geometry" "+32+79" "-composite" 2.415 + 2.416 + (prepare-muscle mid-flexor) "-geometry" "+19+131" "-composite" 2.417 + (prepare-muscle mid-extensor) "-geometry" "+80+131" "-composite" 2.418 + (prepare-touch mid) "-geometry" "+39+133" "-composite" 2.419 + 2.420 + joint-1-2 "-geometry" "+32+193" "-composite" 2.421 + ")"]) 2.422 + 2.423 +(defn generate-finger 2.424 + [tip-flexor tip-extensor tip 2.425 + joint-2-3 2.426 + mid-flexor mid-extensor mid 2.427 + joint-1-2 2.428 + base-flexor base-extensor base 2.429 + joint-palm-1] 2.430 + ["(" 2.431 + "-size" "113x357" "xc:transparent" 2.432 + (generate-top-finger 2.433 + tip-flexor tip-extensor tip 2.434 + joint-2-3 2.435 + mid-flexor mid-extensor mid 2.436 + joint-1-2) "-geometry" "+0+0" "-composite" 2.437 + (prepare-muscle base-flexor) "-geometry" "+19+245" "-composite" 2.438 + (prepare-muscle base-extensor) "-geometry" "+80+245" "-composite" 2.439 + (prepare-touch base) "-geometry" "+39+247" "-composite" 2.440 + joint-palm-1 "-geometry" "+32+307" "-composite" 2.441 + ")"]) 2.442 + 2.443 +(defn generate-thumb 2.444 + [tip-flexor tip-extensor tip 2.445 + joint-1-2 2.446 + mid-flexor mid-extensor mid-flexor-2 mid-extensor-2 mid 2.447 + joint-palm-1] 2.448 + ["(" 2.449 + "-size" "113x357" "xc:transparent" 2.450 + (generate-top-finger 2.451 + tip-flexor tip-extensor tip 2.452 + joint-1-2 2.453 + mid-flexor mid-extensor mid 2.454 + joint-palm-1) "-geometry" "+0+0" "-composite" 2.455 + (prepare-muscle mid-flexor-2) "-geometry" "+2+131" "-composite" 2.456 + (prepare-muscle mid-extensor-2) "-geometry" "+100+131" "-composite" 2.457 + ")"]) 2.458 + 2.459 +pinky --- 0,195 2.460 +ring --- 111,100 2.461 +middle --- 228,0 2.462 +pointer -- 436,96 2.463 +thumb --- 486,420 2.464 + 2.465 + 2.466 +(defn generate-hand 2.467 + [pinky-pieces 2.468 + ring-pieces 2.469 + middle-pieces 2.470 + pointer-pieces 2.471 + thumb-pieces] 2.472 + ["(" 2.473 + "-size" "688x769" "xc:transparent" 2.474 + (apply generate-finger pinky-pieces) 2.475 + "-geometry" "+0+195" "-composite" 2.476 + (apply generate-finger ring-pieces) 2.477 + "-geometry" "+111+100" "-composite" 2.478 + (apply generate-finger middle-pieces) 2.479 + "-geometry" "+228+0" "-composite" 2.480 + "(" (apply generate-thumb thumb-pieces) "-background" "#00000000" 2.481 + "-rotate" "45" ")" 2.482 + "-geometry" "+300+420" "-composite" 2.483 + (apply generate-finger pointer-pieces) 2.484 + "-geometry" "+350+96" "-composite" 2.485 + ")"]) 2.486 + 2.487 +(defn generate-vision 2.488 + [all green blue red] 2.489 + ["(" 2.490 + "-size" "204x192" "xc:transparent" 2.491 + all "-geometry" "+0+0" "-composite" 2.492 + green "-geometry" "+113+0" "-composite" 2.493 + blue "-geometry" "+0+105" "-composite" 2.494 + red "-geometry" "+113+105" "-composite" 2.495 + ")"]) 2.496 + 2.497 + 2.498 + 2.499 +(def test-muscle (File. base "muscle/0/0000000.png")) 2.500 +(def test-proprio (File. base "proprio/0/0000000.png")) 2.501 +(def test-tip (File. base "touch/2/0000000.png")) 2.502 +(def test-mid (File. base "touch/0/0000000.png")) 2.503 +(def test-vision (File. base "vision/0/0000000.png")) 2.504 +(def test-hearing (File. base "hearing/0/0000000.png")) 2.505 +(def test-main (File. base "main/0000000.png")) 2.506 + 2.507 + 2.508 +(def test-target (File. base "output.png")) 2.509 + 2.510 +(def background (File. base "background.png")) 2.511 + 2.512 +(use 'clojure.contrib.shell-out) 2.513 +(defn final-image [muscle proprio tip mid vision hearing main] 2.514 + (let [[muscle proprio tip mid vision hearing main] (map #(.getCanonicalPath %) 2.515 + [muscle proprio tip mid vision 2.516 + hearing main]) 2.517 + finger-pieces [muscle muscle tip 2.518 + proprio 2.519 + muscle muscle mid 2.520 + proprio 2.521 + muscle muscle mid 2.522 + proprio] 2.523 + thumb-pieces [muscle muscle tip 2.524 + proprio 2.525 + muscle muscle muscle muscle mid 2.526 + proprio]] 2.527 + 2.528 + 2.529 + (apply 2.530 + sh 2.531 + (flatten 2.532 + ["convert" 2.533 + (.getCanonicalPath background) 2.534 + (generate-hand finger-pieces 2.535 + finger-pieces 2.536 + finger-pieces 2.537 + finger-pieces 2.538 + thumb-pieces) 2.539 + "-geometry" "+809+22" "-composite" 2.540 + 2.541 + (generate-vision vision vision vision vision) 2.542 + "-geometry" "+974+599" "-composite" 2.543 + 2.544 + hearing 2.545 + "-geometry" "+784+819" "-composite" 2.546 + 2.547 + main 2.548 + "-geometry" "+78+202" "-composite" 2.549 + 2.550 + (.getCanonicalPath test-target)])))) 2.551 + 2.552 + 2.553 + 2.554 + 2.555 + 2.556 + 2.557 #+end_src 2.558 2.559 #+results: integration