Mercurial > cortex
changeset 256:96b746a0b398
bringing in dylan's changes
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 13 Feb 2012 23:45:38 -0700 |
parents | e6e0bb3057b2 (diff) 63dafe7365df (current diff) |
children | 5d7961d7fded |
files | |
diffstat | 3 files changed, 128 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
1.1 Binary file assets/Models/test-touch/touch-cube.blend has changed
2.1 --- a/org/hearing.org Mon Feb 13 06:13:07 2012 -0600 2.2 +++ b/org/hearing.org Mon Feb 13 23:45:38 2012 -0700 2.3 @@ -950,7 +950,6 @@ 2.4 #+end_src 2.5 2.6 * Testing Hearing 2.7 - 2.8 ** Advanced Java Example 2.9 2.10 I wrote a test case in Java that demonstrates the use of the Java 2.11 @@ -1083,7 +1082,6 @@ 2.12 sound it hears beomes fainter. This shows the 3D localization of 2.13 sound in this world.</p> 2.14 </div> 2.15 - 2.16 #+end_html 2.17 2.18 *** Creating the Ear Video 2.19 @@ -1169,7 +1167,6 @@ 2.20 #+html: <ul> <li> <a href="../org/hearing.org">This org file</a> </li> </ul> 2.21 - [[http://hg.bortreb.com ][source-repository]] 2.22 2.23 - 2.24 * Next 2.25 The worm can see and hear, but it can't feel the world or 2.26 itself. Next post, I'll give the worm a [[./touch.org][sense of touch]].
3.1 --- a/org/touch.org Mon Feb 13 06:13:07 2012 -0600 3.2 +++ b/org/touch.org Mon Feb 13 23:45:38 2012 -0700 3.3 @@ -122,7 +122,7 @@ 3.4 #+end_src 3.5 3.6 It is convienent to treat a =Triangle= as a vector of vectors, and a 3.7 -=Vector2f= and =Vector3f= as vectors of floats. (->vector3f) and 3.8 +=Vector2f= or =Vector3f= as vectors of floats. (->vector3f) and 3.9 (->triangle) undo the operations of =(vector3f-seq)= and 3.10 =(triangle-seq)=. If these classes implemented =Iterable= then =(seq)= 3.11 would work on them automitacally. 3.12 @@ -497,6 +497,7 @@ 3.13 I'll use a new creature --- a simple cube which has touch sensors 3.14 evenly distributed along each of its sides. 3.15 3.16 +#+name: test-touch-0 3.17 #+begin_src clojure 3.18 (in-ns 'cortex.test.touch) 3.19 3.20 @@ -504,10 +505,7 @@ 3.21 (load-blender-model "Models/test-touch/touch-cube.blend")) 3.22 #+end_src 3.23 3.24 -#+begin_html 3.25 -<br> 3.26 -#+end_html 3.27 - 3.28 +** The Touch Cube 3.29 #+begin_html 3.30 <div class="figure"> 3.31 <center> 3.32 @@ -527,12 +525,10 @@ 3.33 #+caption: The distribution of feelers along the touch-cube. The colors of the faces are irrelevant; only the white pixels specify feelers. 3.34 [[../images/touch-profile.png]] 3.35 3.36 +#+name: test-touch-1 3.37 #+begin_src clojure 3.38 (in-ns 'cortex.test.touch) 3.39 3.40 -(import com.aurellem.capture.Capture) 3.41 -(import java.io.File) 3.42 - 3.43 (defn test-basic-touch 3.44 ([] (test-basic-touch false)) 3.45 ([record?] 3.46 @@ -576,6 +572,7 @@ 3.47 #+end_html 3.48 3.49 ** Generating the Basic Touch Video 3.50 +#+name: magick4 3.51 #+begin_src clojure 3.52 (ns cortex.video.magick4 3.53 (:import java.io.File) 3.54 @@ -615,31 +612,88 @@ 3.55 background main-view touch targets)))) 3.56 #+end_src 3.57 3.58 +#+begin_src sh :results silent 3.59 +cd /home/r/proj/cortex/render/touch-cube/ 3.60 +ffmpeg -r 60 -i out/%07d.png -b:v 9000k -c:v libtheora basic-touch.ogg 3.61 +#+end_src 3.62 3.63 * Adding Touch to the Worm 3.64 3.65 -#+name: test-touch 3.66 +#+name: test-touch-2 3.67 #+begin_src clojure 3.68 -(ns cortex.test.touch 3.69 - (:use (cortex world util sense body touch)) 3.70 - (:use cortex.test.body)) 3.71 +(in-ns 'cortex.test.touch) 3.72 3.73 -(cortex.import/mega-import-jme3) 3.74 +(defn test-touch 3.75 + ([] (test-touch false)) 3.76 + ([record?] 3.77 + (let [the-worm (doto (worm) (body!)) 3.78 + touch (touch! the-worm) 3.79 + touch-display (view-touch)] 3.80 + (world 3.81 + (nodify [the-worm (floor)]) 3.82 + standard-debug-controls 3.83 + 3.84 + (fn [world] 3.85 + (if record? 3.86 + (Capture/captureVideo 3.87 + world 3.88 + (File. "/home/r/proj/cortex/render/worm-touch/main-view/"))) 3.89 + (speed-up world) 3.90 + (light-up-everything world)) 3.91 3.92 -(defn test-touch [] 3.93 - (let [the-worm (doto (worm) (body!)) 3.94 - touch (touch! the-worm) 3.95 - touch-display (view-touch)] 3.96 - (world (nodify [the-worm (floor)]) 3.97 - standard-debug-controls 3.98 - 3.99 - (fn [world] 3.100 - (speed-up world) 3.101 - (light-up-everything world)) 3.102 + (fn [world tpf] 3.103 + (touch-display 3.104 + (map #(% (.getRootNode world)) touch) 3.105 + (if record? 3.106 + (File. "/home/r/proj/cortex/render/worm-touch/touch/")))))))) 3.107 +#+end_src 3.108 3.109 - (fn [world tpf] 3.110 - (touch-display 3.111 - (map #(% (.getRootNode world)) touch)))))) 3.112 +** Worm Touch Demonstration 3.113 +#+begin_html 3.114 +<div class="figure"> 3.115 +<center> 3.116 +<video controls="controls" width="550"> 3.117 + <source src="../video/worm-touch.ogg" type="video/ogg" 3.118 + preload="none" poster="../images/aurellem-1280x480.png" /> 3.119 +</video> 3.120 +</center> 3.121 +<p>The worm responds to touch.</p> 3.122 +</div> 3.123 +#+end_html 3.124 + 3.125 + 3.126 +** Generating the Worm Touch Video 3.127 +#+name: magick5 3.128 +#+begin_src clojure 3.129 +(ns cortex.video.magick5 3.130 + (:import java.io.File) 3.131 + (:use clojure.contrib.shell-out)) 3.132 + 3.133 +(defn images [path] 3.134 + (sort (rest (file-seq (File. path))))) 3.135 + 3.136 +(def base "/home/r/proj/cortex/render/worm-touch/") 3.137 + 3.138 +(defn pics [file] 3.139 + (images (str base file))) 3.140 + 3.141 +(defn combine-images [] 3.142 + (let [main-view (pics "main-view") 3.143 + touch (pics "touch/0") 3.144 + targets (map 3.145 + #(File. (str base "out/" (format "%07d.png" %))) 3.146 + (range 0 (count main-view)))] 3.147 + (dorun 3.148 + (pmap 3.149 + (comp 3.150 + (fn [[ main-view touch target]] 3.151 + (println target) 3.152 + (sh "convert" 3.153 + main-view 3.154 + touch "-geometry" "+0+0" "-composite" 3.155 + target)) 3.156 + (fn [& args] (map #(.getCanonicalPath %) args))) 3.157 + main-view touch targets)))) 3.158 #+end_src 3.159 3.160 * Headers 3.161 @@ -661,9 +715,44 @@ 3.162 (:import (com.jme3.math Triangle Vector3f Vector2f Ray Matrix4f))) 3.163 #+end_src 3.164 3.165 +#+name: test-touch-header 3.166 +#+begin_src clojure 3.167 +(ns cortex.test.touch 3.168 + (:use (cortex world util sense body touch)) 3.169 + (:use cortex.test.body) 3.170 + (:import com.aurellem.capture.Capture) 3.171 + (:import java.io.File) 3.172 + (:import (com.jme3.math Vector3f ColorRGBA))) 3.173 +#+end_src 3.174 + 3.175 * Source Listing 3.176 + - [[../src/cortex/touch.clj][cortex.touch]] 3.177 + - [[../src/cortex/test/touch.clj][cortex.test.touch]] 3.178 + - [[../src/cortex/video/magick4.clj][cortex.video.magick4]] 3.179 + - [[../src/cortex/video/magick5.clj][cortex.video.magick5]] 3.180 +#+html: <ul> <li> <a href="../org/touch.org">This org file</a> </li> </ul> 3.181 + - [[http://hg.bortreb.com ][source-repository]] 3.182 + 3.183 * Next 3.184 +So far I've implemented simulated Vision, Hearing, and Touch, the most 3.185 +obvious and promiment senses that humans have. Smell and Taste shall 3.186 +remain unimplemented for now. This accounts for the "five senses" that 3.187 +feature so prominently in our lives. But humans have far more than the 3.188 +five main senses. There are internal chemical senses, pain (which is 3.189 +*not* the same as touch), heat sensitivity, and our sense of balance, 3.190 +among others. One extra sense is so important that I must implement it 3.191 +to have a hope of making creatures that can gracefully control their 3.192 +own bodies. It is Proprioception, which is the sense of the location 3.193 +of each body part in relation to the other body parts. 3.194 3.195 +Close your eyes, and touch your nose with your right index finger. How 3.196 +did you do it? You could not see your hand, and neither your hand nor 3.197 +your nose could use the sense of touch to guide the path of your hand. 3.198 +There are no sound cues, and Taste and Smell certainly don't provide 3.199 +any help. You know where your hand is without your other senses 3.200 +because of Proprioception. 3.201 + 3.202 +Onward to [[./proprioception.org][proprioception]]! 3.203 3.204 * COMMENT Code Generation 3.205 #+begin_src clojure :tangle ../src/cortex/touch.clj 3.206 @@ -678,11 +767,22 @@ 3.207 <<visualization>> 3.208 #+end_src 3.209 3.210 +#+begin_src clojure :tangle ../src/cortex/test/touch.clj 3.211 +<<test-touch-header>> 3.212 +<<test-touch-0>> 3.213 +<<test-touch-1>> 3.214 +<<test-touch-2>> 3.215 +#+end_src 3.216 3.217 -#+begin_src clojure :tangle ../src/cortex/test/touch.clj 3.218 -<<test-touch>> 3.219 +#+begin_src clojure :tangle ../src/cortex/video/magick4.clj 3.220 +<<magick4>> 3.221 #+end_src 3.222 3.223 +#+begin_src clojure :tangle ../src/cortex/video/magick5.clj 3.224 +<<magick5>> 3.225 +#+end_src 3.226 + 3.227 + 3.228 3.229 3.230