# HG changeset patch # User Robert McIntyre # Date 1319356173 25200 # Node ID 9ccfbcbed90a2fa82fb45272cdebe43dab8dcebb # Parent e3c6d1c1cb003626409f1bf7f9f0c0bc4634f28e refactored to help fix ray casting problem diff -r e3c6d1c1cb00 -r 9ccfbcbed90a org/skin.org --- a/org/skin.org Sun Oct 23 00:17:54 2011 -0700 +++ b/org/skin.org Sun Oct 23 00:49:33 2011 -0700 @@ -99,51 +99,32 @@ (comp no-op #(.getCenter %)) (triangles geom)))) +(defn get-ray-origin + [geom tri] + (let [new (Vector3f.)] + (.calculateCenter tri) + (.localToWorld geom (.get tri 1) new) + new)) - - -(defn normal-arrows - "returns a node containing arrows which point - in the normal direction of each face of the - given Geometry" - [#^Geometry geom] - (let [node (Node.)] - (dorun - (map #(.attachChild node %) - (map - (fn [tri] - (make-shape +(defn get-ray-direction + [geom tri] + (let [new (Vector3f.)] + (.calculateNormal tri) + (.localToWorld geom (.getNormal tri) new) + new + Vector3f/UNIT_Y)) + +(defn ray-origin-debug + [ray] + (make-shape (assoc base-shape :shape (Sphere. 5 5 0.05) :name "arrow" :color ColorRGBA/Orange :texture false - :asset-manager (asset-manager) :physical? false - ;;:rotation - ;;(.mult - ;; (doto (Quaternion.) - ;; (.lookAt (.getNormal tri) - ;; Vector3f/UNIT_Y)) - ;; (.getLocalRotation geom)) :position - (.add - (.getCenter tri) - (.getLocalTranslation geom))))) - (triangles geom)))) - node)) - - -(defn get-ray-origin - [geom tri] - (.add - (.getCenter tri) - (.getLocalTranslation geom))) - -(defn get-ray-direction - [geom tri] - (.mult (.getLocalRotation geom) - (.getNormal tri))) + (.getOrigin ray)))) (defn ray-debug [ray] (make-shape @@ -185,7 +166,7 @@ (defn touch-percieve [limit geom node debug-node] (let [normals (normal-rays limit geom)] (.detachAllChildren debug-node) - (.attachChild debug-node (normal-arrows geom)) + (println-repl "---------") (doall @@ -193,6 +174,7 @@ (do (let [results (CollisionResults.)] (.attachChild debug-node (ray-debug ray)) + (.attachChild debug-node (ray-origin-debug ray)) (.collideWith geom ray results) ;;(println-repl (.size results) "results for " ray) @@ -200,12 +182,6 @@ (.size results) )))))) -(defn arrow-view [obj] - (view (doto (Node.) - (.attachChild (normal-arrows obj)) - (.attachChild obj)))) - - (defn make-touch [#^Geometry geom] (let [tri (Triangle.) mesh (.getMesh geom)