changeset 90:6d7c17c847a3

saving progress
author Robert McIntyre <rlm@mit.edu>
date Sun, 08 Jan 2012 06:11:58 -0700
parents cd5151b5e7c3
children 2bcc7636cfea
files assets/Models/creature1/end.png assets/Models/creature1/one.blend assets/Models/creature1/tip.png assets/Models/creature1/try-again.blend assets/Models/creature1/worm-2-UV-layout.png org/test-creature.org
diffstat 6 files changed, 101 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/creature1/end.png has changed
     2.1 Binary file assets/Models/creature1/one.blend has changed
     3.1 Binary file assets/Models/creature1/tip.png has changed
     4.1 Binary file assets/Models/creature1/try-again.blend has changed
     5.1 Binary file assets/Models/creature1/worm-2-UV-layout.png has changed
     6.1 --- a/org/test-creature.org	Sat Jan 07 10:49:49 2012 -0700
     6.2 +++ b/org/test-creature.org	Sun Jan 08 06:11:58 2012 -0700
     6.3 @@ -264,6 +264,10 @@
     6.4  
     6.5  (def worm "Models/creature1/try-again.blend")
     6.6  
     6.7 +(def touch "Models/creature1/touch.blend")
     6.8 +
     6.9 +(defn worm-model [] (load-blender-model worm))
    6.10 +
    6.11  (defn x-ray [#^ColorRGBA color]
    6.12    (doto (Material. (asset-manager)
    6.13                     "Common/MatDefs/Misc/Unshaded.j3md")
    6.14 @@ -285,19 +289,105 @@
    6.15              x-axis y-axis z-axis
    6.16              ])
    6.17     standard-debug-controls
    6.18 -   (comp light-up-everything enable-debug
    6.19 -         (fn [world]
    6.20 -           (.setTimer world (NanoTimer.))
    6.21 -           ;;(set-gravity world (Vector3f. 0 0 0))
    6.22 -           (speed-up world)
    6.23 -           world
    6.24 -           ))
    6.25 -   no-op)))
    6.26 +   (fn [world]
    6.27 +     (light-up-everything world)
    6.28 +     (enable-debug world)
    6.29 +     ;;(com.aurellem.capture.Capture/captureVideo
    6.30 +     ;; world (file-str "/home/r/proj/ai-videos/hand"))
    6.31 +     (.setTimer world (NanoTimer.))
    6.32 +     ;;(set-gravity world (Vector3f. 0 0 0))
    6.33 +     (speed-up world)
    6.34 +     )
    6.35 +   no-op
    6.36 +   ;;(let [timer (atom 0)]
    6.37 +   ;;  (fn [_ _]
    6.38 +   ;;    (swap! timer inc)
    6.39 +   ;;    (if (= (rem @timer 60) 0)
    6.40 +   ;;      (println-repl (float (/ @timer 60))))))
    6.41 +   )))
    6.42 +
    6.43 +
    6.44 +(def colorful (.getChild (worm-model) "worm-21"))
    6.45 +
    6.46 +(def im-data
    6.47 +  (let [sink (byte-array 3145727)
    6.48 +        data (.getData (.getImage texture) 0)]
    6.49 +    (.rewind data)
    6.50 +    (.get data sink)
    6.51 +    (vec (seq sink))))
    6.52 +
    6.53 +
    6.54 +(import jme3tools.converters.ImageToAwt)
    6.55 +
    6.56 +(import ij.ImagePlus)
    6.57 +
    6.58 +
    6.59 +
    6.60 +(defn triangle-indices
    6.61 +  "Get the triangle vertex indices of a given triangle from a given
    6.62 +   mesh."
    6.63 +  [#^Mesh mesh triangle-index]
    6.64 +  (let [indices (int-array 3)]
    6.65 +    (.getTriangle mesh triangle-index indices)
    6.66 +    (vec indices)))
    6.67 +
    6.68 +(defn uv-coord
    6.69 +  "Get the uv-coordinates of the vertex named by vertex-index"
    6.70 +  [#^Mesh mesh vertex-index]
    6.71 +  (let [UV-buffer
    6.72 +        (.getData
    6.73 +         (.getBuffer
    6.74 +          mesh
    6.75 +          VertexBuffer$Type/TexCoord))]
    6.76 +    [(.get UV-buffer (* vertex-index 2))
    6.77 +     (.get UV-buffer (+ 1 (* vertex-index 2)))]))
    6.78 +
    6.79 +(defn touch-receptor-image [#^Geometry obj]
    6.80 +  
    6.81 +
    6.82 +
    6.83 +;; yay there's a converter!
    6.84 +
    6.85 +(defn uv-image []
    6.86 +  (let
    6.87 +      [colorful (.getChild (worm-model) "worm-21")
    6.88 +       mat (.getMaterial colorful)
    6.89 +       texture
    6.90 +       (.getTextureValue
    6.91 +        (.getTextureParam
    6.92 +         mat
    6.93 +         MaterialHelper/TEXTURE_TYPE_DIFFUSE))
    6.94 +       im (.getImage texture)]
    6.95 +       (ImagePlus.
    6.96 +        "UV-map"
    6.97 +        (ImageToAwt/convert im false false 0))))
    6.98 +
    6.99 +;; for each triangle in the mesh,
   6.100 +;; get the normal to the triangle,
   6.101 +;; look at the UV touch map, restricted to that triangle,
   6.102 +;; get the positions of those touch sensors in geometry-relative
   6.103 +;; coordinates.
   6.104 +
   6.105 +
   6.106 +
   6.107 +
   6.108 +
   6.109 +
   6.110 +
   6.111 +
   6.112 +       
   6.113 +(defrecord LulzLoader [])
   6.114 +(defprotocol Lulzable (load-lulz [this]))
   6.115 +(extend-type LulzLoader
   6.116 +  Lulzable
   6.117 +  (load-lulz [this] (println "the lulz have arrived!")))
   6.118 +
   6.119 +(defn 
   6.120 +
   6.121 +
   6.122  
   6.123  (defn world-setup [joint]
   6.124 -  (let [
   6.125 -
   6.126 -        joint-position (Vector3f. 0 0 0)
   6.127 +  (let [joint-position (Vector3f. 0 0 0)
   6.128          joint-rotation
   6.129          (.toRotationMatrix
   6.130           (.mult