diff org/touch.org @ 234:712bd7e5b148

saving progress
author Robert McIntyre <rlm@mit.edu>
date Sun, 12 Feb 2012 09:05:47 -0700
parents f27c9fd9134d
children 3fa49ff1649a
line wrap: on
line diff
     1.1 --- a/org/touch.org	Sun Feb 12 06:21:30 2012 -0700
     1.2 +++ b/org/touch.org	Sun Feb 12 09:05:47 2012 -0700
     1.3 @@ -74,12 +74,57 @@
     1.4  ** TODO add image showing example touch-uv map
     1.5  ** TODO add metadata display for worm
     1.6  
     1.7 +
     1.8  * Skin Creation
     1.9 +* TODO get the actual lengths for each hair
    1.10 +
    1.11 +#+begin_src clojure
    1.12 +pixel-triangles
    1.13 +        xyz-triangles
    1.14 +        conversions (map triangles->affine-transform pixel-triangles
    1.15 +                         xyz-triangles)
    1.16 +
    1.17 +#+end_src
    1.18 +
    1.19  #+name: kernel
    1.20  #+begin_src clojure
    1.21  (in-ns 'cortex.touch)
    1.22  
    1.23 +(declare touch-topology touch-hairs set-ray)
    1.24 +
    1.25  (defn touch-kernel
    1.26 +  "Constructs a function which will return tactile sensory data from
    1.27 +   'geo when called from inside a running simulation"
    1.28 +  [#^Geometry geo]
    1.29 +  (let [[ray-reference-origins
    1.30 +         ray-reference-tips
    1.31 +         ray-lengths] (touch-hairs geo)
    1.32 +        current-rays (map (fn [] (Ray.)) ray-reference-origins)
    1.33 +        topology (touch-topology geo)]
    1.34 +    (if (empty? ray-reference-origins) nil
    1.35 +        (fn [node]
    1.36 +          (let [transform (.getWorldMatrix geo)]
    1.37 +            (dorun
    1.38 +             (map (fn [ray ref-origin ref-tip length]
    1.39 +                    (set-ray ray transform ref-origin ref-tip length))
    1.40 +                  current-rays ray-reference-origins
    1.41 +                  ray-reference-tips ray-lengths))
    1.42 +            (vector
    1.43 +             topology
    1.44 +             (vec
    1.45 +              (for [ray current-rays]
    1.46 +                (do
    1.47 +                  (let [results (CollisionResults.)]
    1.48 +                    (.collideWith node ray results)
    1.49 +                    (let [touch-objects
    1.50 +                          (filter #(not (= geo (.getGeometry %)))
    1.51 +                                  results)]
    1.52 +                      [(if (empty? touch-objects)
    1.53 +                         (.getLimit ray)
    1.54 +                         (.getDistance (first touch-objects)))
    1.55 +                       (.getLimit ray)])))))))))))
    1.56 +
    1.57 +(defn touch-kernel*
    1.58    "Returns a function which returns tactile sensory data when called
    1.59     inside a running simulation."
    1.60    [#^Geometry geo]
    1.61 @@ -348,7 +393,6 @@
    1.62  #+end_src
    1.63  
    1.64  
    1.65 -
    1.66  * Sensor Related Functions
    1.67  
    1.68  These functions analyze the touch-sensor-profile image convert the
    1.69 @@ -406,7 +450,7 @@
    1.70  
    1.71  * Physics Collision Objects
    1.72  
    1.73 -The "hairs" are actually rays which extend  from a point on a
    1.74 +The "hairs" are actually =Rays= which extend  from a point on a
    1.75  =Triangle= in the =Mesh= normal to the =Triangle's= surface.
    1.76  
    1.77  #+name: rays
    1.78 @@ -433,9 +477,6 @@
    1.79       (.add (.getCenter tri) (.getNormal tri)) n+c)
    1.80      (.subtract n+c (get-ray-origin geom tri))))
    1.81  #+end_src
    1.82 -
    1.83 -
    1.84 -
    1.85  * Headers 
    1.86  
    1.87  #+name: touch-header
    1.88 @@ -478,7 +519,6 @@
    1.89             (fn [world tpf]
    1.90               (touch-display (map #(% (.getRootNode world)) touch))))))
    1.91  #+end_src
    1.92 -
    1.93  * Source Listing
    1.94  * Next
    1.95