# HG changeset patch # User Robert McIntyre # Date 1328346932 25200 # Node ID 985c7365992362d295a7f3cfc95a406c67ef0266 # Parent 2cbdd7034c6cfa939d71272e5a095f22d8d1dbfb renamed functions in ear.org diff -r 2cbdd7034c6c -r 985c73659923 org/ear.org --- a/org/ear.org Sat Feb 04 01:44:06 2012 -0700 +++ b/org/ear.org Sat Feb 04 02:15:32 2012 -0700 @@ -783,32 +783,14 @@ (continuation (vec floats)))))) - - - -;; Ears work the same way as vision. - -;; (hearing creature) will return [init-functions -;; sensor-functions]. The init functions each take the world and -;; register a SoundProcessor that does foureier transforms on the -;; incommong sound data, making it available to each sensor function. - -(defn creature-ears +(defn ears "Return the children of the creature's \"ears\" node." - ;;dylan - ;;"The ear nodes which are children of the \"ears\" node in the - ;;creature." [#^Node creature] (if-let [ear-node (.getChild creature "ears")] (seq (.getChildren ear-node)) (do (println-repl "could not find ears node") []))) - -;;dylan (defn follow-sense, adjoin-sense, attach-stimuli, -;;anchor-qualia, augment-organ, with-organ - - -(defn update-listener-velocity +(defn update-listener-velocity! "Update the listener's velocity every update loop." [#^Spatial obj #^Listener lis] (let [old-position (atom (.getLocation lis))] @@ -826,7 +808,7 @@ (import com.aurellem.capture.audio.AudioSendRenderer) -(defn attach-ear +(defn create-listener! [#^Application world #^Node creature #^Spatial ear continuation] (let [target (closest-node creature ear) lis (Listener.) @@ -835,15 +817,15 @@ (.setLocation lis (.getWorldTranslation ear)) (.setRotation lis (.getWorldRotation ear)) (bind-sense target lis) - (update-listener-velocity target lis) + (update-listener-velocity! target lis) (.addListener audio-renderer lis) (.registerSoundProcessor audio-renderer lis sp))) -(defn enable-hearing +(defn hearing-fn [#^Node creature #^Spatial ear] (let [hearing-data (atom [])] [(fn [world] - (attach-ear world creature ear + (create-listener! world creature ear (fn [data] (reset! hearing-data (vec data))))) [(fn [] @@ -858,7 +840,7 @@ [topology scaled-data])) ]])) -(defn hearing +(defn hearing! [#^Node creature] (reduce (fn [[init-a senses-a] @@ -866,8 +848,8 @@ [(conj init-a init-b) (into senses-a senses-b)]) [[][]] - (for [ear (creature-ears creature)] - (enable-hearing creature ear)))) + (for [ear (ears creature)] + (hearing-fn creature ear)))) #+end_src @@ -925,7 +907,7 @@ * COMMENT Code Generation -#+begin_src clojure :tangle ../cortex/src/cortex/hearing.clj +#+begin_src clojure :tangle ../src/cortex/hearing.clj <> #+end_src diff -r 2cbdd7034c6c -r 985c73659923 org/ideas.org --- a/org/ideas.org Sat Feb 04 01:44:06 2012 -0700 +++ b/org/ideas.org Sat Feb 04 02:15:32 2012 -0700 @@ -102,7 +102,19 @@ - [ ] docstrings for every function - [ ] common image-loading code - [ ] refactor display/debug code + - [ ] refactor the "get the XX nodes functions" -for each sense, +these are the sense-functions --- they each take a Node which +repepsents the creature + + + - [ ] body! + - [ ] joints! + + - [ ] touch! + - [ ] hearing! + - [ ] vision! + - [ ] proprioception! + - [ ] movement! diff -r 2cbdd7034c6c -r 985c73659923 org/test-creature.org --- a/org/test-creature.org Sat Feb 04 01:44:06 2012 -0700 +++ b/org/test-creature.org Sat Feb 04 02:15:32 2012 -0700 @@ -184,7 +184,7 @@ [init-vision-fns vision-data] (vision creature) vision-debug (map (fn [_] (debug-vision-window)) vision-data) me (sphere 0.5 :color ColorRGBA/Blue :physical? false) - [init-hearing-fns hearing-senses] (hearing creature) + [init-hearing-fns hearing-senses] (hearing! creature) hearing-windows (map (fn [_] (debug-hearing-window 50)) hearing-senses) bell (AudioNode. (asset-manager)