# HG changeset patch # User Robert McIntyre # Date 1326528438 25200 # Node ID b7a3ba5e879b758130d6abf3670e38db02b30590 # Parent 5b23961433e346e9803757cf43c2e51a569d9d89 made BufferedImage visulation more general diff -r 5b23961433e3 -r b7a3ba5e879b org/eyes.org --- a/org/eyes.org Wed Jan 11 21:30:26 2012 -0700 +++ b/org/eyes.org Sat Jan 14 01:07:18 2012 -0700 @@ -99,31 +99,32 @@ (:import com.jme3.math.Vector3f)) (defn view-image - "Initailizes a JPanel on which you may draw a BufferedImage of the - given width and height. Returns a function that accepts a - BufferedImage and draws it to the JPanel." - [width height] + "Initailizes a JPanel on which you may draw a BufferedImage. + Returns a function that accepts a BufferedImage and draws it to the + JPanel." + [] (let [image (atom - (BufferedImage. width height BufferedImage/TYPE_4BYTE_ABGR)) + (BufferedImage. 1 1 BufferedImage/TYPE_4BYTE_ABGR)) panel (proxy [JPanel] [] (paint [graphics] (proxy-super paintComponent graphics) - (.drawImage graphics @image 0 0 nil)))] + (.drawImage graphics @image 0 0 nil))) + frame (JFrame. "Display Image")] (SwingUtilities/invokeLater (fn [] - (.setPreferredSize panel (Dimension. width height)) - (doto (JFrame. "Eye Camera!") + (doto frame (-> (.getContentPane) (.add panel)) (.pack) (.setLocationRelativeTo nil) - (.setResizable false) + (.setResizable true) (.setVisible true)))) (fn [#^BufferedImage i] (reset! image i) - (.repaint panel)))) + (.setSize frame (+ 8 (.getWidth i)) (+ 28 (.getHeight i))) + (.repaint panel 0 0 (.getWidth i) (.getHeight i))))) (defn test-two-eyes "Testing vision: @@ -143,12 +144,12 @@ (let [cam (.clone (.getCamera world)) width (.getWidth cam) height (.getHeight cam)] - (add-eye world cam (view-image width height)) + (add-eye world cam (view-image)) (add-eye world (doto (.clone cam) (.setLocation (Vector3f. -10 0 0)) (.lookAt Vector3f/ZERO Vector3f/UNIT_Y)) - (view-image width height)) + (view-image)) ;; This is here to restore the main view ;; after the other views have completed processing (add-eye world (.getCamera world) no-op))) diff -r 5b23961433e3 -r b7a3ba5e879b org/test-creature.org --- a/org/test-creature.org Wed Jan 11 21:30:26 2012 -0700 +++ b/org/test-creature.org Sat Jan 14 01:07:18 2012 -0700 @@ -6,6 +6,15 @@ #+SETUPFILE: ../../aurellem/org/setup.org #+INCLUDE: ../../aurellem/org/level-0.org + +* objectives + - [ ] get an overall bitmap-like image for touch + - [ ] write code to visuliaze this bitmap + - [ ] directly change the UV-pixels to show touch sensor activation + - [ ] write an explination for why b&w bitmaps for senses is appropiate + - [ ] clean up touch code and write visulazation test + - [ ] do the same for eyes + * Intro So far, I've made the following senses -- - Vision @@ -49,8 +58,63 @@ (use '(cortex world util body hearing touch vision)) (rlm.rlm-commands/help) +(import java.awt.image.BufferedImage) +(import javax.swing.JPanel) +(import javax.swing.SwingUtilities) +(import java.awt.Dimension) +(import javax.swing.JFrame) +(import java.awt.Dimension) +(declare joint-create) -(declare joint-create) +(defn view-image + "Initailizes a JPanel on which you may draw a BufferedImage. + Returns a function that accepts a BufferedImage and draws it to the + JPanel." + [] + (let [image + (atom + (BufferedImage. 1 1 BufferedImage/TYPE_4BYTE_ABGR)) + panel + (proxy [JPanel] [] + (paint + [graphics] + (proxy-super paintComponent graphics) + (.drawImage graphics @image 0 0 nil))) + frame (JFrame. "Display Image")] + (SwingUtilities/invokeLater + (fn [] + (doto frame + (-> (.getContentPane) (.add panel)) + (.pack) + (.setLocationRelativeTo nil) + (.setResizable true) + (.setVisible true)))) + (fn [#^BufferedImage i] + (reset! image i) + (.setSize frame (+ 8 (.getWidth i)) (+ 28 (.getHeight i))) + (.repaint panel 0 0 (.getWidth i) (.getHeight i))))) + + +(defn visualize [points] + + + +(defn collapse + "Take a set of pairs of integers and collapse them into a + contigous bitmap." + [points] + (let [center [0 0]] + + ) + + + + + + + + + (defn load-bullet [] (let [sim (world (Node.) {} no-op no-op)] @@ -314,7 +378,6 @@ ;; (println-repl (float (/ @timer 60)))))) ))) - (defn colorful [] (.getChild (worm-model) "worm-21")) @@ -364,8 +427,6 @@ (ImagePlus. "UV-map" (ImageToAwt/convert im false false 0)))))) - - (import ij.process.ImageProcessor) (import java.awt.image.BufferedImage) @@ -602,7 +663,8 @@ (set (filter #(not (= geo %)) (map #(.getGeometry %) results)))] - (count touch-objects))))))))) + (if (> (count touch-objects) 0) + 1 0))))))))) (defn touch [#^Node pieces] (let [touch-components @@ -612,11 +674,6 @@ (fn [node] (reduce into [] (map #(% node) touch-components))))) - - - - - (defn all-names [] (concat (re-split #"\n" (slurp (file-str @@ -985,20 +1042,6 @@ ) )) - - -#+end_src - - -* COMMENT generate source -#+begin_src clojure :tangle ../src/cortex/silly.clj -<> -#+end_src - - - - - (defn transform-trianglesdsd "Transform that converts each vertex in the first triangle into the corresponding vertex in the second triangle." @@ -1061,25 +1104,19 @@ (dorun (map println in***)) (println) - ))) - - - - - - - - - + )))) - - - - - - - - ) + + +#+end_src + + +* COMMENT generate source +#+begin_src clojure :tangle ../src/cortex/silly.clj +<> +#+end_src + +