diff org/util.org @ 50:b1b90c4ab0bf

trying to resolve problem with skeleton debugging
author Robert McIntyre <rlm@mit.edu>
date Mon, 14 Nov 2011 18:46:34 -0700
parents ee55966ce7f6
children e5e627f50a3a
line wrap: on
line diff
     1.1 --- a/org/util.org	Sat Nov 12 16:52:38 2011 -0700
     1.2 +++ b/org/util.org	Mon Nov 14 18:46:34 2011 -0700
     1.3 @@ -71,9 +71,11 @@
     1.4  The utilities here come in three main groups:
     1.5   - Changing settings in a running =Application=
     1.6   - Creating objects
     1.7 + - Debug Actions
     1.8   - Visualizing objects
     1.9  
    1.10  
    1.11 +
    1.12  *** Changing Settings
    1.13  
    1.14  #+srcname: util
    1.15 @@ -274,20 +276,10 @@
    1.16    ([] (sphere 0.5)))
    1.17  #+end_src
    1.18  
    1.19 -*** Viewing Objects
    1.20  
    1.21 -#+srcname: world-view
    1.22 +*** Debug Actions
    1.23 +#+srcname: debug-actions
    1.24  #+begin_src clojure :results silent
    1.25 -(in-ns 'cortex.util)
    1.26 -
    1.27 -(defprotocol Viewable
    1.28 -  (view [something]))
    1.29 -
    1.30 -(extend-type com.jme3.scene.Geometry
    1.31 -  Viewable
    1.32 -  (view [geo]
    1.33 -	(view (doto (Node.)(.attachChild geo)))))
    1.34 -
    1.35  (defn basic-light-setup
    1.36    "returns a sequence of lights appropiate for fully lighting a scene"
    1.37    []
    1.38 @@ -318,6 +310,45 @@
    1.39     (map
    1.40      #(.addLight (.getRootNode world) %)
    1.41      (basic-light-setup))))
    1.42 +
    1.43 +(defn fire-cannon-ball
    1.44 +  "Creates a function that fires a cannon-ball from the current game's
    1.45 +  camera. The cannon-ball will be attached to the node if provided, or
    1.46 +  to the game's RootNode if no node is provided."
    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 +           (.setLinearVelocity
    1.60 +            (.getControl cannon-ball RigidBodyControl)
    1.61 +            (.mult (.getDirection camera) (float 50))) ;50
    1.62 +           (add-element game cannon-ball (if node node (.getRootNode game)))))))
    1.63 +  ([]
    1.64 +    (fire-cannon-ball false)))
    1.65 +#+end_src
    1.66 +
    1.67 +
    1.68 +*** Viewing Objects
    1.69 +
    1.70 +#+srcname: world-view
    1.71 +#+begin_src clojure :results silent
    1.72 +(in-ns 'cortex.util)
    1.73 +
    1.74 +(defprotocol Viewable
    1.75 +  (view [something]))
    1.76 +
    1.77 +(extend-type com.jme3.scene.Geometry
    1.78 +  Viewable
    1.79 +  (view [geo]
    1.80 +	(view (doto (Node.)(.attachChild geo)))))
    1.81      
    1.82  (extend-type com.jme3.scene.Node
    1.83    Viewable
    1.84 @@ -351,6 +382,7 @@
    1.85  #+begin_src clojure :tangle ../src/cortex/util.clj :noweb yes
    1.86  <<util>>
    1.87  <<shapes>>
    1.88 +<<debug-actions>>
    1.89  <<world-view>>
    1.90  #+end_src
    1.91