# HG changeset patch # User Robert McIntyre # Date 1326982960 25200 # Node ID f89f0b9ed2fee8451cb9332cb9760770b3167fc3 # Parent c05d8d222166607baeae77230218af795e45c264 changed touch image retrieval code to use meta-data in preparation for multiple sensor maps per object diff -r c05d8d222166 -r f89f0b9ed2fe assets/Models/creature1/hand.png Binary file assets/Models/creature1/hand.png has changed diff -r c05d8d222166 -r f89f0b9ed2fe assets/Models/creature1/tip.png Binary file assets/Models/creature1/tip.png has changed diff -r c05d8d222166 -r f89f0b9ed2fe assets/Models/creature1/tip.xcf Binary file assets/Models/creature1/tip.xcf has changed diff -r c05d8d222166 -r f89f0b9ed2fe assets/Models/creature1/try-again.blend Binary file assets/Models/creature1/try-again.blend has changed diff -r c05d8d222166 -r f89f0b9ed2fe org/test-creature.org --- a/org/test-creature.org Mon Jan 16 03:19:15 2012 -0700 +++ b/org/test-creature.org Thu Jan 19 07:22:40 2012 -0700 @@ -423,20 +423,17 @@ ;; Every vertex has its own index as well. (defn tactile-sensor-image - "Return the touch-sensor distribution image in ImagePlus format, or - nil if it does not exist." + "Return the touch-sensor distribution image in BufferedImage format, + or nil if it does not exist." [#^Geometry obj] - (let [mat (.getMaterial obj)] - (if-let [texture-param - (.getTextureParam - mat - MaterialHelper/TEXTURE_TYPE_DIFFUSE)] - (let - [texture - (.getTextureValue texture-param) - im (.getImage texture)] - (ImageToAwt/convert im false false 0))))) - + (if-let [image-path (meta-data obj "touch")] + (ImageToAwt/convert + (.getImage + (.loadTexture + (asset-manager) + image-path)) + false false 0))) + (import ij.process.ImageProcessor) (import java.awt.image.BufferedImage) @@ -707,18 +704,18 @@ (enable-debug world) ;;(com.aurellem.capture.Capture/captureVideo ;; world (file-str "/home/r/proj/ai-videos/hand")) - (.setTimer world (RatchetTimer. 60)) - (speed-up world) + ;;(.setTimer world (RatchetTimer. 60)) + ;;(speed-up world) ;;(set-gravity world (Vector3f. 0 0 0)) ) (fn [world tpf] ;;(dorun ;; (map #(%1 %2) touch-nerves (repeat (.getRootNode world)))) - + (dorun (map #(%1 (%2 (.getRootNode world))) - touch-debug-windows touch-nerves)) - + touch-debug-windows touch-nerves) + ) ) ;;(let [timer (atom 0)] @@ -741,40 +738,49 @@ (defn collision-test [] - (let [a-radius 1 - a-position (Vector3f. -0.25 3 0) - b-radius 1 - b-position (Vector3f. 0.25 3 0) - - - obj-a (box 1 1 1 :color ColorRGBA/Red - :position a-position - :physical? false) + (let [b-radius 1 + b-position (Vector3f. 0 0 0) obj-b (box 1 1 1 :color ColorRGBA/Blue :position b-position - :physical? false) - node (nodify [obj-a obj-b]) - bounds-a (BoundingBox. a-position 1 1 1) - bounds-b (BoundingBox. b-position 1 1 1) + :mass 0) + node (nodify [obj-b]) + bounds-b + (doto (Picture.) + (.setHeight 50) + (.setWidth 50) + (.setImage (asset-manager) + "Models/creature1/hand.png" + false + )) + + ;;(Ray. (Vector3f. 0 -5 0) (.normalize (Vector3f. 0 1 0))) + + collisions + (let [cr (CollisionResults.)] + (.collideWith node bounds-b cr) + (println (map #(.getContactPoint %) cr)) + cr) + + ;;collision-points + ;;(map #(sphere 0.1 :position (.getContactPoint %)) + ;; collisions) + + ;;node (nodify (conj collision-points obj-b)) + sim (world node - {} + {"key-space" + (fn [_ value] + (if value + (let [cr (CollisionResults.)] + (.collideWith node bounds-b cr) + (println-repl (map #(.getContactPoint %) cr)) + cr)))} no-op no-op) ] - (.setBound (.getMesh obj-a) bounds-a) - (.updateBound (.getMesh obj-a)) - - - (.setBound (.getMesh obj-b) bounds-b) - (.updateBound (.getMesh obj-b)) - - - - (let [cr (CollisionResults.)] - (.collideWith node bounds-a cr) - [cr sim]) + sim ))