# HG changeset patch # User Robert McIntyre # Date 1329198720 25200 # Node ID e23717fefc7f83441121b86c80b35395e3236c04 # Parent f1a74d23e7e49e0041ede18873917d63cccaa46a added video and source listing to touch diff -r f1a74d23e7e4 -r e23717fefc7f org/touch.org --- a/org/touch.org Mon Feb 13 20:19:34 2012 -0700 +++ b/org/touch.org Mon Feb 13 22:52:00 2012 -0700 @@ -497,6 +497,7 @@ I'll use a new creature --- a simple cube which has touch sensors evenly distributed along each of its sides. +#+name: test-touch-0 #+begin_src clojure (in-ns 'cortex.test.touch) @@ -504,10 +505,7 @@ (load-blender-model "Models/test-touch/touch-cube.blend")) #+end_src -#+begin_html -
-#+end_html - +** The Touch Cube #+begin_html
@@ -527,12 +525,10 @@ #+caption: The distribution of feelers along the touch-cube. The colors of the faces are irrelevant; only the white pixels specify feelers. [[../images/touch-profile.png]] +#+name: test-touch-1 #+begin_src clojure (in-ns 'cortex.test.touch) -(import com.aurellem.capture.Capture) -(import java.io.File) - (defn test-basic-touch ([] (test-basic-touch false)) ([record?] @@ -576,6 +572,7 @@ #+end_html ** Generating the Basic Touch Video +#+name: magick4 #+begin_src clojure (ns cortex.video.magick4 (:import java.io.File) @@ -622,42 +619,82 @@ * Adding Touch to the Worm -#+name: test-touch +#+name: test-touch-2 #+begin_src clojure -(ns cortex.test.touch - (:use (cortex world util sense body touch)) - (:use cortex.test.body)) - -(cortex.import/mega-import-jme3) +(in-ns 'cortex.test.touch) (defn test-touch ([] (test-touch false)) -([record?] - (let [the-worm (doto (worm) (body!)) - touch (touch! the-worm) - touch-display (view-touch)] - (world (nodify [the-worm (floor)]) - standard-debug-controls - - (fn [world] - (if record? - (Capture/captureVideo - world - (File. "/home/r/proj/cortex/render/worm-touch/main-view/"))) - (speed-up world) - (light-up-everything world)) + ([record?] + (let [the-worm (doto (worm) (body!)) + touch (touch! the-worm) + touch-display (view-touch)] + (world + (nodify [the-worm (floor)]) + standard-debug-controls + + (fn [world] + (if record? + (Capture/captureVideo + world + (File. "/home/r/proj/cortex/render/worm-touch/main-view/"))) + (speed-up world) + (light-up-everything world)) - (fn [world tpf] - (touch-display - (map #(% (.getRootNode world)) touch) -(if record? -(File. "/home/r/proj/cortex/render/worm-touch/touch/")) - -))))) + (fn [world tpf] + (touch-display + (map #(% (.getRootNode world)) touch) + (if record? + (File. "/home/r/proj/cortex/render/worm-touch/touch/")))))))) #+end_src +** Worm Touch Demonstration +#+begin_html +
+
+ +
+

The worm responds to touch.

+
+#+end_html +** Generating the Worm Touch Video +#+name: magick5 +#+begin_src clojure +(ns cortex.video.magick5 + (:import java.io.File) + (:use clojure.contrib.shell-out)) + +(defn images [path] + (sort (rest (file-seq (File. path))))) + +(def base "/home/r/proj/cortex/render/worm-touch/") + +(defn pics [file] + (images (str base file))) + +(defn combine-images [] + (let [main-view (pics "main-view") + touch (pics "touch/0") + targets (map + #(File. (str base "out/" (format "%07d.png" %))) + (range 0 (count main-view)))] + (dorun + (pmap + (comp + (fn [[ main-view touch target]] + (println target) + (sh "convert" + main-view + touch "-geometry" "+0+0" "-composite" + target)) + (fn [& args] (map #(.getCanonicalPath %) args))) + main-view touch targets)))) +#+end_src * Headers @@ -678,7 +715,25 @@ (:import (com.jme3.math Triangle Vector3f Vector2f Ray Matrix4f))) #+end_src +#+name: test-touch-header +#+begin_src clojure +(ns cortex.test.touch + (:use (cortex world util sense body touch)) + (:use cortex.test.body) + (:import com.aurellem.capture.Capture) + (:import java.io.File) + (:import (com.jme3.math Vector3f ColorRGBA))) +#+end_src + * Source Listing + - [[../src/cortex/touch.clj][cortex.touch]] + - [[../src/cortex/test/touch.clj][cortex.test.touch]] + - [[../src/cortex/video/magick4.clj][cortex.video.magick4]] + - [[../src/cortex/video/magick5.clj][cortex.video.magick5]] +#+html: + - [[http://hg.bortreb.com ][source-repository]] + + * Next @@ -695,11 +750,22 @@ <> #+end_src +#+begin_src clojure :tangle ../src/cortex/test/touch.clj +<> +<> +<> +<> +#+end_src -#+begin_src clojure :tangle ../src/cortex/test/touch.clj -<> +#+begin_src clojure :tangle ../src/cortex/video/magick4.clj +<> #+end_src +#+begin_src clojure :tangle ../src/cortex/video/magick5.clj +<> +#+end_src + +