# HG changeset patch # User Robert McIntyre # Date 1329501987 25200 # Node ID c78917fb0615341b579116834a6741c65a81cbf0 # Parent 47fe4f7b74b3715e244ce5879f1590a096f2350a created first version of the video which demonstrates all the senses diff -r 47fe4f7b74b3 -r c78917fb0615 assets/Models/subtitles/hand.blend Binary file assets/Models/subtitles/hand.blend has changed diff -r 47fe4f7b74b3 -r c78917fb0615 org/integration.org --- a/org/integration.org Thu Feb 16 21:14:28 2012 -0700 +++ b/org/integration.org Fri Feb 17 11:06:27 2012 -0700 @@ -12,9 +12,22 @@ made so far. The blender file for the creature serves as an example of a fully equipped creature in terms of senses. You can find it [[../assets/Models/test-creature/hand.blend][here]]. + +#+begin_html +
+ +

Simulated Senses in a Virtual Environment

+
+#+end_html + + + #+name: integration #+begin_src clojure -(ns cortex.integration +(ns cortex.test.integration "let's play!" {:author "Robert McIntyre"} (:use (cortex world util body sense @@ -30,20 +43,14 @@ (def hand "Models/test-creature/hand.blend") (def output-base (File. "/home/r/proj/cortex/render/hand")) +#+end_src +For this demonstration I have to manually drive the muscles of the +hand. I do this by creating a little mini-language to describe +simulated muscle contraction. -;; Let the hand fall palm-up - -;; it curls its phalanges, starting with the pinky. - -;; it lets these fall back down? - -;; block falls down onto the hand, accompanied by a sound. The block -;; can be seen by the hand's eye. - -;; hand FORCEFULLY catapults the block so that it hits the camera. - - +#+name: integration-2 +#+begin_src clojure (defn motor-control-program "Create a function which will execute the motor script" [muscle-positions @@ -94,8 +101,24 @@ :pinky-1-e]) (def full 9001) + + +;; Coreography: + +;; Let the hand fall palm-up + +;; it curls its phalanges, starting with the pinky. + +;; it lets its phalanges fall back down. + +;; block falls down onto the hand, accompanied by a sound. The block +;; can be seen by the hand's eye. + +;; hand FORCEFULLY catapults the block so that it hits the camera. + + ;; the systax here is [keyframe body-part force] -(def wiggle-each-finger-tip +(def move-fingers [[300 :pinky-3-f 50] [320 :pinky-2-f 80] [340 :pinky-1-f 100] @@ -197,41 +220,6 @@ (println-repl (.getWorldTranslation brick))) (controlRender [_ _])))) (add-element world brick)))))) - - -(def control-list - [ - 0 ;;pointer-21 # - 0 ;;pointer-21 # - 0 ;;thumb-11 # - 0 ;;thumb-11 # - 0 ;;pointer-11 # - 0 ;;pointer-11 # - 0 ;;thumb-2.0011 # - 0 ;;thumb-2.0011 # - 0 ;;middle-11 # - 0 ;;middle-11 # - 0 ;;pointer-31 # - 0 ;;pointer-31 # - 0 ;;middle-21 # - 0 ;;middle-21 # - 0 ;;middle-31 # - 0 ;;middle-31 # - 0 ;;pinky-21 # - 0 ;;pinky-21 # - 0 ;;pinky-31 # - 0 ;;pinky-31 # - 0 ;;ring-31 # - 0 ;;ring-31 # - 0 ;;ring-21 # - 0 ;;ring-21 # - 0 ;;ring-11 # - 0 ;;ring-11 # - 0 ;;thumb-11 # - 0 ;;thumb-11 # - 0 ;;pinky-11 # - 0 ;;pinky-11 # - ]) (import com.aurellem.capture.Capture) @@ -261,7 +249,7 @@ prop-display (view-proprioception) control-script (motor-control-program - muscle-positions wiggle-each-finger-tip) + muscle-positions move-fingers) muscles (movement! creature) muscle-display (view-movement) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -315,7 +303,18 @@ (.setLocalTranslation me (.getLocation (.getCamera world))) (fix-display world)))))) +#+end_src +* Generating the Video + +Just a bunch of calls to imagemagick to arrange the data that +=test-everything!= produces. + +#+name: magick-8 +#+begin_src clojure +(ns cortex.video.magick8 + (:import java.io.File) + (:use clojure.contrib.shell-out)) (comment ;; list of touch targets @@ -426,7 +425,6 @@ (map (comp file-names #(File. base %)) paths))) - (defn pinky [] (file-groups "muscle/18" @@ -468,13 +466,13 @@ "touch/2" "proprio/1" + "muscle/13" "muscle/12" - "muscle/13" "touch/1" "proprio/0" + "muscle/9" "muscle/8" - "muscle/9" "touch/0" "proprio/9")) @@ -603,11 +601,11 @@ (defn main [] (file-names (File. base "main"))) -(defn targets [] +(defn targets [dest max] (map (comp #(.getCanonicalPath %) - #(File. (str base "/out/" (format "%07d.png" %)))) - (range 0 (count (main))))) + #(File. (str base dest (format "%07d.png" %)))) + (range max))) (defn final-image [main [all red green blue] hearing @@ -633,7 +631,7 @@ target]))) -(defn convert-files [] +(defn combine-files [] (dorun (pmap final-image (main) @@ -644,20 +642,61 @@ (middle) (pointer) (thumb) - (targets)))) + (targets "/out/" (count (main)))))) + +(defn subtitles [] + (file-names (File. base "subs"))) + +(defn outs [] + (file-names (File. base "out"))) + + +(defn mix-subtitles [] + (let [subs (subtitles) + targets (targets "/out-subs/" (count subs)) + overlay (.getCanonicalPath (File. base "output.png"))] + (dorun + (pmap + (fn [sub target] + (sh + "convert" + overlay + sub "-geometry" "+0+0" "-composite" + target)) + subs targets)))) + +(defn out-subtitles [] + (file-names (File. base "out-subs"))) + + +(defn insert-subtitles [] + (let [subtitles (out-subtitles) + outs (outs) + targets (targets + "/final/" + (+ (count outs) (count subtitles)))] + (dorun + (pmap + #(sh "cp" %1 %2) + (concat subtitles outs) targets)))) + +(defn generate-final [] + (combine-files) + (mix-subtitles) + (insert-subtitles)) #+end_src - -#+begin_src sh +#+begin_src sh :results silent cd /home/r/proj/cortex/render/hand -ffmpeg -r 60 -i out/%07d.png -i main.wav -b:a 128k \ +sox --ignore-length main.wav main-delayed.wav delay 24 + +mogrify -resize 755x final/* + +ffmpeg -r 60 -i final/%07d.png -i main-delayed.wav -b:a 128k \ -b:v 9000k -c:a libvorbis -c:v libtheora hand.ogg #+end_src -#+results: integration -: #'cortex.integration/convert-files - * COMMENT purgatory #+begin_src clojure (defn bullet-trans* [] @@ -820,8 +859,13 @@ * COMMENT generate source -#+begin_src clojure :tangle ../src/cortex/integration.clj +#+begin_src clojure :tangle ../src/cortex/test/integration.clj <> +<> +#+end_src + +#+begin_src clojure :tangle ../src/cortex/video/magick8.clj +<> #+end_src