diff org/test-creature.org @ 112:128fa71ee188

working on retina design
author Robert McIntyre <rlm@mit.edu>
date Thu, 19 Jan 2012 11:29:46 -0700
parents 61d9c0e8d188
children 9d0fe7f54e14
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Thu Jan 19 08:09:15 2012 -0700
     1.2 +++ b/org/test-creature.org	Thu Jan 19 11:29:46 2012 -0700
     1.3 @@ -455,11 +455,14 @@
     1.4  
     1.5  (defn white-coordinates
     1.6    "Coordinates of all the white pixels in a subset of the image."
     1.7 -  [#^BufferedImage image bounds]
     1.8 -  (filter-pixels #(= % white) image bounds))
     1.9 +  ([#^BufferedImage image bounds]
    1.10 +     (filter-pixels #(= % white) image bounds))
    1.11 +  ([#^BufferedImage image]
    1.12 +     (filter-pixels #(= % white) image)))
    1.13  
    1.14  (defn triangle
    1.15 -  "Get the triangle specified by triangle-index from the mesh"
    1.16 +  "Get the triangle specified by triangle-index from the mesh within
    1.17 +  bounds."
    1.18    [#^Mesh mesh triangle-index]
    1.19    (let [scratch (Triangle.)]
    1.20      (.getTriangle mesh triangle-index scratch)
    1.21 @@ -687,8 +690,56 @@
    1.22         eye-map))))
    1.23  
    1.24  
    1.25 +(defn enable-vision
    1.26  
    1.27 +  ;; need to create a camera based on uv image,
    1.28 +  ;; update this camera every frame based on the position of this
    1.29 +  ;; geometry. (maybe can get cam to follow the object)
    1.30  
    1.31 +  ;; use a stack for the continuation to grab the image.
    1.32 +  
    1.33 +
    1.34 +  [#^Geometry eye]
    1.35 +  
    1.36 +
    1.37 +  ;; Here's how vision will work.
    1.38 +
    1.39 +  ;; Make the continuation in scene-processor take FrameBuffer,
    1.40 +  ;; byte-buffer, BufferedImage already sized to the correct
    1.41 +  ;; dimensions. the continuation will decide wether to "mix" them
    1.42 +  ;; into the BufferedImage, lazily ignore them, or mix them halfway
    1.43 +  ;; and call c/graphics card routines.
    1.44 +  
    1.45 +  ;; (vision creature) will take an optional :skip argument which will
    1.46 +  ;; inform the continuations in scene processor to skip the given
    1.47 +  ;; number of cycles; 0 means that no cycles will be skipped.
    1.48 +
    1.49 +  ;; (vision creature) will return [init-functions sensor-functions].
    1.50 +  ;; The init-functions are each single-arg functions that take the
    1.51 +  ;; world and register the cameras and must each be called before the
    1.52 +  ;; corresponding sensor-functions.  Each init-function returns the
    1.53 +  ;; viewport for that eye which can be manipulated, saved, etc. Each
    1.54 +  ;; sensor-function is a thunk and will return data in the same
    1.55 +  ;; format as the tactile-sensor functions; the structure is
    1.56 +  ;; [topology, sensor-data]. Internally, these sensor-functions
    1.57 +  ;; maintain a reference to sensor-data which is periodically updated
    1.58 +  ;; by the continuation function established by its init-function.
    1.59 +  ;; They can be queried every cycle, but their information may not
    1.60 +  ;; necessairly be different every cycle.
    1.61 +
    1.62 +  ;; Each eye in the creature in blender will work the same way as
    1.63 +  ;; joints -- a one dimensional object with no geometry whose local
    1.64 +  ;; coordinate system determines the orientation of the resulting
    1.65 +  ;; eye. All eyes will have a parent named "eyes" just as all joints
    1.66 +  ;; have a parent named "joints". The resulting camera will be a
    1.67 +  ;; ChaseCamera or a CameraNode bound to the geo that is closest to
    1.68 +  ;; the eye marker. The eye marker will contain the metadata for the
    1.69 +  ;; eye, and will be moved by it's bound geometry. The dimensions of
    1.70 +  ;; the eye's camera are equal to the dimensions of the eye's "UV"
    1.71 +  ;; map. 
    1.72 +  
    1.73 +
    1.74 +)
    1.75  
    1.76  (defn debug-window
    1.77    "creates function that offers a debug view of sensor data"