diff org/test-creature.org @ 109:c05d8d222166

ready to start touch UV maps with GIMP
author Robert McIntyre <rlm@mit.edu>
date Mon, 16 Jan 2012 03:19:15 -0700
parents 92b857b6145d
children f89f0b9ed2fe
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Sun Jan 15 04:08:31 2012 -0700
     1.2 +++ b/org/test-creature.org	Mon Jan 16 03:19:15 2012 -0700
     1.3 @@ -628,7 +628,9 @@
     1.4  (defn enable-touch [#^Geometry geo]
     1.5    (let [feeler-coords (feeler-coordinates geo)
     1.6          tris (triangles geo)
     1.7 -        limit 0.1]
     1.8 +        limit 0.1
     1.9 +        ;;results (CollisionResults.)
    1.10 +        ]
    1.11      (fn [node]
    1.12        (let [sensor-origins 
    1.13              (map
    1.14 @@ -657,6 +659,8 @@
    1.15                    (if (> (count touch-objects) 0)
    1.16                      1 0)))))))))))
    1.17  
    1.18 +
    1.19 +
    1.20  (defn touch [#^Node pieces]
    1.21    (map enable-touch
    1.22         (filter #(isa? (class %) Geometry)
    1.23 @@ -704,12 +708,18 @@
    1.24       ;;(com.aurellem.capture.Capture/captureVideo
    1.25       ;; world (file-str "/home/r/proj/ai-videos/hand"))
    1.26       (.setTimer world (RatchetTimer. 60))
    1.27 -     ;;(speed-up world)
    1.28 +     (speed-up world)
    1.29       ;;(set-gravity world (Vector3f. 0 0 0))
    1.30       )
    1.31     (fn [world tpf]
    1.32 +     ;;(dorun 
    1.33 +     ;; (map #(%1 %2) touch-nerves (repeat (.getRootNode world))))
    1.34 +     
    1.35       (dorun
    1.36 -      (map #(%1 (%2 (.getRootNode world))) touch-debug-windows touch-nerves))
    1.37 +      (map #(%1 (%2 (.getRootNode world)))
    1.38 +           touch-debug-windows touch-nerves))
    1.39 +     
    1.40 +
    1.41       )
    1.42     ;;(let [timer (atom 0)]
    1.43     ;;  (fn [_ _]
    1.44 @@ -718,10 +728,63 @@
    1.45     ;;      (println-repl (float (/ @timer 60))))))
    1.46     )))
    1.47  
    1.48 +
    1.49 +
    1.50 +
    1.51 +
    1.52 +
    1.53 +
    1.54 +
    1.55 +
    1.56 +;;; experiments in collisions
    1.57 +
    1.58 +
    1.59 +
    1.60 +(defn collision-test []
    1.61 +  (let [a-radius 1 
    1.62 +        a-position (Vector3f. -0.25 3 0)
    1.63 +        b-radius 1
    1.64 +        b-position (Vector3f. 0.25 3 0)
    1.65 +
    1.66 +
    1.67 +        obj-a (box 1 1 1 :color ColorRGBA/Red
    1.68 +                      :position a-position
    1.69 +                      :physical? false)
    1.70 +        obj-b (box 1 1 1 :color ColorRGBA/Blue
    1.71 +                      :position b-position
    1.72 +                      :physical? false)
    1.73 +        node (nodify [obj-a obj-b])
    1.74 +        bounds-a (BoundingBox. a-position 1 1 1)
    1.75 +        bounds-b (BoundingBox. b-position 1 1 1)
    1.76 +        sim
    1.77 +        (world node
    1.78 +               {}
    1.79 +               no-op
    1.80 +               no-op)
    1.81 +
    1.82 +        ]
    1.83 +    (.setBound (.getMesh obj-a) bounds-a)
    1.84 +    (.updateBound (.getMesh obj-a))
    1.85 +
    1.86 +    
    1.87 +    (.setBound (.getMesh obj-b) bounds-b)
    1.88 +    (.updateBound (.getMesh obj-b))
    1.89 +
    1.90 +
    1.91 +
    1.92 +    (let [cr (CollisionResults.)]
    1.93 +      (.collideWith node bounds-a cr)
    1.94 +      [cr sim])
    1.95 +    
    1.96 +))
    1.97 +   
    1.98 +    
    1.99 +                         
   1.100 +  
   1.101  #+end_src
   1.102  
   1.103  #+results: body-1
   1.104 -: #'cortex.silly/tactile-coords
   1.105 +: #'cortex.silly/test-creature
   1.106  
   1.107  
   1.108  * COMMENT purgatory