# HG changeset patch # User Robert McIntyre # Date 1319389742 25200 # Node ID 0251b7e7609f935a88c467517f114f4d5d1450a1 # Parent 7d0c0282c3a75e848826a4edb70d29bbe62e8ac0 finally got raycasting tough to work diff -r 7d0c0282c3a7 -r 0251b7e7609f org/skin.org --- a/org/skin.org Sun Oct 23 01:27:20 2011 -0700 +++ b/org/skin.org Sun Oct 23 10:09:02 2011 -0700 @@ -140,8 +140,18 @@ (.mult (.getDirection ray) (float (.getLimit ray)))))))) - +(defn contact-color [contacts] + (case contacts + 0 ColorRGBA/Gray + 1 ColorRGBA/Blue + 2 ColorRGBA/Green + 3 ColorRGBA/Yellow + 4 ColorRGBA/Orange + 5 ColorRGBA/Red + 6 ColorRGBA/Magenta + 7 ColorRGBA/Pink + 8 ColorRGBA/White)) (defn normal-rays "returns rays" @@ -153,7 +163,9 @@ (Ray. (get-ray-origin geom tri) (get-ray-direction geom tri)) - (.setLimit limit))) + (.setLimit limit) + ) + ) (triangles geom)))) @@ -168,17 +180,19 @@ (for [ray normals] (do (let [results (CollisionResults.)] - (.collideWith geom ray results) - (let [color (contact-color (.size results))] - - (.attachChild debug-node (ray-debug ray color)) - (.attachChild debug-node (ray-origin-debug ray color)) - ) + (.collideWith node ray results) + (let [answer (count (filter #(not (= geom (.getGeometry %))) results)) + ;;color (contact-color answer) + ] + ;;(dorun (map #(println-repl (.getName (.getGeometry %))) results)) + ;;(.attachChild debug-node (ray-debug ray color)) + ;;(.attachChild debug-node (ray-origin-debug ray color)) - (println-repl (.size results) "results for " ray) - (doall (map (partial collision-debug node) results)) - (.size results) - )))))) + + ;;(println-repl (.size results) "results for " ray) + ;;(doall (map (partial collision-debug node) results)) + answer + ))))))) (defn make-touch [#^Geometry geom] (let [tri (Triangle.) @@ -213,6 +227,11 @@ (use 'hello.brick-wall) + + + + + (defn touch-reception [controls] (let [control (first @@ -282,7 +301,7 @@ (make-shape (merge base-shape {:position (Vector3f. 0 2 0) - :name "the blob." + :name "box" :material "Common/MatDefs/Misc/Unshaded.j3md" :texture "Textures/purpleWisp.png" :physical? true @@ -299,7 +318,8 @@ (doto (box 5 0.2 5 :mass 0 :position (Vector3f. 0 -2 0) :material "Common/MatDefs/Misc/Unshaded.j3md" - :texture "Textures/redWisp.png") + :texture "Textures/redWisp.png" + :name "floor") (-> (.getMaterial) (.getAdditionalRenderState) (.setBlendMode RenderState$BlendMode/Alpha)) @@ -315,8 +335,9 @@ (defn test-skin [] (let [b + (transparent-box) ;;(transparent-sphere) - (transparent-box) + ;;(sphere) f (transparent-floor) ;;controls ;;(make-touch-sphere b) @@ -332,7 +353,8 @@ node {"key-return" (fire-cannon-ball) "key-space" (fn [game value] - (println-repl (touch-percieve 1 b node debug-node))) + (if value + (println-repl (touch-percieve 0.2 b node debug-node)))) } ;;no-op (fn [world] @@ -345,7 +367,9 @@ ) (fn [& _] - (Thread/sleep 10) + ;;(println-repl + (touch-percieve 0.2 b node debug-node) + ;;(Thread/sleep 10) ;;(touch-print controls) ;;(color-touch controls) )))) @@ -358,6 +382,8 @@ + + * COMMENT code generation