# HG changeset patch # User Robert McIntyre # Date 1326028318 25200 # Node ID 6d7c17c847a34bb79184ba92c97907830292637d # Parent cd5151b5e7c3a18baf88f5313faef53897d83826 saving progress diff -r cd5151b5e7c3 -r 6d7c17c847a3 assets/Models/creature1/end.png Binary file assets/Models/creature1/end.png has changed diff -r cd5151b5e7c3 -r 6d7c17c847a3 assets/Models/creature1/one.blend Binary file assets/Models/creature1/one.blend has changed diff -r cd5151b5e7c3 -r 6d7c17c847a3 assets/Models/creature1/tip.png Binary file assets/Models/creature1/tip.png has changed diff -r cd5151b5e7c3 -r 6d7c17c847a3 assets/Models/creature1/try-again.blend Binary file assets/Models/creature1/try-again.blend has changed diff -r cd5151b5e7c3 -r 6d7c17c847a3 assets/Models/creature1/worm-2-UV-layout.png Binary file assets/Models/creature1/worm-2-UV-layout.png has changed diff -r cd5151b5e7c3 -r 6d7c17c847a3 org/test-creature.org --- a/org/test-creature.org Sat Jan 07 10:49:49 2012 -0700 +++ b/org/test-creature.org Sun Jan 08 06:11:58 2012 -0700 @@ -264,6 +264,10 @@ (def worm "Models/creature1/try-again.blend") +(def touch "Models/creature1/touch.blend") + +(defn worm-model [] (load-blender-model worm)) + (defn x-ray [#^ColorRGBA color] (doto (Material. (asset-manager) "Common/MatDefs/Misc/Unshaded.j3md") @@ -285,19 +289,105 @@ x-axis y-axis z-axis ]) standard-debug-controls - (comp light-up-everything enable-debug - (fn [world] - (.setTimer world (NanoTimer.)) - ;;(set-gravity world (Vector3f. 0 0 0)) - (speed-up world) - world - )) - no-op))) + (fn [world] + (light-up-everything world) + (enable-debug world) + ;;(com.aurellem.capture.Capture/captureVideo + ;; world (file-str "/home/r/proj/ai-videos/hand")) + (.setTimer world (NanoTimer.)) + ;;(set-gravity world (Vector3f. 0 0 0)) + (speed-up world) + ) + no-op + ;;(let [timer (atom 0)] + ;; (fn [_ _] + ;; (swap! timer inc) + ;; (if (= (rem @timer 60) 0) + ;; (println-repl (float (/ @timer 60)))))) + ))) + + +(def colorful (.getChild (worm-model) "worm-21")) + +(def im-data + (let [sink (byte-array 3145727) + data (.getData (.getImage texture) 0)] + (.rewind data) + (.get data sink) + (vec (seq sink)))) + + +(import jme3tools.converters.ImageToAwt) + +(import ij.ImagePlus) + + + +(defn triangle-indices + "Get the triangle vertex indices of a given triangle from a given + mesh." + [#^Mesh mesh triangle-index] + (let [indices (int-array 3)] + (.getTriangle mesh triangle-index indices) + (vec indices))) + +(defn uv-coord + "Get the uv-coordinates of the vertex named by vertex-index" + [#^Mesh mesh vertex-index] + (let [UV-buffer + (.getData + (.getBuffer + mesh + VertexBuffer$Type/TexCoord))] + [(.get UV-buffer (* vertex-index 2)) + (.get UV-buffer (+ 1 (* vertex-index 2)))])) + +(defn touch-receptor-image [#^Geometry obj] + + + +;; yay there's a converter! + +(defn uv-image [] + (let + [colorful (.getChild (worm-model) "worm-21") + mat (.getMaterial colorful) + texture + (.getTextureValue + (.getTextureParam + mat + MaterialHelper/TEXTURE_TYPE_DIFFUSE)) + im (.getImage texture)] + (ImagePlus. + "UV-map" + (ImageToAwt/convert im false false 0)))) + +;; for each triangle in the mesh, +;; get the normal to the triangle, +;; look at the UV touch map, restricted to that triangle, +;; get the positions of those touch sensors in geometry-relative +;; coordinates. + + + + + + + + + +(defrecord LulzLoader []) +(defprotocol Lulzable (load-lulz [this])) +(extend-type LulzLoader + Lulzable + (load-lulz [this] (println "the lulz have arrived!"))) + +(defn + + (defn world-setup [joint] - (let [ - - joint-position (Vector3f. 0 0 0) + (let [joint-position (Vector3f. 0 0 0) joint-rotation (.toRotationMatrix (.mult