changeset 163:985c73659923

renamed functions in ear.org
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 02:15:32 -0700
parents 2cbdd7034c6c
children c33a8e5fe7bc
files org/ear.org org/ideas.org org/test-creature.org
diffstat 3 files changed, 24 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/ear.org	Sat Feb 04 01:44:06 2012 -0700
     1.2 +++ b/org/ear.org	Sat Feb 04 02:15:32 2012 -0700
     1.3 @@ -783,32 +783,14 @@
     1.4          (continuation
     1.5           (vec floats))))))
     1.6  
     1.7 -
     1.8 -
     1.9 -
    1.10 -;; Ears work the same way as vision.
    1.11 -
    1.12 -;; (hearing creature) will return [init-functions
    1.13 -;; sensor-functions]. The init functions each take the world and
    1.14 -;; register a SoundProcessor that does foureier transforms on the
    1.15 -;; incommong sound data, making it available to each sensor function.
    1.16 -
    1.17 -(defn creature-ears
    1.18 +(defn ears
    1.19    "Return the children of the creature's \"ears\" node."
    1.20 -  ;;dylan
    1.21 -  ;;"The ear nodes which are children of the \"ears\" node in the
    1.22 -  ;;creature."
    1.23    [#^Node creature]
    1.24    (if-let [ear-node (.getChild creature "ears")]
    1.25      (seq (.getChildren ear-node))
    1.26      (do (println-repl "could not find ears node") [])))
    1.27  
    1.28 -
    1.29 -;;dylan (defn follow-sense, adjoin-sense, attach-stimuli,
    1.30 -;;anchor-qualia, augment-organ, with-organ
    1.31 -
    1.32 -
    1.33 -(defn update-listener-velocity
    1.34 +(defn update-listener-velocity!
    1.35    "Update the listener's velocity every update loop."
    1.36    [#^Spatial obj #^Listener lis]
    1.37    (let [old-position (atom (.getLocation lis))]
    1.38 @@ -826,7 +808,7 @@
    1.39  
    1.40  (import com.aurellem.capture.audio.AudioSendRenderer)
    1.41  
    1.42 -(defn attach-ear
    1.43 +(defn create-listener!
    1.44    [#^Application world #^Node creature #^Spatial ear continuation]
    1.45    (let [target (closest-node creature ear)
    1.46          lis (Listener.)
    1.47 @@ -835,15 +817,15 @@
    1.48      (.setLocation lis (.getWorldTranslation ear))
    1.49      (.setRotation lis (.getWorldRotation ear))
    1.50      (bind-sense target lis)
    1.51 -    (update-listener-velocity target lis)
    1.52 +    (update-listener-velocity! target lis)
    1.53      (.addListener audio-renderer lis)
    1.54      (.registerSoundProcessor audio-renderer lis sp)))
    1.55  
    1.56 -(defn enable-hearing
    1.57 +(defn hearing-fn
    1.58    [#^Node creature #^Spatial ear]
    1.59    (let [hearing-data (atom [])]
    1.60      [(fn [world]
    1.61 -       (attach-ear world creature ear
    1.62 +       (create-listener! world creature ear
    1.63                     (fn [data]
    1.64                       (reset! hearing-data (vec data)))))
    1.65       [(fn []
    1.66 @@ -858,7 +840,7 @@
    1.67            [topology scaled-data]))
    1.68          ]]))
    1.69  
    1.70 -(defn hearing
    1.71 +(defn hearing!
    1.72    [#^Node creature]
    1.73    (reduce
    1.74     (fn [[init-a senses-a]
    1.75 @@ -866,8 +848,8 @@
    1.76       [(conj init-a init-b)
    1.77        (into senses-a senses-b)])
    1.78     [[][]]      
    1.79 -   (for [ear (creature-ears creature)]
    1.80 -     (enable-hearing creature ear))))
    1.81 +   (for [ear (ears creature)]
    1.82 +     (hearing-fn creature ear))))
    1.83  
    1.84  
    1.85  #+end_src
    1.86 @@ -925,7 +907,7 @@
    1.87  
    1.88  * COMMENT Code Generation
    1.89  
    1.90 -#+begin_src clojure :tangle ../cortex/src/cortex/hearing.clj
    1.91 +#+begin_src clojure :tangle ../src/cortex/hearing.clj
    1.92  <<ears>>
    1.93  #+end_src
    1.94  
     2.1 --- a/org/ideas.org	Sat Feb 04 01:44:06 2012 -0700
     2.2 +++ b/org/ideas.org	Sat Feb 04 02:15:32 2012 -0700
     2.3 @@ -102,7 +102,19 @@
     2.4   - [ ] docstrings for every function
     2.5   - [ ] common image-loading code
     2.6   - [ ] refactor display/debug code
     2.7 + - [ ] refactor the "get the XX nodes functions"
     2.8  
     2.9  
    2.10  
    2.11 -for each sense,  
    2.12 +these are the sense-functions --- they each take a Node which
    2.13 +repepsents the creature
    2.14 +
    2.15 +
    2.16 + - [ ] body!
    2.17 + - [ ] joints!
    2.18 +
    2.19 + - [ ] touch!
    2.20 + - [ ] hearing!
    2.21 + - [ ] vision!
    2.22 + - [ ] proprioception!
    2.23 + - [ ] movement!
     3.1 --- a/org/test-creature.org	Sat Feb 04 01:44:06 2012 -0700
     3.2 +++ b/org/test-creature.org	Sat Feb 04 02:15:32 2012 -0700
     3.3 @@ -184,7 +184,7 @@
     3.4          [init-vision-fns vision-data] (vision creature)
     3.5          vision-debug (map (fn [_] (debug-vision-window)) vision-data)
     3.6          me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
     3.7 -        [init-hearing-fns hearing-senses] (hearing creature)
     3.8 +        [init-hearing-fns hearing-senses] (hearing! creature)
     3.9          hearing-windows (map (fn [_] (debug-hearing-window 50))
    3.10                               hearing-senses)
    3.11          bell (AudioNode. (asset-manager)