changeset 304:2dfebf71053c

Merged Winston cover letter
author Dylan Holmes <ocsenave@gmail.com>
date Sat, 18 Feb 2012 02:07:40 -0600
parents 35d9e7d04d87 (current diff) 7e3938f40c52 (diff)
children 19c43ec6958d
files
diffstat 24 files changed, 1115 insertions(+), 462 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/heart/heart.blend has changed
     2.1 Binary file assets/Models/subtitles/hand.blend has changed
     3.1 Binary file assets/Models/test-creature/finger-tip-UV-layout.png has changed
     4.1 Binary file assets/Models/test-creature/finger-tip.png has changed
     5.1 Binary file assets/Models/test-creature/finger-tip.xcf has changed
     6.1 Binary file assets/Models/test-creature/hand.blend has changed
     7.1 Binary file assets/Models/test-creature/mid-finger.png has changed
     8.1 Binary file assets/Models/test-creature/mid-finger.xcf has changed
     9.1 Binary file assets/Models/test-creature/palm-retina.png has changed
    10.1 Binary file assets/Models/test-touch/touch-cube.blend has changed
    11.1 Binary file assets/Models/test-touch/touch-cube.blend.orig has changed
    12.1 Binary file images/worm-with-muscle.png has changed
    13.1 --- a/org/body.org	Sat Feb 18 02:06:06 2012 -0600
    13.2 +++ b/org/body.org	Sat Feb 18 02:07:40 2012 -0600
    13.3 @@ -80,14 +80,17 @@
    13.4    (.setTimer world (RatchetTimer. 60))
    13.5    world)
    13.6  
    13.7 -(defn test-one []
    13.8 -  (world (hand)
    13.9 -         standard-debug-controls
   13.10 -         (comp
   13.11 -          #(Capture/captureVideo
   13.12 -            % (File. "/home/r/proj/cortex/render/body/1"))
   13.13 -          setup)
   13.14 -         no-op))
   13.15 +(defn test-hand-1
   13.16 +  ([] (test-hand-1 false))
   13.17 +  ([record?]
   13.18 +     (world (hand)
   13.19 +            standard-debug-controls
   13.20 +            (fn [world]
   13.21 +              (if record?
   13.22 +                (Capture/captureVideo
   13.23 +                 world
   13.24 +                 (File. "/home/r/proj/cortex/render/body/1")))
   13.25 +             (setup world)) no-op)))
   13.26  #+end_src
   13.27  
   13.28  
   13.29 @@ -158,18 +161,22 @@
   13.30    (box 10 3 10 :position (Vector3f. 0 -10 0)
   13.31         :color ColorRGBA/Gray :mass 0))
   13.32  
   13.33 -(defn test-two []
   13.34 -  (world (nodify
   13.35 -          [(doto (hand)
   13.36 -             (physical!))
   13.37 -          (floor)])
   13.38 -         (merge standard-debug-controls gravity-control)
   13.39 -         (comp
   13.40 -          #(Capture/captureVideo
   13.41 -            % (File. "/home/r/proj/cortex/render/body/2"))
   13.42 -          #(do (set-gravity % Vector3f/ZERO) %)
   13.43 -          setup)
   13.44 -         no-op))
   13.45 +(defn test-hand-2
   13.46 +  ([] (test-hand-2 false))
   13.47 +  ([record?]
   13.48 +     (world
   13.49 +      (nodify
   13.50 +       [(doto (hand)
   13.51 +          (physical!))
   13.52 +        (floor)])
   13.53 +      (merge standard-debug-controls gravity-control)
   13.54 +      (fn [world]
   13.55 +        (if record?
   13.56 +          (Capture/captureVideo
   13.57 +           world (File. "/home/r/proj/cortex/render/body/2")))
   13.58 +        (set-gravity world Vector3f/ZERO)
   13.59 +        (setup world))
   13.60 +      no-op)))
   13.61  #+end_src
   13.62  
   13.63  #+begin_html
   13.64 @@ -428,20 +435,23 @@
   13.65    {"key-h" (fn [world val]
   13.66               (if val (enable-debug world)))})
   13.67    
   13.68 -(defn test-three []
   13.69 -  (world (nodify
   13.70 -          [(doto (hand)
   13.71 -             (physical!)
   13.72 -             (joints!))
   13.73 -           (floor)])
   13.74 -         (merge standard-debug-controls debug-control
   13.75 -                gravity-control)
   13.76 -         (comp
   13.77 -          #(Capture/captureVideo
   13.78 -            % (File. "/home/r/proj/cortex/render/body/3"))
   13.79 -          #(do (set-gravity % Vector3f/ZERO) %)
   13.80 -          setup)
   13.81 -         no-op))
   13.82 +(defn test-hand-3
   13.83 +  ([] (test-hand-3 false))
   13.84 +  ([record?]
   13.85 +     (world 
   13.86 +      (nodify
   13.87 +       [(doto (hand)
   13.88 +          (physical!)
   13.89 +          (joints!))
   13.90 +        (floor)])
   13.91 +      (merge standard-debug-controls debug-control
   13.92 +             gravity-control)
   13.93 +      (comp
   13.94 +       #(Capture/captureVideo
   13.95 +         % (File. "/home/r/proj/cortex/render/body/3"))
   13.96 +       #(do (set-gravity % Vector3f/ZERO) %)
   13.97 +       setup)
   13.98 +      no-op)))
   13.99  #+end_src
  13.100  
  13.101  =physical!= makes the hand solid, then =joints!= connects each
  13.102 @@ -494,22 +504,25 @@
  13.103   (load-blender-model
  13.104              "Models/test-creature/worm.blend"))
  13.105  
  13.106 -(defn worm-1 []
  13.107 -  (let [timer (RatchetTimer. 60)]
  13.108 -    (world
  13.109 -     (nodify
  13.110 -      [(doto (worm)
  13.111 -         (body!))
  13.112 -       (floor)])
  13.113 -     (merge standard-debug-controls debug-control)
  13.114 -     #(do
  13.115 -        (speed-up %)
  13.116 -        (light-up-everything %)
  13.117 -        (.setTimer % timer)
  13.118 -        (cortex.util/display-dialated-time % timer)
  13.119 -        (Capture/captureVideo
  13.120 -         % (File. "/home/r/proj/cortex/render/body/4")))
  13.121 -     no-op)))
  13.122 +(defn test-worm
  13.123 +  ([] (test-worm false))
  13.124 +  ([record?]
  13.125 +     (let [timer (RatchetTimer. 60)]
  13.126 +       (world
  13.127 +        (nodify
  13.128 +         [(doto (worm)
  13.129 +            (body!))
  13.130 +          (floor)])
  13.131 +        (merge standard-debug-controls debug-control)
  13.132 +        #(do
  13.133 +           (speed-up %)
  13.134 +           (light-up-everything %)
  13.135 +           (.setTimer % timer)
  13.136 +           (cortex.util/display-dialated-time % timer)
  13.137 +           (if record?
  13.138 +             (Capture/captureVideo
  13.139 +              % (File. "/home/r/proj/cortex/render/body/4"))))
  13.140 +        no-op))))
  13.141  #+end_src
  13.142  
  13.143  #+begin_html
    14.1 --- a/org/capture-video.org	Sat Feb 18 02:06:06 2012 -0600
    14.2 +++ b/org/capture-video.org	Sat Feb 18 02:07:40 2012 -0600
    14.3 @@ -12,8 +12,7 @@
    14.4  create a demo video to show off your hard work. Screen capturing is
    14.5  the most straightforward way to do this, but it can slow down your
    14.6  game and produce low-quality video as a result. A better way is to
    14.7 -record a video feed directly from the game while it is
    14.8 -running.
    14.9 +record a video feed directly from the game while it is running.
   14.10  
   14.11  In this post, I'll explain how you can alter your JMonkeyEngine3 game
   14.12  to output video while it is running. The main trick is to alter the
   14.13 @@ -28,62 +27,62 @@
   14.14  ** The built-in =Timer= rushes to keep up.
   14.15  #* Game-time vs. User-time vs. Video-time
   14.16  
   14.17 -Standard JME3 applications use a =Timer= object to manage time
   14.18 -in the simulated world. Because most JME3 applications (e.g. games)
   14.19 -are supposed to happen \ldquo{}live\rdquo{}, the built-in =Timer=
   14.20 -requires simulated time to match real time. This means that the
   14.21 -application must rush to finish all of its calculations on
   14.22 -schedule: the more complicated the calculations, the more the
   14.23 -application is obligated to rush. And if the workload becomes too
   14.24 -much to handle on schedule, =Timer= forces the application to cut
   14.25 -corners: it demands fast, approximate answers instead of careful,
   14.26 -accurate ones.  Although this policy sometimes causes physically impossible
   14.27 -glitches and choppy framerates, it ensures that the user will never be
   14.28 -kept waiting while the computer stops to make a complicated
   14.29 -calculation.
   14.30 +Standard JME3 applications use a =Timer= object to manage time in the
   14.31 +simulated world. Because most JME3 applications (e.g. games) are
   14.32 +supposed to happen \ldquo{}live\rdquo{}, the built-in =Timer= requires
   14.33 +simulated time to match real time. This means that the application
   14.34 +must rush to finish all of its calculations on schedule: the more
   14.35 +complicated the calculations, the more the application is obligated to
   14.36 +rush. And if the workload becomes too much to handle on schedule,
   14.37 +=Timer= forces the application to cut corners: it demands fast,
   14.38 +approximate answers instead of careful, accurate ones.  Although this
   14.39 +policy sometimes causes physically impossible glitches and choppy
   14.40 +framerates, it ensures that the user will never be kept waiting while
   14.41 +the computer stops to make a complicated calculation.
   14.42  
   14.43  Now, the built-in =Timer= values speed over accuracy because real-time
   14.44 -applications require it. On the other hand, if your goal is to record a
   14.45 -glitch-free video, you need a =Timer= that will take its time to
   14.46 -ensure that all calculations are accurate, even if they take a long time. In the next section, we
   14.47 -will create a new kind of =Timer=\mdash{}called =IsoTimer=\mdash{}which
   14.48 -slows down to let the computer finish all its calculations. The result
   14.49 -is a perfectly steady framerate and a flawless physical simulation.
   14.50 +applications require it. On the other hand, if your goal is to record
   14.51 +a glitch-free video, you need a =Timer= that will take its time to
   14.52 +ensure that all calculations are accurate, even if they take a long
   14.53 +time. In the next section, we will create a new kind of
   14.54 +=Timer=\mdash{}called =IsoTimer=\mdash{}which slows down to let the
   14.55 +computer finish all its calculations. The result is a perfectly steady
   14.56 +framerate and a flawless physical simulation.
   14.57  
   14.58  # are supposed to happen \ldquo live \rdquo, this =Timer= requires the
   14.59 -# application to update in real-time. In order to keep up with the real world, JME applications cannot
   14.60 -# afford to take too much time on expensive computations. Whenever the
   14.61 -# workload becomes too much for the computer to handle on schedule,
   14.62 -# =Timer= forces the computer to cut corners, giving fast, approximate
   14.63 -# answers instead of careful, accurate ones. Although physical accuracy sometimes
   14.64 -# suffers as a result, this policy ensures that the user will never be
   14.65 -# kept waiting while the computer stops to make a complicated
   14.66 -# calculation.
   14.67 +# application to update in real-time. In order to keep up with the
   14.68 +# real world, JME applications cannot afford to take too much time on
   14.69 +# expensive computations. Whenever the workload becomes too much for
   14.70 +# the computer to handle on schedule, =Timer= forces the computer to
   14.71 +# cut corners, giving fast, approximate answers instead of careful,
   14.72 +# accurate ones. Although physical accuracy sometimes suffers as a
   14.73 +# result, this policy ensures that the user will never be kept waiting
   14.74 +# while the computer stops to make a complicated calculation.
   14.75  
   14.76  #fast answers are more important than accurate ones. 
   14.77  
   14.78  # A standard JME3 application that extends =SimpleApplication= or
   14.79  # =Application= tries as hard as it can to keep in sync with
   14.80 -# /user-time/.  If a ball is rolling at 1 game-mile per game-hour in the
   14.81 -# game, and you wait for one user-hour as measured by the clock on your
   14.82 -# wall, then the ball should have traveled exactly one game-mile. In
   14.83 -# order to keep sync with the real world, the game throttles its physics
   14.84 -# engine and graphics display.  If the computations involved in running
   14.85 -# the game are too intense, then the game will first skip frames, then
   14.86 -# sacrifice physics accuracy.  If there are particuraly demanding
   14.87 -# computations, then you may only get 1 fps, and the ball may tunnel
   14.88 -# through the floor or obstacles due to inaccurate physics simulation,
   14.89 -# but after the end of one user-hour, that ball will have traveled one
   14.90 -# game-mile.
   14.91 +# /user-time/.  If a ball is rolling at 1 game-mile per game-hour in
   14.92 +# the game, and you wait for one user-hour as measured by the clock on
   14.93 +# your wall, then the ball should have traveled exactly one
   14.94 +# game-mile. In order to keep sync with the real world, the game
   14.95 +# throttles its physics engine and graphics display.  If the
   14.96 +# computations involved in running the game are too intense, then the
   14.97 +# game will first skip frames, then sacrifice physics accuracy.  If
   14.98 +# there are particuraly demanding computations, then you may only get
   14.99 +# 1 fps, and the ball may tunnel through the floor or obstacles due to
  14.100 +# inaccurate physics simulation, but after the end of one user-hour,
  14.101 +# that ball will have traveled one game-mile.
  14.102  
  14.103 -# When we're recording video, we don't care if the game-time syncs with
  14.104 -# user-time, but instead whether the time in the recorded video
  14.105 +# When we're recording video, we don't care if the game-time syncs
  14.106 +# with user-time, but instead whether the time in the recorded video
  14.107  # (video-time) syncs with user-time. To continue the analogy, if we
  14.108 -# recorded the ball rolling at 1 game-mile per game-hour and watched the
  14.109 -# video later, we would want to see 30 fps video of the ball rolling at
  14.110 -# 1 video-mile per /user-hour/. It doesn't matter how much user-time it
  14.111 -# took to simulate that hour of game-time to make the high-quality
  14.112 -# recording.
  14.113 +# recorded the ball rolling at 1 game-mile per game-hour and watched
  14.114 +# the video later, we would want to see 30 fps video of the ball
  14.115 +# rolling at 1 video-mile per /user-hour/. It doesn't matter how much
  14.116 +# user-time it took to simulate that hour of game-time to make the
  14.117 +# high-quality recording.
  14.118  ** COMMENT Two examples to clarify the point:
  14.119  *** Recording from a Simple Simulation
  14.120  
  14.121 @@ -151,10 +150,10 @@
  14.122  the screen, and an additional $\frac{1}{60}$ to encode the video and
  14.123  write the frame to disk. This is a total of $\frac{1}{24}$
  14.124  user-seconds for each $\frac{1}{60}$ game-seconds. It will take
  14.125 -$(\frac{60}{24} = 2.5)$ user-hours to record one game-hour and game-time
  14.126 -will appear to flow two-fifths as fast as user time while the game is
  14.127 -running. However, just as in example one, when all is said and done we
  14.128 -will have an hour long video at 60 fps.
  14.129 +$(\frac{60}{24} = 2.5)$ user-hours to record one game-hour and
  14.130 +game-time will appear to flow two-fifths as fast as user time while
  14.131 +the game is running. However, just as in example one, when all is said
  14.132 +and done we will have an hour long video at 60 fps.
  14.133  
  14.134  
  14.135  ** COMMENT proposed names for the new timer
  14.136 @@ -182,8 +181,8 @@
  14.137  #+include ../../jmeCapture/src/com/aurellem/capture/IsoTimer.java src java
  14.138  
  14.139  If an Application uses this =IsoTimer= instead of the normal one, we
  14.140 -can be sure that every call to =simpleUpdate=, for example, corresponds
  14.141 -to exactly $(\frac{1}{fps})$ seconds of game-time.
  14.142 +can be sure that every call to =simpleUpdate=, for example,
  14.143 +corresponds to exactly $(\frac{1}{fps})$ seconds of game-time.
  14.144  
  14.145  * =VideoRecorder= manages video feeds in JMonkeyEngine.
  14.146  
  14.147 @@ -240,8 +239,9 @@
  14.148  
  14.149  With this, we are able to record video!
  14.150  
  14.151 -However, it can be hard to properly install Xuggle. If you would rather not use Xuggle, here is an alternate class that uses
  14.152 -[[http://www.randelshofer.ch/blog/2008/08/writing-avi-videos-in-pure-java/][Werner Randelshofer's]] excellent pure Java AVI file writer.
  14.153 +However, it can be hard to properly install Xuggle. If you would
  14.154 +rather not use Xuggle, here is an alternate class that uses [[http://www.randelshofer.ch/blog/2008/08/writing-avi-videos-in-pure-java/][Werner
  14.155 +Randelshofer's]] excellent pure Java AVI file writer.
  14.156  
  14.157  =./src/com/aurellem/capture/video/AVIVideoRecorder.java=
  14.158  #+include ../../jmeCapture/src/com/aurellem/capture/video/AVIVideoRecorder.java src java
  14.159 @@ -265,13 +265,14 @@
  14.160  
  14.161  ** Include this code.
  14.162  
  14.163 -  No matter how complicated your application is, it's easy to add
  14.164 -  support for video output with just a few lines of code.
  14.165 +No matter how complicated your application is, it's easy to add
  14.166 +support for video output with just a few lines of code.
  14.167  #  You can also record from multiple ViewPorts as the above example shows.
  14.168  
  14.169 -And although you can use =VideoRecorder= to record advanced split-screen videos with multiple views, in the simplest case, you want to capture a single view\mdash{}
  14.170 -exactly what's on screen. In this case, the following simple =captureVideo=
  14.171 -method will do the job:
  14.172 +And although you can use =VideoRecorder= to record advanced
  14.173 +split-screen videos with multiple views, in the simplest case, you
  14.174 +want to capture a single view\mdash{} exactly what's on screen. In
  14.175 +this case, the following simple =captureVideo= method will do the job:
  14.176  
  14.177  #+begin_src java
  14.178  public static void captureVideo(final Application app, 
  14.179 @@ -302,12 +303,9 @@
  14.180  }
  14.181  #+end_src
  14.182  
  14.183 -This method selects the appropriate =VideoRecorder= class
  14.184 -for the file type you specify, and instructs your
  14.185 -application to record video to the file.
  14.186 -
  14.187 -
  14.188 -
  14.189 +This method selects the appropriate =VideoRecorder= class for the file
  14.190 +type you specify, and instructs your application to record video to
  14.191 +the file.
  14.192  
  14.193  Now that you have a =captureVideo= method, you use it like this:
  14.194  
  14.195 @@ -321,7 +319,8 @@
  14.196  
  14.197    - Choose the output file :: If you want to record from the game's
  14.198         main =ViewPort= to a file called =/home/r/record.flv=, then
  14.199 -       include the following line of code somewhere before you call =app.start()=;
  14.200 +       include the following line of code somewhere before you call
  14.201 +       =app.start()=;
  14.202  
  14.203    #+begin_src java :exports code
  14.204  Capture.captureVideo(app, new File("/home/r/record.flv"));
  14.205 @@ -384,8 +383,9 @@
  14.206    
  14.207  * COMMENT More Examples
  14.208  ** COMMENT Hello Physics
  14.209 -=HelloVideo= is boring. Let's add some video capturing to =HelloPhysics=
  14.210 -and create something fun!
  14.211 +
  14.212 +=HelloVideo= is boring. Let's add some video capturing to
  14.213 +=HelloPhysics= and create something fun!
  14.214  
  14.215  This example is a modified version of =HelloPhysics= that creates four
  14.216  simultaneous views of the same scene of cannonballs careening into a
  14.217 @@ -579,7 +579,7 @@
  14.218  four points of view are simultaneously recorded and then glued
  14.219  together later.
  14.220  
  14.221 - JME3 Xuggle Aurellem video capture
  14.222 +JME3 Xuggle Aurellem video capture
  14.223   
  14.224   
  14.225  * Showcase of recorded videos
  14.226 @@ -757,31 +757,3 @@
  14.227   videoscale ! ffmpegcolorspace ! \
  14.228   video/x-raw-yuv, width=640, height=480, framerate=25/1 ! \
  14.229   videobox right=-640 ! mix.
  14.230 -
  14.231 -
  14.232 -
  14.233 -
  14.234 -
  14.235 -
  14.236 -
  14.237 -
  14.238 -
  14.239 -
  14.240 -
  14.241 -
  14.242 -
  14.243 -
  14.244 -
  14.245 -
  14.246 -
  14.247 -
  14.248 -
  14.249 -
  14.250 -
  14.251 -
  14.252 -
  14.253 -
  14.254 -
  14.255 -
  14.256 -
  14.257 -
    15.1 --- a/org/hearing.org	Sat Feb 18 02:06:06 2012 -0600
    15.2 +++ b/org/hearing.org	Sat Feb 18 02:07:40 2012 -0600
    15.3 @@ -1018,43 +1018,43 @@
    15.4  #+begin_src clojure 
    15.5  (in-ns 'cortex.test.hearing)
    15.6  
    15.7 -(cortex.import/mega-import-jme3)
    15.8 -(import java.io.File)
    15.9 -
   15.10 -(use 'cortex.body)
   15.11 -
   15.12 -(defn test-worm-hearing []
   15.13 -  (let [the-worm (doto (worm) (body!))
   15.14 -        hearing (hearing! the-worm)
   15.15 -        hearing-display (view-hearing)
   15.16 +(defn test-worm-hearing
   15.17 +  ([] (test-worm-hearing false))
   15.18 +  ([record?] 
   15.19 +     (let [the-worm (doto (worm) (body!))
   15.20 +           hearing (hearing! the-worm)
   15.21 +           hearing-display (view-hearing)
   15.22 +           
   15.23 +           tone (AudioNode. (asset-manager)
   15.24 +                            "Sounds/pure.wav" false)
   15.25 +           
   15.26 +           hymn (AudioNode. (asset-manager) 
   15.27 +                            "Sounds/ear-and-eye.wav" false)]
   15.28 +       (world
   15.29 +        (nodify [the-worm (floor)])
   15.30 +        (merge standard-debug-controls
   15.31 +               {"key-return"
   15.32 +                (fn [_ value]
   15.33 +                  (if value (.play tone)))
   15.34 +                "key-l"
   15.35 +                (fn [_ value]
   15.36 +                  (if value (.play hymn)))})
   15.37 +        (fn [world]
   15.38 +          (light-up-everything world)
   15.39 +          (if record?
   15.40 +            (do 
   15.41 +              (com.aurellem.capture.Capture/captureVideo
   15.42 +               world
   15.43 +               (File."/home/r/proj/cortex/render/worm-audio/frames"))
   15.44 +              (com.aurellem.capture.Capture/captureAudio
   15.45 +               world
   15.46 +               (File."/home/r/proj/cortex/render/worm-audio/audio.wav")))))
   15.47          
   15.48 -        tone (AudioNode. (asset-manager)
   15.49 -                         "Sounds/pure.wav" false)
   15.50 -        
   15.51 -        hymn (AudioNode. (asset-manager) 
   15.52 -                         "Sounds/ear-and-eye.wav" false)]
   15.53 -    (world
   15.54 -     (nodify [the-worm (floor)])
   15.55 -     (merge standard-debug-controls
   15.56 -            {"key-return"
   15.57 -             (fn [_ value]
   15.58 -               (if value (.play tone)))
   15.59 -             "key-l"
   15.60 -             (fn [_ value]
   15.61 -               (if value (.play hymn)))})
   15.62 -     (fn [world]
   15.63 -       (light-up-everything world)
   15.64 -       (com.aurellem.capture.Capture/captureVideo
   15.65 -        world
   15.66 -        (File."/home/r/proj/cortex/render/worm-audio/frames"))
   15.67 -       (com.aurellem.capture.Capture/captureAudio
   15.68 -        world
   15.69 -        (File."/home/r/proj/cortex/render/worm-audio/audio.wav")))
   15.70 -     
   15.71 -     (fn [world tpf]
   15.72 -       (hearing-display
   15.73 -        (map #(% world) hearing)
   15.74 -        (File. "/home/r/proj/cortex/render/worm-audio/hearing-data"))))))
   15.75 +        (fn [world tpf]
   15.76 +          (hearing-display
   15.77 +           (map #(% world) hearing)
   15.78 +           (if record?
   15.79 +             (File. "/home/r/proj/cortex/render/worm-audio/hearing-data"))))))))
   15.80  #+end_src
   15.81  
   15.82  In this test, I load the worm with its newly formed ear and let it
   15.83 @@ -1154,11 +1154,13 @@
   15.84  #+name: test-header
   15.85  #+begin_src clojure
   15.86  (ns cortex.test.hearing
   15.87 -  (:use (cortex world util hearing))
   15.88 +  (:use (cortex world util hearing body))
   15.89    (:use cortex.test.body)
   15.90    (:import (com.jme3.audio AudioNode Listener))
   15.91 +  (:import java.io.File)
   15.92    (:import com.jme3.scene.Node
   15.93 -	   com.jme3.system.AppSettings))
   15.94 +	   com.jme3.system.AppSettings
   15.95 +           com.jme3.math.Vector3f))
   15.96  #+end_src
   15.97  
   15.98  * Source Listing
    16.1 --- a/org/ideas.org	Sat Feb 18 02:06:06 2012 -0600
    16.2 +++ b/org/ideas.org	Sat Feb 18 02:07:40 2012 -0600
    16.3 @@ -70,10 +70,11 @@
    16.4   - [X] proprioception sensor map in the style of the other senses -- day
    16.5   - [X] refactor integration code to distribute to each of the senses
    16.6         -- day
    16.7 - - [ ] create video showing all the senses for Winston -- 2 days
    16.8 + - [X] create video showing all the senses for Winston -- 2 days
    16.9 + - [ ] spellchecking !!!!!
   16.10   - [ ] send package to friends for critiques -- 2 days
   16.11 - - [ ] fix videos that were encoded wrong, test on InterNet Explorer.
   16.12 - - [ ] redo videos vision with new collapse code
   16.13 + - [X] fix videos that were encoded wrong, test on InterNet Explorer.
   16.14 + - [X] redo videos vision with new collapse code
   16.15   - [X] find a topology that looks good. (maybe nil topology?)
   16.16   - [X] fix red part of touch cube in video and image
   16.17   - [ ] write summary of project for Winston            \
    17.1 --- a/org/integration.org	Sat Feb 18 02:06:06 2012 -0600
    17.2 +++ b/org/integration.org	Sat Feb 18 02:07:40 2012 -0600
    17.3 @@ -1,4 +1,4 @@
    17.4 -#+title: First attempt at a creature!
    17.5 +#+title: 
    17.6  #+author: Robert McIntyre
    17.7  #+email: rlm@mit.edu
    17.8  #+description: 
    17.9 @@ -6,72 +6,235 @@
   17.10  #+SETUPFILE: ../../aurellem/org/setup.org
   17.11  #+INCLUDE: ../../aurellem/org/level-0.org
   17.12  
   17.13 +* Integration 
   17.14  
   17.15 +This is the ultimate test which features all of the senses that I've
   17.16 +made so far. The blender file for the creature serves as an example of
   17.17 +a fully equipped creature in terms of senses. You can find it [[../assets/Models/test-creature/hand.blend][here]].
   17.18  
   17.19  
   17.20 -* Intro 
   17.21 -So far, I've made the following senses -- 
   17.22 - - Vision
   17.23 - - Hearing
   17.24 - - Touch
   17.25 - - Proprioception
   17.26 +#+begin_html
   17.27 +<div class="figure">
   17.28 +<video controls="controls" width="755">
   17.29 +  <source src="../video/hand.ogg" type="video/ogg"
   17.30 +	  preload="none" poster="../images/aurellem-1280x480.png" />
   17.31 +</video>
   17.32 +<p>Simulated Senses in a Virtual Environment</p>
   17.33 +</div>
   17.34 +#+end_html
   17.35  
   17.36 -And one effector: 
   17.37 - - Movement
   17.38 -
   17.39 -However, the code so far has only enabled these senses, but has not
   17.40 -actually implemented them.  For example, there is still a lot of work
   17.41 -to be done for vision. I need to be able to create an /eyeball/ in
   17.42 -simulation that can be moved around and see the world from different
   17.43 -angles. I also need to determine weather to use log-polar or cartesian
   17.44 -for the visual input, and I need to determine how/wether to
   17.45 -disceritise the visual input.
   17.46 -
   17.47 -I also want to be able to visualize both the sensors and the
   17.48 -effectors in pretty pictures. This semi-retarted creature will be my
   17.49 -first attempt at bringing everything together.
   17.50 -
   17.51 -* The creature's body
   17.52 -
   17.53 -Still going to do an eve-like body in blender, but due to problems
   17.54 -importing the joints, etc into jMonkeyEngine3, I'm going to do all
   17.55 -the connecting here in clojure code, using the names of the individual
   17.56 -components and trial and error. Later, I'll maybe make some sort of
   17.57 -creature-building modifications to blender that support whatever
   17.58 -discritized senses I'm going to make.
   17.59 +* Generating the Video
   17.60  
   17.61  #+name: integration
   17.62  #+begin_src clojure 
   17.63 -(ns cortex.integration
   17.64 +(ns cortex.test.integration
   17.65    "let's play!"
   17.66    {:author "Robert McIntyre"}
   17.67 -  (:use (cortex world util body
   17.68 -                hearing touch vision sense proprioception movement))
   17.69 +  (:use (cortex world util body sense
   17.70 +                hearing touch vision proprioception movement))
   17.71    (:import (com.jme3.math ColorRGBA Vector3f))
   17.72 +  (:import java.io.File)
   17.73    (:import com.jme3.audio.AudioNode)
   17.74    (:import com.aurellem.capture.RatchetTimer))
   17.75  
   17.76 -(def hand "Models/creature1/one.blend")
   17.77 +(dorun (cortex.import/mega-import-jme3))
   17.78 +(rlm.rlm-commands/help)
   17.79  
   17.80 -(def worm "Models/creature1/try-again.blend")
   17.81 +(def hand "Models/test-creature/hand.blend")
   17.82  
   17.83 -(defn test-creature [thing]
   17.84 -  (let [x-axis
   17.85 -        (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red)
   17.86 -        y-axis
   17.87 -        (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green)
   17.88 -        z-axis
   17.89 -        (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue)
   17.90 +(def output-base (File. "/home/r/proj/cortex/render/hand"))
   17.91 +#+end_src
   17.92  
   17.93 -        me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
   17.94 -        bell (AudioNode. (asset-manager)
   17.95 -                         "Sounds/pure.wav" false)
   17.96 +For this demonstration I have to manually drive the muscles of the
   17.97 +hand. I do this by creating a little mini-language to describe
   17.98 +simulated muscle contraction.
   17.99  
  17.100 -        fix-display
  17.101 -        (runonce (fn [world]
  17.102 -                   (add-camera! world (.getCamera world) no-op)))
  17.103 -        creature (doto (load-blender-model thing) (body!))
  17.104 +#+name: integration-2
  17.105 +#+begin_src clojure
  17.106 +(defn motor-control-program
  17.107 +  "Create a function which will execute the motor script"
  17.108 +  [muscle-positions
  17.109 +   script]
  17.110 +  (let [current-frame (atom -1)
  17.111 +        keyed-script (group-by first script)
  17.112 +        current-forces (atom {}) ]
  17.113 +    (fn [effectors]
  17.114 +      (let [indexed-effectors (vec effectors)]
  17.115 +        (dorun 
  17.116 +         (for [[_ part force] (keyed-script (swap! current-frame inc))]
  17.117 +           (swap! current-forces (fn [m] (assoc m part force)))))
  17.118 +        (doall (map (fn [effector power]
  17.119 +                      (effector (int power)))
  17.120 +                    effectors
  17.121 +                    (map #(@current-forces % 0) muscle-positions)))))))
  17.122  
  17.123 +(def muscle-positions
  17.124 +  [:pointer-2-e
  17.125 +   :pointer-2-f
  17.126 +   :thumb-1
  17.127 +   :thumb-1
  17.128 +   :pointer-1-e
  17.129 +   :pointer-1-f
  17.130 +   :thumb-2-e
  17.131 +   :thumb-2-f
  17.132 +   :middle-1-e
  17.133 +   :middle-1-f
  17.134 +   :pointer-3-f
  17.135 +   :pointer-3-e
  17.136 +   :middle-2-e
  17.137 +   :middle-2-f
  17.138 +   :middle-3-f
  17.139 +   :middle-3-e
  17.140 +   :pinky-2-e
  17.141 +   :pinky-2-f
  17.142 +   :pinky-3-f
  17.143 +   :pinky-3-e
  17.144 +   :ring-3-e
  17.145 +   :ring-3-f
  17.146 +   :ring-2-f
  17.147 +   :ring-2-e
  17.148 +   :ring-1-e
  17.149 +   :ring-1-f
  17.150 +   :thumb-1-e
  17.151 +   :thumb-1-f
  17.152 +   :pinky-1-f
  17.153 +   :pinky-1-e])
  17.154 +
  17.155 +(def full 9001)
  17.156 +
  17.157 +
  17.158 +;; Coreography:
  17.159 +
  17.160 +;; Let the hand fall palm-up
  17.161 +
  17.162 +;; it curls its phalanges, starting with the pinky.
  17.163 +
  17.164 +;; it lets its phalanges fall back down.
  17.165 +
  17.166 +;; block falls down onto the hand, accompanied by a sound. The block
  17.167 +;; can be seen by the hand's eye.
  17.168 +
  17.169 +;; hand FORCEFULLY catapults the  block so that it hits the camera.
  17.170 +
  17.171 +
  17.172 +;; the systax here is [keyframe body-part force]
  17.173 +(def move-fingers
  17.174 +  [[300 :pinky-3-f 50]
  17.175 +   [320 :pinky-2-f 80]
  17.176 +   [340 :pinky-1-f 100]
  17.177 +
  17.178 +   [310 :ring-3-f 100]
  17.179 +   [330 :ring-2-f 120]
  17.180 +   [350 :ring-1-f 140]
  17.181 +
  17.182 +   [330 :middle-3-f 120]
  17.183 +   [340 :middle-2-f 120]
  17.184 +   [360 :middle-1-f 30]
  17.185 +
  17.186 +   [350 :pointer-3-f 120]
  17.187 +   [360 :pointer-2-f 120]
  17.188 +   [380 :pointer-1-f 30]
  17.189 +
  17.190 +   [800 :pinky-3-f 0]
  17.191 +   [800 :pinky-2-f 0]
  17.192 +   [800 :pinky-1-f  0]
  17.193 +
  17.194 +   [800 :ring-3-f  0]
  17.195 +   [800 :ring-2-f  0]
  17.196 +   [800 :ring-1-f  0]
  17.197 +
  17.198 +   [800 :middle-3-f  0]
  17.199 +   [800 :middle-2-f  0]
  17.200 +   [800 :middle-1-f 0]
  17.201 +
  17.202 +   [800 :pointer-3-f  0]
  17.203 +   [800 :pointer-2-f  0]
  17.204 +   [800 :pointer-1-f 0]
  17.205 +
  17.206 +   
  17.207 +   [800 :pinky-3-e 50]
  17.208 +   [800 :pinky-2-e 80]
  17.209 +   [800 :pinky-1-e 100]
  17.210 +
  17.211 +   [800 :ring-3-e 100]
  17.212 +   [800 :ring-2-e 120]
  17.213 +   [800 :ring-1-e 140]
  17.214 +
  17.215 +   [800 :middle-3-e 120]
  17.216 +   [800 :middle-2-e 120]
  17.217 +   [800 :middle-1-e 30]
  17.218 +
  17.219 +   [800 :pointer-3-e 120]
  17.220 +   [800 :pointer-2-e 120]
  17.221 +   [800 :pointer-1-e 30]
  17.222 +
  17.223 +   [870 :pinky-3-e 0]
  17.224 +   [870 :pinky-2-e 0]
  17.225 +   [870 :pinky-1-e  0]
  17.226 +
  17.227 +   [870 :ring-3-e  0]
  17.228 +   [870 :ring-2-e  0]
  17.229 +   [870 :ring-1-e  0]
  17.230 +
  17.231 +   [870 :middle-3-e  0]
  17.232 +   [870 :middle-2-e  0]
  17.233 +   [870 :middle-1-e 0]
  17.234 +
  17.235 +   [870 :pointer-3-e  0]
  17.236 +   [870 :pointer-2-e  0]
  17.237 +   [870 :pointer-1-e 0]
  17.238 +
  17.239 +   [1500 :pointer-1-f full]
  17.240 +   [1500 :pointer-2-f full]
  17.241 +   [1500 :pointer-3-f full]
  17.242 +   
  17.243 +   [1500 :middle-1-f full]
  17.244 +   [1500 :middle-2-f full]
  17.245 +   [1500 :middle-3-f full]
  17.246 +   
  17.247 +   [1510 :pointer-1-f 0]
  17.248 +   [1510 :pointer-2-f 0]
  17.249 +   [1510 :pointer-3-f 0]
  17.250 +   
  17.251 +   [1510 :middle-1-f 0]
  17.252 +   [1510 :middle-2-f 0]
  17.253 +   [1510 :middle-3-f 0]
  17.254 +   ])
  17.255 +
  17.256 +(defn gen-summon-ball [debug?]
  17.257 +  (let [wait (atom 1100)]
  17.258 +    (fn [world]
  17.259 +      (if (= 0 (swap! wait dec))
  17.260 +        (let [brick
  17.261 +              (box 0.8 0.8 0.8 :mass 0.05
  17.262 +                                :position (Vector3f. -0.5 0 0.5)
  17.263 +                                :color (ColorRGBA/Red))
  17.264 +              bell (AudioNode. (asset-manager)
  17.265 +                               "Sounds/pure.wav" false)]
  17.266 +          (.play bell)
  17.267 +          (if debug?
  17.268 +            (.addControl
  17.269 +             brick
  17.270 +             (proxy [AbstractControl] []
  17.271 +               (controlUpdate [tpf]
  17.272 +                 (println-repl (.getWorldTranslation brick)))
  17.273 +               (controlRender [_ _]))))
  17.274 +          (add-element world brick))))))
  17.275 +
  17.276 +(import com.aurellem.capture.Capture)
  17.277 +
  17.278 +(defn test-everything! 
  17.279 +  ([] (test-everything! false))
  17.280 +  ([record?]
  17.281 +  (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
  17.282 +
  17.283 +        base (File. "/home/r/proj/cortex/render/hand")
  17.284 +        
  17.285 +        
  17.286 +        creature (doto (load-blender-model hand) 
  17.287 +                   (body!))
  17.288 +
  17.289 +        summon-ball (gen-summon-ball false)
  17.290          ;;;;;;;;;;;;  Sensors/Effectors  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17.291          touch (touch! creature)
  17.292          touch-display (view-touch)
  17.293 @@ -85,69 +248,466 @@
  17.294          prop (proprioception! creature)
  17.295          prop-display (view-proprioception)
  17.296  
  17.297 -        muscle-exertion (atom 0)
  17.298 +        control-script (motor-control-program
  17.299 +                        muscle-positions move-fingers)
  17.300          muscles (movement! creature)
  17.301 -        muscle-display (view-movement)]
  17.302 +        muscle-display (view-movement)
  17.303 +        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17.304  
  17.305 -    (apply
  17.306 -     world
  17.307 -     (with-movement
  17.308 -       (.getChild creature "worm-21")
  17.309 -       ["key-r" "key-t"
  17.310 -        "key-f" "key-g"
  17.311 -        "key-v" "key-b"]
  17.312 -       [10 10 10 10 1 1]
  17.313 -       [(nodify [creature
  17.314 -                 (box 10 2 10 :position (Vector3f. 0 -9 0)
  17.315 -                      :color ColorRGBA/Gray :mass 0)
  17.316 -                 x-axis y-axis z-axis
  17.317 -                 me])
  17.318 -        (merge standard-debug-controls
  17.319 -               {"key-return"
  17.320 -                (fn [_ value]
  17.321 -                  (if value
  17.322 -                    (do
  17.323 -                      (println-repl "play-sound")
  17.324 -                      (.play bell))))
  17.325 -                "key-h"
  17.326 -                (fn [_ value]
  17.327 -                  (if value
  17.328 -                    (swap!  muscle-exertion (partial + 20))))
  17.329 -                "key-n"
  17.330 -                (fn [_ value]
  17.331 -                  (if value
  17.332 -                    (swap! muscle-exertion (fn [v] (- v 20)))))})
  17.333 -        (fn [world]
  17.334 -          (light-up-everything world)
  17.335 -          (enable-debug world)
  17.336 -          (add-camera! world
  17.337 -                       (add-eye! creature
  17.338 -                                 (.getChild 
  17.339 -                                  (.getChild creature "eyes") "eye"))
  17.340 -                   (comp (view-image) BufferedImage!))
  17.341 -          (.setTimer world (RatchetTimer. 60))
  17.342 -          (speed-up world)
  17.343 -          (set-gravity world (Vector3f. 0 0 0))
  17.344 -          (comment 
  17.345 -            (com.aurellem.capture.Capture/captureVideo
  17.346 -             world (file-str "/home/r/proj/ai-videos/hand"))))
  17.347 -        (fn [world tpf]
  17.348 -          (prop-display (prop))
  17.349 -          (touch-display (map #(% (.getRootNode world)) touch))
  17.350 -          (vision-display (map #(% world) vision))
  17.351 -          (hearing-display (map #(% world) hearing))
  17.352 -          (muscle-display (map #(% @muscle-exertion) muscles))
  17.353 -          (.setLocalTranslation me (.getLocation (.getCamera world)))
  17.354 -          (fix-display world))]))))
  17.355 +        fix-display (gen-fix-display)]
  17.356 +    (world
  17.357 +     (nodify [creature
  17.358 +              (box 10 2 10 :position (Vector3f. 0 -9 0)
  17.359 +                   :color ColorRGBA/Gray :mass 0)
  17.360 +              me])
  17.361 +     standard-debug-controls
  17.362 +    
  17.363 +     (fn [world]
  17.364 +       (.setTimer world (RatchetTimer. 60))
  17.365 +       (position-camera
  17.366 +        world (Vector3f. -0.13217318, 5.816415, -5.3089414)
  17.367 +        (Quaternion. 0.55685693, 0.0042774677, -0.0028673497, 0.83059245))
  17.368 +
  17.369 +       (light-up-everything world)
  17.370 +       (enable-debug world)
  17.371 +       (add-camera! world
  17.372 +                    (add-eye! creature
  17.373 +                              (.getChild 
  17.374 +                               (.getChild creature "eyes") "eye"))
  17.375 +                    (comp (view-image) BufferedImage!))
  17.376 +
  17.377 +       (if record?
  17.378 +         (Capture/captureVideo
  17.379 +          world (File. base "main")))
  17.380 +       (if record?
  17.381 +         (Capture/captureAudio
  17.382 +          world (File. base "main.wav"))))
  17.383 +     (fn [world tpf]
  17.384 +       (prop-display
  17.385 +        (prop)
  17.386 +        (if record? (File. base "proprio")))             
  17.387 +       (touch-display
  17.388 +        (map #(% (.getRootNode world)) touch)
  17.389 +        (if record? (File. base "touch")))
  17.390 +       (vision-display
  17.391 +        (map #(% world) vision)
  17.392 +        (if record? (File. base "vision")))
  17.393 +       (hearing-display
  17.394 +        (map #(% world) hearing)
  17.395 +        (if record? (File. base "hearing")))
  17.396 +       (muscle-display
  17.397 +        (control-script muscles)
  17.398 +        (if record? (File. base "muscle")))
  17.399 +         
  17.400 +       (summon-ball world)
  17.401 +       
  17.402 +       (.setLocalTranslation me (.getLocation (.getCamera world)))
  17.403 +       (fix-display world))))))
  17.404  #+end_src
  17.405  
  17.406 -#+results: body-1
  17.407 -: #'cortex.silly/follow-test
  17.408 +** ImageMagick / ffmpeg
  17.409 +
  17.410 +Just a bunch of calls to imagemagick to arrange the data that
  17.411 +=test-everything!= produces.
  17.412 +
  17.413 +#+name: magick-8
  17.414 +#+begin_src clojure
  17.415 +(ns cortex.video.magick8
  17.416 +  (:import java.io.File)
  17.417 +  (:use clojure.contrib.shell-out))
  17.418 +
  17.419 +(comment
  17.420 +;; list of touch targets
  17.421 +0  middle-11 
  17.422 +1  middle-21 
  17.423 +2  middle-31
  17.424 +3  pinky-11
  17.425 +4  pinky-21
  17.426 +5  pinky-31
  17.427 +6  pointer-11
  17.428 +7  pointer-21
  17.429 +8  pointer-31
  17.430 +9  ring-11
  17.431 +10 ring-21
  17.432 +11 ring-31
  17.433 +12 thumb-11
  17.434 +13 thumb-2.0011 
  17.435 +
  17.436 +
  17.437 +;; list of vision targets
  17.438 +0  :all
  17.439 +1  :green
  17.440 +2  :blue
  17.441 +3  :red 
  17.442 +
  17.443 +;; list of proprio targets
  17.444 +0  middle-11 -> middle-21
  17.445 +1  middle-21 -> middle-31
  17.446 +2  thumb-11 -> thumb-2.0011
  17.447 +3  pointer-11 -> pointer-21
  17.448 +4  pointer-21 -> pointer-31
  17.449 +5  ring-21 -> ring-31
  17.450 +6  ring-11 -> ring-21
  17.451 +7  pinky-21 -> pinky-31
  17.452 +8  pinky-11 -> pinky-21
  17.453 +9  middle-11 -> palm1
  17.454 +10 pinky-11 -> palm1
  17.455 +11 palm1 -> pointer-11
  17.456 +12 palm1 -> ring-11
  17.457 +13 palm1 -> thumb-11
  17.458 +
  17.459 +
  17.460 +;; list of muscle targets
  17.461 +0  :pointer-2-e
  17.462 +1  :pointer-2-f
  17.463 +2  :thumb-1
  17.464 +3  :thumb-1
  17.465 +4  :pointer-1-e
  17.466 +5  :pointer-1-f
  17.467 +6  :thumb-2-e
  17.468 +7  :thumb-2-f
  17.469 +8  :middle-1-e
  17.470 +9  :middle-1-f
  17.471 +10 :pointer-3-f
  17.472 +11 :pointer-3-e
  17.473 +12 :middle-2-e
  17.474 +13 :middle-2-f
  17.475 +14 :middle-3-f
  17.476 +15 :middle-3-e
  17.477 +16 :pinky-2-e
  17.478 +17 :pinky-2-f
  17.479 +18 :pinky-3-f
  17.480 +19 :pinky-3-e
  17.481 +20 :ring-3-e
  17.482 +21 :ring-3-f
  17.483 +22 :ring-2-f
  17.484 +23 :ring-2-e
  17.485 +24 :ring-1-e
  17.486 +25 :ring-1-f
  17.487 +26 :thumb-1-e
  17.488 +27 :thumb-1-f
  17.489 +28 :pinky-1-f
  17.490 +29 :pinky-1-e
  17.491 +)
  17.492 +
  17.493 +(def base (File. "/home/r/proj/cortex/render/hand"))
  17.494 +
  17.495 +(defn prepare-muscle [muscle]
  17.496 +  ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"])
  17.497 +
  17.498 +(defn prepare-touch [touch]
  17.499 +  ["(" touch "-rotate" "180" ")"])
  17.500 +
  17.501 +(defn generate-top-finger [tip-flexor tip-extensor tip
  17.502 +                           joint-2-3
  17.503 +                           mid-flexor mid-extensor mid
  17.504 +                           joint-1-2]
  17.505 +  ["("
  17.506 +   "-size" "113x357" "xc:transparent"
  17.507 +   (prepare-muscle tip-flexor)   "-geometry" "+0+7"    "-composite"
  17.508 +   (prepare-muscle tip-extensor) "-geometry" "+98+7"   "-composite"
  17.509 +   (prepare-touch tip)           "-geometry" "+18+0"   "-composite"
  17.510 +
  17.511 +   joint-2-3                     "-geometry" "+32+79" "-composite"
  17.512 +
  17.513 +   (prepare-muscle mid-flexor)   "-geometry" "+19+131"    "-composite"
  17.514 +   (prepare-muscle mid-extensor) "-geometry" "+80+131"   "-composite"
  17.515 +   (prepare-touch mid)           "-geometry" "+39+133"   "-composite"
  17.516 +   
  17.517 +   joint-1-2                     "-geometry" "+32+193" "-composite"
  17.518 +   ")"])
  17.519 +
  17.520 +(defn file-names [#^File dir]
  17.521 +   (map #(.getCanonicalPath %) (next (sort (file-seq dir)))))
  17.522 +
  17.523 +(defn file-groups [& paths]
  17.524 +  (apply (partial map list )
  17.525 +         (map (comp file-names #(File. base %))
  17.526 +              paths)))
  17.527 +  
  17.528 +(defn pinky []
  17.529 +  (file-groups
  17.530 +   "muscle/18"
  17.531 +   "muscle/19"
  17.532 +   "touch/5"
  17.533 +   "proprio/7"
  17.534 +   
  17.535 +   "muscle/17"
  17.536 +   "muscle/16"
  17.537 +   "touch/4"
  17.538 +   "proprio/8"
  17.539 +   
  17.540 +   "muscle/28"
  17.541 +   "muscle/29"
  17.542 +   "touch/3"
  17.543 +   "proprio/10"))
  17.544 +
  17.545 +(defn ring []
  17.546 +  (file-groups
  17.547 +   "muscle/21"
  17.548 +   "muscle/20"
  17.549 +   "touch/11"
  17.550 +   "proprio/5"
  17.551 +
  17.552 +   "muscle/22"
  17.553 +   "muscle/23"
  17.554 +   "touch/10"
  17.555 +   "proprio/6"
  17.556 +
  17.557 +   "muscle/25"
  17.558 +   "muscle/24"
  17.559 +   "touch/9"
  17.560 +   "proprio/12"))
  17.561 +
  17.562 +(defn middle []
  17.563 +  (file-groups
  17.564 +   "muscle/14"
  17.565 +   "muscle/15"
  17.566 +   "touch/2"
  17.567 +   "proprio/1"
  17.568 +
  17.569 +   "muscle/13"
  17.570 +   "muscle/12"
  17.571 +   "touch/1"
  17.572 +   "proprio/0"
  17.573 +
  17.574 +   "muscle/9"
  17.575 +   "muscle/8"
  17.576 +   "touch/0"
  17.577 +   "proprio/9"))
  17.578 +
  17.579 +(defn pointer []
  17.580 +  (file-groups
  17.581 +   "muscle/10"
  17.582 +   "muscle/11"
  17.583 +   "touch/8"
  17.584 +   "proprio/4"
  17.585 +
  17.586 +   "muscle/1"
  17.587 +   "muscle/0"
  17.588 +   "touch/7"
  17.589 +   "proprio/3"
  17.590 +
  17.591 +   "muscle/5"
  17.592 +   "muscle/4"
  17.593 +   "touch/6"
  17.594 +   "proprio/11"))
  17.595 +
  17.596 +(defn thumb []
  17.597 +  (file-groups
  17.598 +   "muscle/7"
  17.599 +   "muscle/6"
  17.600 +   "touch/13"
  17.601 +   "proprio/2"
  17.602 +
  17.603 +   "muscle/27"
  17.604 +   "muscle/26"
  17.605 +   "muscle/3"
  17.606 +   "muscle/2"
  17.607 +   "touch/12"
  17.608 +   "proprio/13"))
  17.609 +
  17.610 +(defn generate-finger
  17.611 +  [tip-flexor tip-extensor tip
  17.612 +   joint-2-3
  17.613 +   mid-flexor mid-extensor mid
  17.614 +   joint-1-2
  17.615 +   base-flexor base-extensor base
  17.616 +   joint-palm-1]
  17.617 +  ["("
  17.618 +   "-size" "113x357" "xc:transparent"
  17.619 +   (generate-top-finger
  17.620 +    tip-flexor  tip-extensor tip
  17.621 +    joint-2-3
  17.622 +    mid-flexor mid-extensor mid
  17.623 +    joint-1-2)                    "-geometry" "+0+0"      "-composite"
  17.624 +   (prepare-muscle base-flexor)   "-geometry" "+19+245"   "-composite"
  17.625 +   (prepare-muscle base-extensor) "-geometry" "+80+245"   "-composite"
  17.626 +   (prepare-touch base)           "-geometry" "+39+247"   "-composite"
  17.627 +   joint-palm-1                   "-geometry" "+32+307"   "-composite"
  17.628 +   ")"])
  17.629 +
  17.630 +(defn generate-thumb
  17.631 +  [tip-flexor tip-extensor tip
  17.632 +   joint-1-2
  17.633 +   mid-flexor mid-extensor mid-flexor-2 mid-extensor-2 mid
  17.634 +   joint-palm-1]
  17.635 +  ["("
  17.636 +   "-size" "113x357" "xc:transparent"
  17.637 +   (generate-top-finger
  17.638 +    tip-flexor  tip-extensor tip
  17.639 +    joint-1-2
  17.640 +    mid-flexor mid-extensor mid
  17.641 +    joint-palm-1)                   "-geometry" "+0+0"     "-composite"
  17.642 +   (prepare-muscle mid-flexor-2)    "-geometry" "+2+131"   "-composite"
  17.643 +   (prepare-muscle mid-extensor-2)  "-geometry" "+100+131" "-composite"
  17.644 +   ")"])
  17.645 +
  17.646 +(defn generate-hand
  17.647 +  [pinky-pieces
  17.648 +   ring-pieces
  17.649 +   middle-pieces
  17.650 +   pointer-pieces
  17.651 +   thumb-pieces]
  17.652 +  ["("
  17.653 +   "-size" "688x769" "xc:transparent"
  17.654 +   (apply generate-finger pinky-pieces)
  17.655 +   "-geometry" "+0+195" "-composite"
  17.656 +   (apply generate-finger ring-pieces)
  17.657 +   "-geometry" "+111+100" "-composite"
  17.658 +   (apply generate-finger middle-pieces)
  17.659 +   "-geometry" "+228+0"   "-composite"
  17.660 +   "(" (apply generate-thumb thumb-pieces) "-background" "#00000000"
  17.661 +   "-rotate" "45" ")"
  17.662 +   "-geometry" "+300+420" "-composite"
  17.663 +   (apply generate-finger pointer-pieces)
  17.664 +   "-geometry" "+350+96"  "-composite"
  17.665 +   ")"])
  17.666 +
  17.667 +(defn generate-vision
  17.668 +  [all green blue red]
  17.669 +  ["("
  17.670 +   "-size" "204x192" "xc:transparent"
  17.671 +   all    "-geometry" "+0+0" "-composite"
  17.672 +   green  "-geometry" "+113+0" "-composite"
  17.673 +   blue   "-geometry" "+0+105" "-composite"
  17.674 +   red    "-geometry" "+113+105" "-composite"
  17.675 +   ")"])
  17.676 +  
  17.677 +(def test-muscle (File. base "muscle/0/0000000.png"))
  17.678 +(def test-proprio (File. base "proprio/0/0000000.png"))
  17.679 +(def test-tip (File. base "touch/2/0000000.png"))
  17.680 +(def test-mid (File. base "touch/0/0000000.png"))
  17.681 +(def test-vision (File. base "vision/0/0000000.png"))
  17.682 +(def test-hearing (File. base "hearing/0/0000000.png"))
  17.683 +(def test-main (File. base "main/0000000.png"))
  17.684 +
  17.685 +(def test-target (File. base "output.png"))
  17.686 +
  17.687 +(def background (File. base "background.png"))
  17.688 +
  17.689 +(use 'clojure.contrib.shell-out)
  17.690 +
  17.691 +(defn vision []
  17.692 +  (file-groups
  17.693 +   "vision/0"
  17.694 +   "vision/1"
  17.695 +   "vision/2"
  17.696 +   "vision/3"))
  17.697 +
  17.698 +(defn hearing []
  17.699 +  (file-names (File. base "hearing/0")))
  17.700 +
  17.701 +(defn main []
  17.702 +  (file-names (File. base "main")))
  17.703 +
  17.704 +(defn targets [dest max]
  17.705 +  (map
  17.706 +   (comp #(.getCanonicalPath %)
  17.707 +         #(File. (str base dest (format "%07d.png" %))))
  17.708 +   (range max)))
  17.709 +
  17.710 +
  17.711 +(defn final-image [main [all red green blue] hearing
  17.712 +                   pinky ring middle pointer thumb target]
  17.713 +  (println target)
  17.714 +  (apply
  17.715 +     sh
  17.716 +     (flatten
  17.717 +      ["convert"
  17.718 +       (.getCanonicalPath background)
  17.719 +       
  17.720 +       (generate-hand pinky ring middle pointer thumb)
  17.721 +       "-geometry" "+809+22" "-composite"
  17.722 +       
  17.723 +       (generate-vision all red green blue)
  17.724 +       "-geometry" "+974+599" "-composite"
  17.725 +
  17.726 +       hearing
  17.727 +       "-geometry" "+784+819" "-composite"
  17.728 +
  17.729 +       main
  17.730 +       "-geometry" "+78+202" "-composite"
  17.731 +              
  17.732 +       target])))
  17.733 +  
  17.734 +(defn combine-files []
  17.735 +  (dorun
  17.736 +   (pmap final-image
  17.737 +         (main)
  17.738 +         (vision)
  17.739 +         (hearing)
  17.740 +         (pinky)
  17.741 +         (ring)
  17.742 +         (middle)
  17.743 +         (pointer)
  17.744 +         (thumb)
  17.745 +         (targets "/out/" (count (main))))))
  17.746 +
  17.747 +(defn subtitles [] 
  17.748 +  (file-names (File. base "subs")))
  17.749 +
  17.750 +(defn outs []
  17.751 +  (file-names (File. base "out")))
  17.752 +
  17.753 +
  17.754 +(defn mix-subtitles []
  17.755 +  (let [subs (subtitles)
  17.756 +        targets (targets "/out-subs/" (count subs))
  17.757 +        overlay (.getCanonicalPath (File. base "output.png"))]
  17.758 +    (dorun 
  17.759 +     (pmap
  17.760 +      (fn [sub target]
  17.761 +        (sh
  17.762 +         "convert"
  17.763 +         overlay
  17.764 +         sub "-geometry" "+0+0" "-composite"
  17.765 +         target))
  17.766 +      subs targets))))
  17.767 +
  17.768 +(defn out-subtitles []
  17.769 +  (file-names (File. base "out-subs")))
  17.770 +                    
  17.771 +
  17.772 +(defn insert-subtitles []
  17.773 +  (let [subtitles (out-subtitles)
  17.774 +        outs (outs)
  17.775 +        targets (targets
  17.776 +                 "/final/"
  17.777 +                 (+ (count outs) (count subtitles)))]
  17.778 +    (dorun
  17.779 +     (pmap
  17.780 +      #(sh "cp" %1 %2)
  17.781 +      (concat subtitles outs) targets))))
  17.782 +
  17.783 +(defn generate-final []
  17.784 +  (combine-files)
  17.785 +   (mix-subtitles)
  17.786 +   (insert-subtitles))
  17.787 +#+end_src
  17.788 +
  17.789 +#+begin_src sh :results silent
  17.790 +cd /home/r/proj/cortex/render/hand
  17.791 +
  17.792 +sox --ignore-length main.wav main-delayed.wav delay 24 
  17.793 +
  17.794 +mogrify -resize 755x final/*
  17.795 +
  17.796 +ffmpeg -r 60 -i final/%07d.png -i main-delayed.wav -b:a 128k \
  17.797 +         -b:v 9000k -c:a libvorbis -c:v libtheora hand.ogg 
  17.798 +#+end_src
  17.799 +
  17.800 +
  17.801 +* Source Listing
  17.802 +  - [[../src/cortex/test/integration.clj][cortex.test.integration]]
  17.803 +  - [[../src/cortex/video/magick8.clj][cortex.video.magick8]]
  17.804 +  - [[../assets/Models/subtitles/hand.blend][subtitles/hand.blend]]
  17.805 +#+html: <ul> <li> <a href="../org/integration.org">This org file</a> </li> </ul>
  17.806 +  - [[http://hg.bortreb.com ][source-repository]]
  17.807  
  17.808  
  17.809  * COMMENT purgatory
  17.810  #+begin_src clojure
  17.811 -
  17.812  (defn bullet-trans* []
  17.813    (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red
  17.814                     :position (Vector3f. 5 0 0)
  17.815 @@ -308,10 +868,11 @@
  17.816    
  17.817  
  17.818  * COMMENT generate source
  17.819 -#+begin_src clojure :tangle ../src/cortex/integration.clj
  17.820 +#+begin_src clojure :tangle ../src/cortex/test/integration.clj
  17.821  <<integration>>
  17.822 +<<integration-2>>
  17.823  #+end_src
  17.824  
  17.825 -
  17.826 -  
  17.827 -
  17.828 +#+begin_src clojure :tangle ../src/cortex/video/magick8.clj
  17.829 +<<magick-8>>
  17.830 +#+end_src
    18.1 --- a/org/movement.org	Sat Feb 18 02:06:06 2012 -0600
    18.2 +++ b/org/movement.org	Sat Feb 18 02:07:40 2012 -0600
    18.3 @@ -14,31 +14,31 @@
    18.4  force in the human body at all!  (A straight line of force would
    18.5  correspond to some sort of jet or rocket propulsion.)
    18.6  
    18.7 -*(next paragraph is from memory and needs to be checked!)*
    18.8 -
    18.9 -In humans, muscles are composed of millions of sarcomeres, which can
   18.10 -contract to exert force. A single motor neuron might control 100-1,000
   18.11 -sarcomeres. When the motor neuron is engaged by the brain, it
   18.12 -activates all of the sarcomeres to which it is attached. Some motor
   18.13 -neurons command many sarcomeres, and some command only a few. The
   18.14 -spinal cord generally engages the motor neurons which control few
   18.15 -sarcomeres before the motor neurons which control many sarcomeres.
   18.16 -This recruitment stragety allows for percise movements at low
   18.17 -strength. The collection of all motor neurons that control a muscle is
   18.18 -called the motor pool. The brain essentially says "activate 30% of the
   18.19 -motor pool" and the spinal cord recruits motor neurons untill 30% are
   18.20 -activated. Since the distribution of power among motor neurons is
   18.21 -unequal and recruitment goes from weakest to strongest, the first 30%
   18.22 -of the motor pool might be 5% of the strength of the muscle.
   18.23 +In humans, muscles are composed of muscle fibers which can contract to
   18.24 +exert force. The muscle fibers which compose a muscle are partitioned
   18.25 +into discrete groups which are each controlled by a single alpha motor
   18.26 +neuton. A single alpha motor neuron might control as little as three
   18.27 +or as many as one thousand muscle fibers. When the alpha motor neuron
   18.28 +is engaged by the spinal cord, it activates all of the muscle fibers
   18.29 +to which it is attached. The spinal cord generally engages the alpha
   18.30 +motor neurons which control few muscle fibers before the motor neurons
   18.31 +which control many muscle fibers.  This recruitment stragety allows
   18.32 +for percise movements at low strength. The collection of all motor
   18.33 +neurons that control a muscle is called the motor pool. The brain
   18.34 +essentially says "activate 30% of the motor pool" and the spinal cord
   18.35 +recruits motor neurons untill 30% are activated. Since the
   18.36 +distribution of power among motor neurons is unequal and recruitment
   18.37 +goes from weakest to strongest, the first 30% of the motor pool might
   18.38 +be 5% of the strength of the muscle.
   18.39  
   18.40  My simulated muscles follow a similiar design: Each muscle is defined
   18.41  by a 1-D array of numbers (the "motor pool"). Each entry in the array
   18.42 -represents a motor neuron which controlls a number of sarcomeres equal
   18.43 -to the value of the entry. A muscle also has a scalar :strength factor
   18.44 -which determines the total force the muscle can exert when all motor
   18.45 -neurons are activated.  The effector function for a muscle takes a
   18.46 -number to index into the motor pool, and that number "activates" all
   18.47 -the motor neurons whose index is lower or equal to the number.  Each
   18.48 +represents a motor neuron which controlls a number of muscle fibers
   18.49 +equal to the value of the entry. Each muscle has a scalar strength
   18.50 +factor which determines the total force the muscle can exert when all
   18.51 +motor neurons are activated.  The effector function for a muscle takes
   18.52 +a number to index into the motor pool, and then "activates" all the
   18.53 +motor neurons whose index is lower or equal to the number.  Each
   18.54  motor-neuron will apply force in proportion to its value in the array.
   18.55  Lower values cause less force.  The lower values can be put at the
   18.56  "beginning" of the 1-D array to simulate the layout of actual human
   18.57 @@ -118,13 +118,14 @@
   18.58          
   18.59          pool (motor-pool muscle)
   18.60          pool-integral (reductions + pool)
   18.61 -        force-index
   18.62 +        forces
   18.63          (vec (map  #(float (* strength (/ % (last pool-integral))))
   18.64                pool-integral))
   18.65          control (.getControl target RigidBodyControl)]
   18.66 +    (println-repl (.getName target) axis)
   18.67      (fn [n]
   18.68        (let [pool-index (max 0 (min n (dec (count pool))))
   18.69 -            force (force-index pool-index)]
   18.70 +            force (forces pool-index)]
   18.71          (.applyTorque control (.mult axis force))
   18.72          (float (/ force strength))))))
   18.73  
   18.74 @@ -175,9 +176,16 @@
   18.75  
   18.76  * Adding Touch to the Worm
   18.77  
   18.78 +To the worm, I add two new nodes which describe a single muscle. 
   18.79 +
   18.80 +#+attr_html: width=755
   18.81 +#+caption: The node highlighted in orange is the parent node of all muscles in the worm.  The arrow highlighted in yellow represents the creature's single muscle, which moves the top segment.  The other nodes which are not highlighted are joints, eyes, and ears.
   18.82 +[[../images/worm-with-muscle.png]]
   18.83 +
   18.84 +#+name: test-movement
   18.85  #+begin_src clojure
   18.86 -(defn test-movement
   18.87 -  ([] (test-movement false))
   18.88 +(defn test-worm-movement
   18.89 +  ([] (test-worm-movement false))
   18.90    ([record?]
   18.91       (let [creature (doto (worm) (body!))
   18.92  
   18.93 @@ -211,11 +219,7 @@
   18.94                          (Vector3f. -4.912815, 2.004171, 0.15710819))
   18.95            (.setRotation (.getCamera world)
   18.96                          (Quaternion. 0.13828252, 0.65516764, 
   18.97 -                                     -0.12370994, 0.7323449))
   18.98 -
   18.99 -          (comment 
  18.100 -            (com.aurellem.capture.Capture/captureVideo
  18.101 -             world (file-str "/home/r/proj/ai-videos/hand"))))
  18.102 +                                     -0.12370994, 0.7323449)))
  18.103          (fn [world tpf]
  18.104            (muscle-display
  18.105             (map #(% @muscle-exertion) muscles)
  18.106 @@ -240,7 +244,6 @@
  18.107  </div>
  18.108  #+end_html
  18.109  
  18.110 -
  18.111  ** Making the Worm Muscles Video
  18.112  #+name: magick7
  18.113  #+begin_src clojure
  18.114 @@ -304,11 +307,9 @@
  18.115    (:import java.io.File)
  18.116    (:import java.awt.image.BufferedImage)
  18.117    (:import com.jme3.scene.Node)
  18.118 -  (:import com.jme3.math.Vector3f)
  18.119 +  (:import (com.jme3.math Quaternion Vector3f))
  18.120    (:import (com.aurellem.capture Capture RatchetTimer))
  18.121    (:import com.jme3.bullet.control.RigidBodyControl))
  18.122 -
  18.123 -(cortex.import/mega-import-jme3)
  18.124  #+end_src
  18.125  
  18.126  * Source Listing
    19.1 --- a/org/proprioception.org	Sat Feb 18 02:06:06 2012 -0600
    19.2 +++ b/org/proprioception.org	Sat Feb 18 02:07:40 2012 -0600
    19.3 @@ -351,10 +351,12 @@
    19.4  #+name: test-proprioception-header
    19.5  #+begin_src clojure
    19.6  (ns cortex.test.proprioception
    19.7 -(:import (com.aurellem.capture Capture RatchetTimer))
    19.8 -(:use (cortex util world proprioception body))
    19.9 -(:import java.io.File))
   19.10 -(cortex.import/mega-import-jme3)
   19.11 +  (:import (com.aurellem.capture Capture RatchetTimer))
   19.12 +  (:use (cortex util world proprioception body))
   19.13 +  (:import java.io.File)
   19.14 +  (:import com.jme3.bullet.control.RigidBodyControl)
   19.15 +  (:import com.jme3.bullet.collision.PhysicsCollisionObject)
   19.16 +  (:import (com.jme3.math Vector3f Quaternion ColorRGBA)))
   19.17  #+end_src
   19.18  
   19.19  * Source Listing
    20.1 --- a/org/sense.org	Sat Feb 18 02:06:06 2012 -0600
    20.2 +++ b/org/sense.org	Sat Feb 18 02:07:40 2012 -0600
    20.3 @@ -448,32 +448,35 @@
    20.4  (defn test-bind-sense
    20.5    "Show a camera that stays in the same relative position to a blue
    20.6    cube."
    20.7 -  []
    20.8 -  (let [eye-pos (Vector3f. 0 30 0)
    20.9 -        rock (box 1 1 1 :color ColorRGBA/Blue
   20.10 -                  :position (Vector3f. 0 10 0)
   20.11 -                  :mass 30)
   20.12 -        table (box 3 1 10 :color ColorRGBA/Gray :mass 0
   20.13 -                   :position (Vector3f. 0 -3 0))]
   20.14 -    (world
   20.15 -     (nodify [rock table])
   20.16 -     standard-debug-controls
   20.17 -     (fn init [world]
   20.18 -       (let [cam (doto (.clone (.getCamera world))
   20.19 -                   (.setLocation eye-pos)
   20.20 -                   (.lookAt Vector3f/ZERO
   20.21 -                            Vector3f/UNIT_X))]
   20.22 -         (bind-sense rock cam)
   20.23 -         (.setTimer world (RatchetTimer. 60))
   20.24 -         (Capture/captureVideo
   20.25 -          world (File. "/home/r/proj/cortex/render/bind-sense0"))
   20.26 -         (add-camera!
   20.27 -          world cam
   20.28 -          (comp (view-image
   20.29 -                 (File. "/home/r/proj/cortex/render/bind-sense1"))
   20.30 -                BufferedImage!))
   20.31 -         (add-camera! world (.getCamera world) no-op)))
   20.32 -     no-op)))
   20.33 +  ([] (test-bind-sense false))
   20.34 +  ([record?]
   20.35 +     (let [eye-pos (Vector3f. 0 30 0)
   20.36 +           rock (box 1 1 1 :color ColorRGBA/Blue
   20.37 +                     :position (Vector3f. 0 10 0)
   20.38 +                     :mass 30)
   20.39 +           table (box 3 1 10 :color ColorRGBA/Gray :mass 0
   20.40 +                      :position (Vector3f. 0 -3 0))]
   20.41 +       (world
   20.42 +        (nodify [rock table])
   20.43 +        standard-debug-controls
   20.44 +        (fn init [world]
   20.45 +          (let [cam (doto (.clone (.getCamera world))
   20.46 +                      (.setLocation eye-pos)
   20.47 +                      (.lookAt Vector3f/ZERO
   20.48 +                               Vector3f/UNIT_X))]
   20.49 +            (bind-sense rock cam)
   20.50 +            (.setTimer world (RatchetTimer. 60))
   20.51 +            (if record?
   20.52 +              (Capture/captureVideo
   20.53 +               world (File. "/home/r/proj/cortex/render/bind-sense0")))
   20.54 +            (add-camera!
   20.55 +             world cam
   20.56 +             (comp (view-image
   20.57 +                    (if record?
   20.58 +                    (File. "/home/r/proj/cortex/render/bind-sense1")))
   20.59 +                   BufferedImage!))
   20.60 +            (add-camera! world (.getCamera world) no-op)))
   20.61 +        no-op))))
   20.62  #+end_src
   20.63  
   20.64  #+begin_html
    21.1 --- a/org/touch.org	Sat Feb 18 02:06:06 2012 -0600
    21.2 +++ b/org/touch.org	Sat Feb 18 02:07:40 2012 -0600
    21.3 @@ -435,7 +435,7 @@
    21.4                                               touch-objects))]
    21.5                           (FastMath/clamp
    21.6                            (float 
    21.7 -                           (if (> response limit) 0.0
    21.8 +                           (if (> response limit) (float 0.0)
    21.9                                 (+ response correction)))
   21.10                             (float 0.0)
   21.11                             limit)))
   21.12 @@ -485,7 +485,7 @@
   21.13          (for [i (range (count coords))]
   21.14            (.setRGB image ((coords i) 0) ((coords i) 1)
   21.15                     (apply touch->gray (sensor-data i)))))
   21.16 -       image))))
   21.17 +     image))))
   21.18  #+end_src
   21.19  
   21.20  #+results: visualization
   21.21 @@ -623,8 +623,8 @@
   21.22  #+begin_src clojure
   21.23  (in-ns 'cortex.test.touch)
   21.24  
   21.25 -(defn test-touch 
   21.26 -  ([] (test-touch false))
   21.27 +(defn test-worm-touch 
   21.28 +  ([] (test-worm-touch false))
   21.29    ([record?]
   21.30       (let [the-worm (doto (worm) (body!))
   21.31             touch (touch! the-worm)
   21.32 @@ -730,6 +730,7 @@
   21.33    - [[../src/cortex/test/touch.clj][cortex.test.touch]]
   21.34    - [[../src/cortex/video/magick4.clj][cortex.video.magick4]]
   21.35    - [[../src/cortex/video/magick5.clj][cortex.video.magick5]]
   21.36 +  - [[../assets/Models/test-touch/touch-cube.blend][touch-cube.blend]]
   21.37  #+html: <ul> <li> <a href="../org/touch.org">This org file</a> </li> </ul>
   21.38    - [[http://hg.bortreb.com ][source-repository]]
   21.39  
   21.40 @@ -781,11 +782,3 @@
   21.41  #+begin_src clojure :tangle ../src/cortex/video/magick5.clj
   21.42  <<magick5>>
   21.43  #+end_src
   21.44 -
   21.45 -
   21.46 -
   21.47 -
   21.48 -  
   21.49 -
   21.50 -
   21.51 -
    22.1 --- a/org/util.org	Sat Feb 18 02:06:06 2012 -0600
    22.2 +++ b/org/util.org	Sat Feb 18 02:07:40 2012 -0600
    22.3 @@ -113,13 +113,10 @@
    22.4  
    22.5  (defn position-camera
    22.6    "Change the position of the in-world camera."
    22.7 -  ([world position direction up]
    22.8 +  [world #^Vector3f position #^Quaternion rotation]
    22.9       (doto (.getCamera world)
   22.10 -       (.setLocation )
   22.11 -       (.lookAt direction up)))
   22.12 -  ([world position direction]
   22.13 -     (position-camera
   22.14 -      world position direction Vector3f/UNIT_Y)))
   22.15 +       (.setLocation position)
   22.16 +       (.setRotation rotation)))
   22.17  
   22.18  (defn enable-debug 
   22.19    "Turn on debug wireframes for every object in this simulation."
   22.20 @@ -219,7 +216,7 @@
   22.21  #+end_src
   22.22  
   22.23  #+results: util
   22.24 -: #'cortex.util/apply-map
   22.25 +: #'cortex.util/runonce
   22.26      
   22.27  
   22.28  *** Creating Basic Shapes
    23.1 --- a/org/vision.org	Sat Feb 18 02:06:06 2012 -0600
    23.2 +++ b/org/vision.org	Sat Feb 18 02:07:40 2012 -0600
    23.3 @@ -453,35 +453,38 @@
    23.4  
    23.5     You should see a rotating cube, and two windows,
    23.6     each displaying a different view of the cube."
    23.7 -  []
    23.8 -  (let [candy
    23.9 -        (box 1 1 1 :physical? false :color ColorRGBA/Blue)]
   23.10 -    (world
   23.11 -     (doto (Node.)
   23.12 -       (.attachChild candy))
   23.13 -     {}
   23.14 -     (fn [world]
   23.15 -       (let [cam (.clone (.getCamera world))
   23.16 -             width (.getWidth cam)
   23.17 -             height (.getHeight cam)]
   23.18 -         (add-camera! world cam 
   23.19 -                      (comp
   23.20 -                       (view-image
   23.21 -                        (File. "/home/r/proj/cortex/render/vision/1"))
   23.22 -                        BufferedImage!))
   23.23 -         (add-camera! world
   23.24 -                  (doto (.clone cam)
   23.25 -                    (.setLocation (Vector3f. -10 0 0))
   23.26 -                    (.lookAt Vector3f/ZERO Vector3f/UNIT_Y))
   23.27 -                  (comp
   23.28 -                   (view-image
   23.29 -                    (File. "/home/r/proj/cortex/render/vision/2"))
   23.30 -                        BufferedImage!))
   23.31 -         ;; This is here to restore the main view
   23.32 +  ([] (test-pipeline false))
   23.33 +  ([record?]
   23.34 +     (let [candy
   23.35 +           (box 1 1 1 :physical? false :color ColorRGBA/Blue)]
   23.36 +       (world
   23.37 +        (doto (Node.)
   23.38 +          (.attachChild candy))
   23.39 +        {}
   23.40 +        (fn [world]
   23.41 +          (let [cam (.clone (.getCamera world))
   23.42 +                width (.getWidth cam)
   23.43 +                height (.getHeight cam)]
   23.44 +            (add-camera! world cam 
   23.45 +                         (comp
   23.46 +                          (view-image
   23.47 +                           (if record?
   23.48 +                             (File. "/home/r/proj/cortex/render/vision/1")))
   23.49 +                          BufferedImage!))
   23.50 +            (add-camera! world
   23.51 +                         (doto (.clone cam)
   23.52 +                           (.setLocation (Vector3f. -10 0 0))
   23.53 +                           (.lookAt Vector3f/ZERO Vector3f/UNIT_Y))
   23.54 +                         (comp
   23.55 +                          (view-image
   23.56 +                           (if record?
   23.57 +                             (File. "/home/r/proj/cortex/render/vision/2")))
   23.58 +                          BufferedImage!))
   23.59 +            ;; This is here to restore the main view
   23.60           ;; after the other views have completed processing
   23.61 -         (add-camera! world (.getCamera world) no-op)))
   23.62 -     (fn [world tpf]
   23.63 -       (.rotate candy (* tpf 0.2) 0 0)))))
   23.64 +            (add-camera! world (.getCamera world) no-op)))
   23.65 +        (fn [world tpf]
   23.66 +          (.rotate candy (* tpf 0.2) 0 0))))))
   23.67  #+end_src
   23.68  
   23.69  #+begin_html
   23.70 @@ -541,60 +544,62 @@
   23.71    (comp #(change-color % color)
   23.72           (fire-cannon-ball)))
   23.73  
   23.74 -(defn test-worm-vision [record] 
   23.75 -  (let [the-worm (doto (worm)(body!))
   23.76 -        vision (vision! the-worm)
   23.77 -        vision-display (view-vision)
   23.78 -        fix-display (gen-fix-display)
   23.79 -        me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
   23.80 -        x-axis
   23.81 -        (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red
   23.82 -             :position (Vector3f. 0 -5 0))
   23.83 -        y-axis
   23.84 -        (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green
   23.85 -             :position (Vector3f. 0 -5 0))
   23.86 -        z-axis
   23.87 -        (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue
   23.88 -             :position (Vector3f. 0 -5 0))
   23.89 -        timer (RatchetTimer. 60)]
   23.90 +(defn test-worm-vision 
   23.91 +  ([] (test-worm-vision false))
   23.92 +  ([record?] 
   23.93 +     (let [the-worm (doto (worm)(body!))
   23.94 +           vision (vision! the-worm)
   23.95 +           vision-display (view-vision)
   23.96 +           fix-display (gen-fix-display)
   23.97 +           me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
   23.98 +           x-axis
   23.99 +           (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red
  23.100 +                :position (Vector3f. 0 -5 0))
  23.101 +           y-axis
  23.102 +           (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green
  23.103 +                :position (Vector3f. 0 -5 0))
  23.104 +           z-axis
  23.105 +           (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue
  23.106 +                :position (Vector3f. 0 -5 0))
  23.107 +           timer (RatchetTimer. 60)]
  23.108  
  23.109 -    (world (nodify [(floor) the-worm x-axis y-axis z-axis me])
  23.110 -           (assoc standard-debug-controls
  23.111 -             "key-r" (colored-cannon-ball ColorRGBA/Red)
  23.112 -             "key-b" (colored-cannon-ball ColorRGBA/Blue)
  23.113 -             "key-g" (colored-cannon-ball ColorRGBA/Green))
  23.114 -           (fn [world]
  23.115 -             (light-up-everything world)
  23.116 -             (speed-up world)
  23.117 -             (.setTimer world timer)
  23.118 -             (display-dialated-time world timer)
  23.119 -             ;; add a view from the worm's perspective
  23.120 -             (if record
  23.121 -               (Capture/captureVideo
  23.122 -                  world
  23.123 -                  (File.
  23.124 -                   "/home/r/proj/cortex/render/worm-vision/main-view")))
  23.125 -             
  23.126 -             (add-camera!
  23.127 -              world
  23.128 -              (add-eye! the-worm
  23.129 -                        (.getChild 
  23.130 -                         (.getChild the-worm "eyes") "eye"))
  23.131 -              (comp
  23.132 -               (view-image
  23.133 -                (if record
  23.134 -                  (File.
  23.135 -                   "/home/r/proj/cortex/render/worm-vision/worm-view")))
  23.136 -               BufferedImage!))
  23.137 -                 
  23.138 -             (set-gravity world Vector3f/ZERO))
  23.139 -               
  23.140 -           (fn [world _ ]
  23.141 -             (.setLocalTranslation me (.getLocation (.getCamera world)))
  23.142 -             (vision-display
  23.143 -              (map #(% world) vision)
  23.144 -              (if record (File. "/home/r/proj/cortex/render/worm-vision")))
  23.145 -             (fix-display world)))))
  23.146 +       (world (nodify [(floor) the-worm x-axis y-axis z-axis me])
  23.147 +              (assoc standard-debug-controls
  23.148 +                "key-r" (colored-cannon-ball ColorRGBA/Red)
  23.149 +                "key-b" (colored-cannon-ball ColorRGBA/Blue)
  23.150 +                "key-g" (colored-cannon-ball ColorRGBA/Green))
  23.151 +              (fn [world]
  23.152 +                (light-up-everything world)
  23.153 +                (speed-up world)
  23.154 +                (.setTimer world timer)
  23.155 +                (display-dialated-time world timer)
  23.156 +                ;; add a view from the worm's perspective
  23.157 +                (if record?
  23.158 +                  (Capture/captureVideo
  23.159 +                   world
  23.160 +                   (File.
  23.161 +                    "/home/r/proj/cortex/render/worm-vision/main-view")))
  23.162 +                
  23.163 +                (add-camera!
  23.164 +                 world
  23.165 +                 (add-eye! the-worm
  23.166 +                           (.getChild 
  23.167 +                            (.getChild the-worm "eyes") "eye"))
  23.168 +                 (comp
  23.169 +                  (view-image
  23.170 +                   (if record?
  23.171 +                     (File.
  23.172 +                      "/home/r/proj/cortex/render/worm-vision/worm-view")))
  23.173 +                  BufferedImage!))
  23.174 +                
  23.175 +                (set-gravity world Vector3f/ZERO))
  23.176 +              
  23.177 +              (fn [world _ ]
  23.178 +                (.setLocalTranslation me (.getLocation (.getCamera world)))
  23.179 +                (vision-display
  23.180 +                 (map #(% world) vision)
  23.181 +                 (if record? (File. "/home/r/proj/cortex/render/worm-vision")))
  23.182 +                (fix-display world))))))
  23.183  #+end_src
  23.184  
  23.185  The world consists of the worm and a flat gray floor. I can shoot red,
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/winston-intro.txt	Sat Feb 18 02:07:40 2012 -0600
    24.3 @@ -0,0 +1,103 @@
    24.4 +Dear Professor Winston,
    24.5 +
    24.6 +I'm ready for you to look through the work that I've done so far. It's
    24.7 +a sequence of posts describing the different simulated senses I've
    24.8 +implemented, with videos. 
    24.9 +
   24.10 +It's "blocks world reloaded", because like you say, you need multiple
   24.11 +senses to enable intelligence.
   24.12 +
   24.13 +Please look through the videos and skim the text and tell me what
   24.14 +you think:
   24.15 +
   24.16 +Introduction:
   24.17 +http://aurellem.org/cortex/html/intro.html
   24.18 +http://aurellem.org/cortex/html/sense.html
   24.19 +
   24.20 +http://aurellem.org/cortex/html/body.html  -- simulated physical bodies
   24.21 +http://aurellem.org/cortex/html/vision.html -- simulated eyes
   24.22 +http://aurellem.org/cortex/html/hearing.html -- simulated ears
   24.23 +http://aurellem.org/cortex/html/touch.html   -- simulated skin/hairs
   24.24 +http://aurellem.org/cortex/html/proprioception.html -- simulated proprioception
   24.25 +http://aurellem.org/cortex/html/movement.html       -- simulated muscles
   24.26 +http://aurellem.org/cortex/html/integration.html  -- full demonstration 
   24.27 +
   24.28 +In particular, look at the video at
   24.29 +http://aurellem.org/cortex/html/integration.html.  It shows a
   24.30 +simulated hand equipped with all of the senses I've built so far.
   24.31 +
   24.32 +There's some more background information and full source code at 
   24.33 +http://aurellem.org
   24.34 +
   24.35 +If you can't see a video, let me know and I'll upload it to YouTube so
   24.36 +you can see it.
   24.37 +
   24.38 +
   24.39 +
   24.40 +
   24.41 +Now, I need your help moving forward. Can I use this work as a base
   24.42 +for a Masters thesis with you when I come back to MIT this coming Fall?
   24.43 +What critiques and project ideas do you have after looking through
   24.44 +what I've done so far?
   24.45 +
   24.46 +I have some ideas on where I can go with this project but I think you
   24.47 +will have some better ones.
   24.48 +
   24.49 +Here are some possible projects I might do with this as a base that I
   24.50 +think would be worthy Masters projects.
   24.51 +
   24.52 + - HACKER for writing muscle-control programs : Presented with
   24.53 +   low-level muscle control/ sense API, generate higher level programs
   24.54 +   for accomplishing various stated goals. Example goals might be
   24.55 +   "extend all your fingers" or "move your hand into the area with
   24.56 +   blue light" or "decrease the angle of this joint".  It would be
   24.57 +   like Sussman's HACKER, except it would operate with much more data
   24.58 +   in a more realistic world.  Start off with "calisthenics" to
   24.59 +   develop subroutines over the motor control API.  This would be the
   24.60 +   "spinal chord" of a more intelligent creature.
   24.61 +
   24.62 + - Create hundreds of small creatures and have them do simple
   24.63 +   simulated swarm tasks.
   24.64 + 
   24.65 + - A joint that learns what sort of joint it (cone, point-to-point,
   24.66 +   hinge, etc.) is by correlating exploratory muscle movements with
   24.67 +   vision.
   24.68 +
   24.69 + - Something with cross-modal clustering using the rich sense
   24.70 +   data. This might prove difficult due to the higher dimensionality
   24.71 +   of my senses.
   24.72 +
   24.73 + - Simulated Imagination --- this would involve a creature with an
   24.74 +   effector which creates an /entire new sub-simulation/ where the
   24.75 +   creature has direct control over placement/creation of objects via
   24.76 +   simulated telekinesis. The creature observes this sub-world through
   24.77 +   it's normal senses and uses its observations to make predictions
   24.78 +   about it's top level world.
   24.79 +
   24.80 + - Hook it up with Genesis --- I could make a "semantic effector"
   24.81 +   which marks objects/sensory states with semantic information. In
   24.82 +   conjunction with Simulated Imagination, and HACKER-like motor
   24.83 +   control, Genesis might be able to ask simple questions like "stack
   24.84 +   two blocks together and hit the top one with your hand; does the
   24.85 +   bottom block move?" and the system could answer "yes".  This would
   24.86 +   be rather complicated to do and involves many of the above
   24.87 +   projects, but there may be a way to scale it down to Master's
   24.88 +   thesis size.
   24.89 +
   24.90 + - Make a virtual computer in the virtual world which with which the
   24.91 +   creature interacts using its fingers to press keys on a virtual
   24.92 +   keyboard. The creature can access the internet, watch videos, take
   24.93 +   over the world, anything it wants. (This is probably not worthy of
   24.94 +   a Masters project, I just thought it was a neat idea. It's possible
   24.95 +   to use videos/etc in the simulated world at any rate.)
   24.96 +
   24.97 +
   24.98 +I can't wait to hear your critiques and ideas.  If you think I
   24.99 +shouldn't use this system as a base and should instead do something
  24.100 +else, that's fine too. 
  24.101 +
  24.102 +On a related note, can I be considered for the position of TA next
  24.103 +year for 6.034 or 6.xxx?
  24.104 +
  24.105 +sincerely,
  24.106 +--Robert McIntyre