changeset 363:9fa92af29c3a

saving ...
author Robert McIntyre <rlm@mit.edu>
date Thu, 07 Mar 2013 05:36:17 +0000
parents 4b229dc028b6
children b599a189433b
files org/gabor.org org/util.org
diffstat 2 files changed, 122 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/gabor.org	Thu Mar 07 03:28:26 2013 +0000
     1.2 +++ b/org/gabor.org	Thu Mar 07 05:36:17 2013 +0000
     1.3 @@ -16,8 +16,20 @@
     1.4    (:import java.awt.image.BufferedImage)
     1.5    (:import ij.ImagePlus)
     1.6    (:import org.opencv.core.Mat)
     1.7 -  (:use cortex.sense)
     1.8 -  (:use cortex.util))
     1.9 +  (:use (cortex world sense util vision))
    1.10 +  (:import com.jme3.post.SceneProcessor)
    1.11 +  (:import (com.jme3.util BufferUtils Screenshots))
    1.12 +  (:import java.nio.ByteBuffer)
    1.13 +  (:import java.awt.image.BufferedImage)
    1.14 +  (:import (com.jme3.renderer ViewPort Camera))
    1.15 +  (:import (com.jme3.math ColorRGBA Vector3f Matrix3f Vector2f))
    1.16 +  (:import com.jme3.renderer.Renderer)
    1.17 +  (:import com.jme3.app.Application)
    1.18 +  (:import com.jme3.texture.FrameBuffer)
    1.19 +  (:import (com.jme3.scene Node Spatial)))
    1.20 +
    1.21 +
    1.22 +(cortex.import/mega-import-jme3)
    1.23  
    1.24  (defn load-opencv
    1.25    "Load the opencv native library. Must be called before any OpenCV
    1.26 @@ -93,8 +105,100 @@
    1.27  (defn print-kernel [kernel]
    1.28    (println (.dump kernel)))
    1.29                             
    1.30 -(defn convolve-practice []
    1.31 -  (let [input "/home/r/proj/cortex/images/dominos.jpg"
    1.32 +
    1.33 +(def brick-length 0.48)
    1.34 +(def brick-width 0.24)
    1.35 +(def brick-height 0.12)
    1.36 +(def gravity (Vector3f. 0 -9.81 0))
    1.37 +
    1.38 +
    1.39 +(defn brick* [position]
    1.40 +  (println "get brick.")
    1.41 +  (doto (box brick-length brick-height brick-width
    1.42 +	     :position position :name "brick"
    1.43 +	     :material "Common/MatDefs/Misc/Unshaded.j3md"
    1.44 +	     :texture "Textures/Terrain/BrickWall/BrickWall.jpg"
    1.45 +	     :mass 34)
    1.46 +    (->
    1.47 +     (.getMesh)
    1.48 +     (.scaleTextureCoordinates (Vector2f. 1 0.5)))
    1.49 +    (.setShadowMode RenderQueue$ShadowMode/CastAndReceive)
    1.50 +    )
    1.51 +  )
    1.52 +
    1.53 +
    1.54 +(defn floor*
    1.55 +  "make a sturdy, unmovable physical floor"
    1.56 +  []
    1.57 +  (box 10 0.1 5 :name "floor" :mass 0 :color ColorRGBA/Gray :position (Vector3f. 0 0 0)))
    1.58 +
    1.59 +(defn floor* []
    1.60 +  (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240
    1.61 +	     :material "Common/MatDefs/Misc/Unshaded.j3md"
    1.62 +	     :texture "Textures/BronzeCopper030.jpg"
    1.63 +	     :position (Vector3f. 0 0 0 )
    1.64 +	     :mass 0)
    1.65 +    (->
    1.66 +     (.getMesh)
    1.67 +     (.scaleTextureCoordinates (Vector2f. 3 6)));64 64
    1.68 +    (->
    1.69 +     (.getMaterial)
    1.70 +     (.getTextureParam "ColorMap")
    1.71 +     (.getTextureValue)
    1.72 +     (.setWrap Texture$WrapMode/Repeat))
    1.73 +    (.setShadowMode RenderQueue$ShadowMode/Receive)
    1.74 +  ))
    1.75 +
    1.76 +
    1.77 +(defn brick-wall* []
    1.78 +  (let [node (Node. "brick-wall")]
    1.79 +    (dorun
    1.80 +     (map
    1.81 +      (comp  #(.attachChild node %) brick*)
    1.82 +       (for [y (range 10)
    1.83 +	     x (range 4)
    1.84 +	     z (range 1)]
    1.85 +       	    (Vector3f.
    1.86 +       	     (+ (* 2 x brick-length)
    1.87 +		(if (even? (+ y z)) 
    1.88 +		  (/ brick-length 4) (/ brick-length -4)))
    1.89 +       	     (+ (* brick-height (inc (* 2 y))))
    1.90 +	     (* 2 z brick-width) ))))
    1.91 +    (.setShadowMode node RenderQueue$ShadowMode/CastAndReceive)
    1.92 +    node))
    1.93 +
    1.94 +(import com.aurellem.capture.Capture)
    1.95 +
    1.96 +(import java.io.File)
    1.97 +
    1.98 +
    1.99 +(defn brick-wall-game-run [record?]
   1.100 +  (doto
   1.101 +      (world
   1.102 +       (doto (Node.) (.attachChild (floor*))
   1.103 +	     (.attachChild (brick-wall*))
   1.104 +	     )
   1.105 +       {"key-f" (fn [game value] 
   1.106 +		  (if (not value) (add-element game (brick-wall*))))
   1.107 +	"key-space" (fire-cannon-ball )}
   1.108 +       (fn [world]
   1.109 +         (position-camera world
   1.110 +          (Vector3f. 1.382548, 4.0383573, 5.994235)
   1.111 +          (Quaternion. 0.0013082094, 0.98581666, -0.1676442, 0.0076932586))
   1.112 +
   1.113 +         ;;(speed-up world)
   1.114 +         
   1.115 +         (if record?
   1.116 +           (Capture/captureVideo
   1.117 +            world
   1.118 +            (File.
   1.119 +             "/home/r/proj/cortex/render/gabor-1/main")))
   1.120 +           (add-camera! world (.getCamera world) no-op))
   1.121 +       (fn [& _]))     
   1.122 +    (.start)))
   1.123 +
   1.124 +(defn convolve-practice [kernel]
   1.125 +  (let [input "/home/r/proj/cortex/render/gabor-1/main/0000032.png"
   1.126          
   1.127          
   1.128          output "/home/r/ppp.png"
   1.129 @@ -114,6 +218,14 @@
   1.130      (view (ImagePlus. input))
   1.131      (view (ImagePlus. output))))
   1.132  
   1.133 +
   1.134 +
   1.135 +(defn generate-gabor-images []
   1.136 +  (gabor-kernel 2.8 1 0 3.5 0)
   1.137 +
   1.138 +
   1.139 +
   1.140 +
   1.141  #+end_src
   1.142  
   1.143  
     2.1 --- a/org/util.org	Thu Mar 07 03:28:26 2013 +0000
     2.2 +++ b/org/util.org	Thu Mar 07 05:36:17 2013 +0000
     2.3 @@ -276,8 +276,8 @@
     2.4  	geom (Geometry. (:name d) (:shape d))]
     2.5      (if (:texture d)
     2.6        (let [key (TextureKey. (:texture d))]
     2.7 -	;;(.setGenerateMips key true)
     2.8 -	;;(.setTexture mat "ColorMap" (.loadTexture asset-manager key))
     2.9 +	(.setGenerateMips key true)
    2.10 +	(.setTexture mat "ColorMap" (.loadTexture asset-manager key))
    2.11          ))
    2.12      (if (:color d) (.setColor mat "Color" (:color d)))
    2.13      (.setMaterial geom mat)
    2.14 @@ -398,14 +398,15 @@
    2.15         (if (not value)
    2.16           (let [camera (.getCamera game)
    2.17                 cannon-ball
    2.18 -               (sphere  0.7 
    2.19 +               (sphere  0.4
    2.20 +                        ;;:texture nil
    2.21                          :material "Common/MatDefs/Misc/Unshaded.j3md"
    2.22 -                        :color ColorRGBA/White
    2.23 +                        :color ColorRGBA/Blue
    2.24                          :name "cannonball!"
    2.25                          :position
    2.26                          (.add (.getLocation camera)
    2.27                                (.mult (.getDirection camera) (float 1)))
    2.28 -                        :mass 3)] ;200 0.05
    2.29 +                        :mass 25)] ;200 0.05
    2.30             (.setLinearVelocity
    2.31              (.getControl cannon-ball RigidBodyControl)
    2.32              (.mult (.getDirection camera) (float 50))) ;50