# HG changeset patch # User Robert McIntyre # Date 1362634577 0 # Node ID 9fa92af29c3a1ccb7c1c8aaad54ac7f0d15621df # Parent 4b229dc028b67badc3fa0afc52a99c2048912a8b saving ... diff -r 4b229dc028b6 -r 9fa92af29c3a org/gabor.org --- a/org/gabor.org Thu Mar 07 03:28:26 2013 +0000 +++ b/org/gabor.org Thu Mar 07 05:36:17 2013 +0000 @@ -16,8 +16,20 @@ (:import java.awt.image.BufferedImage) (:import ij.ImagePlus) (:import org.opencv.core.Mat) - (:use cortex.sense) - (:use cortex.util)) + (:use (cortex world sense util vision)) + (:import com.jme3.post.SceneProcessor) + (:import (com.jme3.util BufferUtils Screenshots)) + (:import java.nio.ByteBuffer) + (:import java.awt.image.BufferedImage) + (:import (com.jme3.renderer ViewPort Camera)) + (:import (com.jme3.math ColorRGBA Vector3f Matrix3f Vector2f)) + (:import com.jme3.renderer.Renderer) + (:import com.jme3.app.Application) + (:import com.jme3.texture.FrameBuffer) + (:import (com.jme3.scene Node Spatial))) + + +(cortex.import/mega-import-jme3) (defn load-opencv "Load the opencv native library. Must be called before any OpenCV @@ -93,8 +105,100 @@ (defn print-kernel [kernel] (println (.dump kernel))) -(defn convolve-practice [] - (let [input "/home/r/proj/cortex/images/dominos.jpg" + +(def brick-length 0.48) +(def brick-width 0.24) +(def brick-height 0.12) +(def gravity (Vector3f. 0 -9.81 0)) + + +(defn brick* [position] + (println "get brick.") + (doto (box brick-length brick-height brick-width + :position position :name "brick" + :material "Common/MatDefs/Misc/Unshaded.j3md" + :texture "Textures/Terrain/BrickWall/BrickWall.jpg" + :mass 34) + (-> + (.getMesh) + (.scaleTextureCoordinates (Vector2f. 1 0.5))) + (.setShadowMode RenderQueue$ShadowMode/CastAndReceive) + ) + ) + + +(defn floor* + "make a sturdy, unmovable physical floor" + [] + (box 10 0.1 5 :name "floor" :mass 0 :color ColorRGBA/Gray :position (Vector3f. 0 0 0))) + +(defn floor* [] + (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240 + :material "Common/MatDefs/Misc/Unshaded.j3md" + :texture "Textures/BronzeCopper030.jpg" + :position (Vector3f. 0 0 0 ) + :mass 0) + (-> + (.getMesh) + (.scaleTextureCoordinates (Vector2f. 3 6)));64 64 + (-> + (.getMaterial) + (.getTextureParam "ColorMap") + (.getTextureValue) + (.setWrap Texture$WrapMode/Repeat)) + (.setShadowMode RenderQueue$ShadowMode/Receive) + )) + + +(defn brick-wall* [] + (let [node (Node. "brick-wall")] + (dorun + (map + (comp #(.attachChild node %) brick*) + (for [y (range 10) + x (range 4) + z (range 1)] + (Vector3f. + (+ (* 2 x brick-length) + (if (even? (+ y z)) + (/ brick-length 4) (/ brick-length -4))) + (+ (* brick-height (inc (* 2 y)))) + (* 2 z brick-width) )))) + (.setShadowMode node RenderQueue$ShadowMode/CastAndReceive) + node)) + +(import com.aurellem.capture.Capture) + +(import java.io.File) + + +(defn brick-wall-game-run [record?] + (doto + (world + (doto (Node.) (.attachChild (floor*)) + (.attachChild (brick-wall*)) + ) + {"key-f" (fn [game value] + (if (not value) (add-element game (brick-wall*)))) + "key-space" (fire-cannon-ball )} + (fn [world] + (position-camera world + (Vector3f. 1.382548, 4.0383573, 5.994235) + (Quaternion. 0.0013082094, 0.98581666, -0.1676442, 0.0076932586)) + + ;;(speed-up world) + + (if record? + (Capture/captureVideo + world + (File. + "/home/r/proj/cortex/render/gabor-1/main"))) + (add-camera! world (.getCamera world) no-op)) + (fn [& _])) + (.start))) + +(defn convolve-practice [kernel] + (let [input "/home/r/proj/cortex/render/gabor-1/main/0000032.png" output "/home/r/ppp.png" @@ -114,6 +218,14 @@ (view (ImagePlus. input)) (view (ImagePlus. output)))) + + +(defn generate-gabor-images [] + (gabor-kernel 2.8 1 0 3.5 0) + + + + #+end_src diff -r 4b229dc028b6 -r 9fa92af29c3a org/util.org --- a/org/util.org Thu Mar 07 03:28:26 2013 +0000 +++ b/org/util.org Thu Mar 07 05:36:17 2013 +0000 @@ -276,8 +276,8 @@ geom (Geometry. (:name d) (:shape d))] (if (:texture d) (let [key (TextureKey. (:texture d))] - ;;(.setGenerateMips key true) - ;;(.setTexture mat "ColorMap" (.loadTexture asset-manager key)) + (.setGenerateMips key true) + (.setTexture mat "ColorMap" (.loadTexture asset-manager key)) )) (if (:color d) (.setColor mat "Color" (:color d))) (.setMaterial geom mat) @@ -398,14 +398,15 @@ (if (not value) (let [camera (.getCamera game) cannon-ball - (sphere 0.7 + (sphere 0.4 + ;;:texture nil :material "Common/MatDefs/Misc/Unshaded.j3md" - :color ColorRGBA/White + :color ColorRGBA/Blue :name "cannonball!" :position (.add (.getLocation camera) (.mult (.getDirection camera) (float 1))) - :mass 3)] ;200 0.05 + :mass 25)] ;200 0.05 (.setLinearVelocity (.getControl cannon-ball RigidBodyControl) (.mult (.getDirection camera) (float 50))) ;50