comparison 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
comparison
equal deleted inserted replaced
111:61d9c0e8d188 112:128fa71ee188
453 :else (recur (inc x) y matches))) 453 :else (recur (inc x) y matches)))
454 x0 y0 []))) 454 x0 y0 [])))
455 455
456 (defn white-coordinates 456 (defn white-coordinates
457 "Coordinates of all the white pixels in a subset of the image." 457 "Coordinates of all the white pixels in a subset of the image."
458 [#^BufferedImage image bounds] 458 ([#^BufferedImage image bounds]
459 (filter-pixels #(= % white) image bounds)) 459 (filter-pixels #(= % white) image bounds))
460 ([#^BufferedImage image]
461 (filter-pixels #(= % white) image)))
460 462
461 (defn triangle 463 (defn triangle
462 "Get the triangle specified by triangle-index from the mesh" 464 "Get the triangle specified by triangle-index from the mesh within
465 bounds."
463 [#^Mesh mesh triangle-index] 466 [#^Mesh mesh triangle-index]
464 (let [scratch (Triangle.)] 467 (let [scratch (Triangle.)]
465 (.getTriangle mesh triangle-index scratch) 468 (.getTriangle mesh triangle-index scratch)
466 scratch)) 469 scratch))
467 470
685 false false 0) 688 false false 0)
686 (read-string 689 (read-string
687 eye-map)))) 690 eye-map))))
688 691
689 692
690 693 (defn enable-vision
691 694
695 ;; need to create a camera based on uv image,
696 ;; update this camera every frame based on the position of this
697 ;; geometry. (maybe can get cam to follow the object)
698
699 ;; use a stack for the continuation to grab the image.
700
701
702 [#^Geometry eye]
703
704
705 ;; Here's how vision will work.
706
707 ;; Make the continuation in scene-processor take FrameBuffer,
708 ;; byte-buffer, BufferedImage already sized to the correct
709 ;; dimensions. the continuation will decide wether to "mix" them
710 ;; into the BufferedImage, lazily ignore them, or mix them halfway
711 ;; and call c/graphics card routines.
712
713 ;; (vision creature) will take an optional :skip argument which will
714 ;; inform the continuations in scene processor to skip the given
715 ;; number of cycles; 0 means that no cycles will be skipped.
716
717 ;; (vision creature) will return [init-functions sensor-functions].
718 ;; The init-functions are each single-arg functions that take the
719 ;; world and register the cameras and must each be called before the
720 ;; corresponding sensor-functions. Each init-function returns the
721 ;; viewport for that eye which can be manipulated, saved, etc. Each
722 ;; sensor-function is a thunk and will return data in the same
723 ;; format as the tactile-sensor functions; the structure is
724 ;; [topology, sensor-data]. Internally, these sensor-functions
725 ;; maintain a reference to sensor-data which is periodically updated
726 ;; by the continuation function established by its init-function.
727 ;; They can be queried every cycle, but their information may not
728 ;; necessairly be different every cycle.
729
730 ;; Each eye in the creature in blender will work the same way as
731 ;; joints -- a one dimensional object with no geometry whose local
732 ;; coordinate system determines the orientation of the resulting
733 ;; eye. All eyes will have a parent named "eyes" just as all joints
734 ;; have a parent named "joints". The resulting camera will be a
735 ;; ChaseCamera or a CameraNode bound to the geo that is closest to
736 ;; the eye marker. The eye marker will contain the metadata for the
737 ;; eye, and will be moved by it's bound geometry. The dimensions of
738 ;; the eye's camera are equal to the dimensions of the eye's "UV"
739 ;; map.
740
741
742 )
692 743
693 (defn debug-window 744 (defn debug-window
694 "creates function that offers a debug view of sensor data" 745 "creates function that offers a debug view of sensor data"
695 [] 746 []
696 (let [vi (view-image)] 747 (let [vi (view-image)]