changeset 9:7d0c0282c3a7

got positioning right, but there is still a problem
author Robert McIntyre <rlm@mit.edu>
date Sun, 23 Oct 2011 01:27:20 -0700
parents 522cf85fdb57
children 0251b7e7609f
files org/skin.org
diffstat 1 files changed, 14 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/skin.org	Sun Oct 23 00:59:22 2011 -0700
     1.2 +++ b/org/skin.org	Sun Oct 23 01:27:20 2011 -0700
     1.3 @@ -108,28 +108,26 @@
     1.4  
     1.5  (defn get-ray-direction
     1.6    [geom tri]
     1.7 -  (let [new (Vector3f.)]
     1.8 +  (let [n+c (Vector3f.)]
     1.9      (.calculateNormal tri)
    1.10 -    
    1.11 -    (.localToWorld geom (.getNormal tri) new)
    1.12 -    (.subtract new (get-ray-origin geom tri))
    1.13 -               
    1.14 -    ;;Vector3f/UNIT_Y
    1.15 +    (.calculateCenter tri)
    1.16 +    (.localToWorld geom (.add (.getCenter tri) (.getNormal tri)) n+c)
    1.17 +    (.subtract n+c (get-ray-origin geom tri))
    1.18      ))
    1.19    
    1.20  (defn ray-origin-debug
    1.21 -  [ray]
    1.22 +  [ray color]
    1.23    (make-shape
    1.24                (assoc base-shape
    1.25                  :shape (Sphere. 5 5 0.05)
    1.26                  :name "arrow"
    1.27 -                :color ColorRGBA/Orange
    1.28 +                :color color
    1.29                  :texture false
    1.30                  :physical? false
    1.31                  :position
    1.32                  (.getOrigin ray))))
    1.33  
    1.34 -(defn ray-debug [ray]
    1.35 +(defn ray-debug [ray color]
    1.36    (make-shape
    1.37     (assoc
    1.38         base-shape
    1.39 @@ -160,28 +158,25 @@
    1.40  
    1.41  
    1.42  (defn collision-debug [node result]
    1.43 -
    1.44    (println-repl "contact point: " (.getContactPoint result))
    1.45 -
    1.46 -
    1.47    )
    1.48  
    1.49  (defn touch-percieve [limit geom node debug-node]
    1.50    (let [normals  (normal-rays limit geom)]
    1.51      (.detachAllChildren debug-node)
    1.52 -
    1.53 -    
    1.54 -    (println-repl "---------")
    1.55      (doall
    1.56       (for [ray normals]
    1.57         (do
    1.58           (let [results (CollisionResults.)]
    1.59 -           (.attachChild debug-node (ray-debug ray))
    1.60 -           (.attachChild debug-node (ray-origin-debug ray))
    1.61             (.collideWith geom ray results)
    1.62 +           (let [color (contact-color (.size results))]
    1.63 +             
    1.64 +             (.attachChild debug-node (ray-debug ray color))
    1.65 +             (.attachChild debug-node (ray-origin-debug ray color))
    1.66 +           )
    1.67             
    1.68 -            ;;(println-repl (.size results) "results for " ray)
    1.69 -           ;;(doall (map (partial collision-debug node) results))
    1.70 +           (println-repl (.size results) "results for " ray)
    1.71 +           (doall (map (partial collision-debug node) results))
    1.72             (.size results)
    1.73             ))))))
    1.74