changeset 15:c32f3eb9fdeb

modified fire-cannon-ball to place the ball on a specific node
author Robert McIntyre <rlm@mit.edu>
date Sun, 23 Oct 2011 11:50:17 -0700
parents 3aa1ee6c6308
children d2e9f0d09475
files org/cortex.org org/skin.org
diffstat 2 files changed, 30 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/cortex.org	Sun Oct 23 11:30:42 2011 -0700
     1.2 +++ b/org/cortex.org	Sun Oct 23 11:50:17 2011 -0700
     1.3 @@ -637,14 +637,18 @@
     1.4  		     :shape (Sphere. 32 32 (float r)))))) 
     1.5    ([] (sphere 0.5)))
     1.6  
     1.7 -(defn add-element [game node]
     1.8 +(defn add-element
     1.9 +  ([game element node]
    1.10    (.addAll
    1.11     (.getPhysicsSpace
    1.12      (.getState
    1.13       (.getStateManager game)
    1.14       BulletAppState))
    1.15 -    node)
    1.16 -  (.attachChild (.getRootNode game) node))
    1.17 +    element)
    1.18 +  (.attachChild node element))
    1.19 +  ([game element]
    1.20 +     (add-element game element (.getRootNode game))))
    1.21 +
    1.22  
    1.23  (defn set-gravity*
    1.24    [game gravity]
    1.25 @@ -833,23 +837,27 @@
    1.26        (set-gravity* game new-value)
    1.27        (set-gravity* game gravity))))
    1.28  
    1.29 -(defn fire-cannon-ball []
    1.30 -  (fn [game value]
    1.31 -    (if (not value)
    1.32 -      (let [camera (.getCamera game)
    1.33 -	    cannon-ball
    1.34 -	    (sphere  0.7 
    1.35 -		     :material "Common/MatDefs/Misc/Unshaded.j3md"
    1.36 -		     :texture "Textures/PokeCopper.jpg"
    1.37 -		     :position
    1.38 -		     (.add (.getLocation camera)
    1.39 -			   (.mult (.getDirection camera) (float 1)))
    1.40 -		     :mass 3)] ;200 0.05
    1.41 -	(.setShadowMode cannon-ball RenderQueue$ShadowMode/CastAndReceive)
    1.42 -	(.setLinearVelocity
    1.43 -	 (.getControl cannon-ball RigidBodyControl)
    1.44 -	 (.mult (.getDirection camera) (float 50))) ;50
    1.45 -	(add-element game cannon-ball)))))
    1.46 +(defn fire-cannon-ball 
    1.47 +  ([node]
    1.48 +     (fn [game value]
    1.49 +       (if (not value)
    1.50 +         (let [camera (.getCamera game)
    1.51 +               cannon-ball
    1.52 +               (sphere  0.7 
    1.53 +                        :material "Common/MatDefs/Misc/Unshaded.j3md"
    1.54 +                        :texture "Textures/PokeCopper.jpg"
    1.55 +                        :position
    1.56 +                        (.add (.getLocation camera)
    1.57 +                              (.mult (.getDirection camera) (float 1)))
    1.58 +                        :mass 3)] ;200 0.05
    1.59 +           (.setShadowMode cannon-ball RenderQueue$ShadowMode/CastAndReceive)
    1.60 +           (.setLinearVelocity
    1.61 +            (.getControl cannon-ball RigidBodyControl)
    1.62 +            (.mult (.getDirection camera) (float 50))) ;50
    1.63 +           (add-element game cannon-ball node)))))
    1.64 +  ([]
    1.65 +    (fire-cannon-ball false)))
    1.66 +  
    1.67  
    1.68  (defn floor* []
    1.69    (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240
     2.1 --- a/org/skin.org	Sun Oct 23 11:30:42 2011 -0700
     2.2 +++ b/org/skin.org	Sun Oct 23 11:50:17 2011 -0700
     2.3 @@ -248,7 +248,7 @@
     2.4      
     2.5      (world
     2.6       root-node
     2.7 -     {"key-return" (fire-cannon-ball)}
     2.8 +     {"key-return" (fire-cannon-ball node)}
     2.9       ;;no-op
    2.10       (fn [world]
    2.11       ;;  (Capture/SimpleCaptureVideo
    2.12 @@ -261,7 +261,7 @@
    2.13  
    2.14       (fn [& _]
    2.15         (let [touch-data (touch-percieve 0.2 b node)]
    2.16 -         (println-repl touch-data)
    2.17 +         ;;(println-repl touch-data)
    2.18           (manage-ray-debug-node debug-node b touch-data 0.2))
    2.19         (Thread/sleep 10)
    2.20         ;;(touch-print controls)