changeset 110:f89f0b9ed2fe

changed touch image retrieval code to use meta-data in preparation for multiple sensor maps per object
author Robert McIntyre <rlm@mit.edu>
date Thu, 19 Jan 2012 07:22:40 -0700
parents c05d8d222166
children 61d9c0e8d188
files assets/Models/creature1/hand.png assets/Models/creature1/tip.png assets/Models/creature1/tip.xcf assets/Models/creature1/try-again.blend org/test-creature.org
diffstat 5 files changed, 50 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/creature1/hand.png has changed
     2.1 Binary file assets/Models/creature1/tip.png has changed
     3.1 Binary file assets/Models/creature1/tip.xcf has changed
     4.1 Binary file assets/Models/creature1/try-again.blend has changed
     5.1 --- a/org/test-creature.org	Mon Jan 16 03:19:15 2012 -0700
     5.2 +++ b/org/test-creature.org	Thu Jan 19 07:22:40 2012 -0700
     5.3 @@ -423,20 +423,17 @@
     5.4  ;; Every vertex has its own index as well.
     5.5  
     5.6  (defn tactile-sensor-image
     5.7 -  "Return the touch-sensor distribution image in ImagePlus format, or
     5.8 -   nil if it does not exist."
     5.9 +  "Return the touch-sensor distribution image in BufferedImage format,
    5.10 +   or nil if it does not exist."
    5.11    [#^Geometry obj]
    5.12 -  (let [mat (.getMaterial obj)]
    5.13 -    (if-let [texture-param
    5.14 -             (.getTextureParam
    5.15 -              mat
    5.16 -              MaterialHelper/TEXTURE_TYPE_DIFFUSE)]
    5.17 -      (let
    5.18 -          [texture
    5.19 -           (.getTextureValue texture-param)
    5.20 -           im (.getImage texture)]
    5.21 -        (ImageToAwt/convert im false false 0)))))
    5.22 -
    5.23 +  (if-let [image-path (meta-data obj "touch")]
    5.24 +    (ImageToAwt/convert
    5.25 +     (.getImage
    5.26 +      (.loadTexture
    5.27 +       (asset-manager)
    5.28 +       image-path))
    5.29 +    false false 0)))
    5.30 +     
    5.31  (import ij.process.ImageProcessor)
    5.32  (import java.awt.image.BufferedImage)
    5.33  
    5.34 @@ -707,18 +704,18 @@
    5.35       (enable-debug world)
    5.36       ;;(com.aurellem.capture.Capture/captureVideo
    5.37       ;; world (file-str "/home/r/proj/ai-videos/hand"))
    5.38 -     (.setTimer world (RatchetTimer. 60))
    5.39 -     (speed-up world)
    5.40 +     ;;(.setTimer world (RatchetTimer. 60))
    5.41 +     ;;(speed-up world)
    5.42       ;;(set-gravity world (Vector3f. 0 0 0))
    5.43       )
    5.44     (fn [world tpf]
    5.45       ;;(dorun 
    5.46       ;; (map #(%1 %2) touch-nerves (repeat (.getRootNode world))))
    5.47 -     
    5.48 +    
    5.49       (dorun
    5.50        (map #(%1 (%2 (.getRootNode world)))
    5.51 -           touch-debug-windows touch-nerves))
    5.52 -     
    5.53 +           touch-debug-windows touch-nerves)
    5.54 +     )
    5.55  
    5.56       )
    5.57     ;;(let [timer (atom 0)]
    5.58 @@ -741,40 +738,49 @@
    5.59  
    5.60  
    5.61  (defn collision-test []
    5.62 -  (let [a-radius 1 
    5.63 -        a-position (Vector3f. -0.25 3 0)
    5.64 -        b-radius 1
    5.65 -        b-position (Vector3f. 0.25 3 0)
    5.66 -
    5.67 -
    5.68 -        obj-a (box 1 1 1 :color ColorRGBA/Red
    5.69 -                      :position a-position
    5.70 -                      :physical? false)
    5.71 +  (let [b-radius 1
    5.72 +        b-position (Vector3f. 0 0 0)
    5.73          obj-b (box 1 1 1 :color ColorRGBA/Blue
    5.74                        :position b-position
    5.75 -                      :physical? false)
    5.76 -        node (nodify [obj-a obj-b])
    5.77 -        bounds-a (BoundingBox. a-position 1 1 1)
    5.78 -        bounds-b (BoundingBox. b-position 1 1 1)
    5.79 +                      :mass 0)
    5.80 +        node (nodify [obj-b])
    5.81 +        bounds-b
    5.82 +        (doto (Picture.)
    5.83 +          (.setHeight 50)
    5.84 +          (.setWidth 50)
    5.85 +          (.setImage (asset-manager)
    5.86 +                     "Models/creature1/hand.png"
    5.87 +                     false
    5.88 +          ))
    5.89 +        
    5.90 +        ;;(Ray. (Vector3f. 0 -5 0) (.normalize (Vector3f. 0 1 0)))
    5.91 +
    5.92 +        collisions
    5.93 +        (let [cr (CollisionResults.)]
    5.94 +          (.collideWith node bounds-b cr)
    5.95 +          (println (map #(.getContactPoint %) cr))
    5.96 +          cr)
    5.97 +
    5.98 +        ;;collision-points
    5.99 +        ;;(map #(sphere 0.1 :position (.getContactPoint %))
   5.100 +        ;;     collisions)
   5.101 +
   5.102 +        ;;node (nodify (conj collision-points obj-b))
   5.103 +        
   5.104          sim
   5.105          (world node
   5.106 -               {}
   5.107 +               {"key-space"
   5.108 +                (fn [_ value]
   5.109 +                  (if value
   5.110 +                    (let [cr (CollisionResults.)]
   5.111 +                      (.collideWith node bounds-b cr)
   5.112 +                      (println-repl (map #(.getContactPoint %) cr))
   5.113 +                      cr)))}
   5.114                 no-op
   5.115                 no-op)
   5.116  
   5.117          ]
   5.118 -    (.setBound (.getMesh obj-a) bounds-a)
   5.119 -    (.updateBound (.getMesh obj-a))
   5.120 -
   5.121 -    
   5.122 -    (.setBound (.getMesh obj-b) bounds-b)
   5.123 -    (.updateBound (.getMesh obj-b))
   5.124 -
   5.125 -
   5.126 -
   5.127 -    (let [cr (CollisionResults.)]
   5.128 -      (.collideWith node bounds-a cr)
   5.129 -      [cr sim])
   5.130 +    sim
   5.131      
   5.132  ))
   5.133