comparison org/skin.org @ 20:67d508a1e34d

going to update website/documentation
author Robert McIntyre <rlm@mit.edu>
date Sun, 23 Oct 2011 12:32:56 -0700
parents 5a371057078f
children 6372c108c5c6
comparison
equal deleted inserted replaced
19:5a371057078f 20:67d508a1e34d
25 (rlm.rlm-commands/help) 25 (rlm.rlm-commands/help)
26 26
27 (import java.util.logging.Level) 27 (import java.util.logging.Level)
28 (import java.util.logging.Logger) 28 (import java.util.logging.Logger)
29 (use 'hello.brick-wall) 29 (use 'hello.brick-wall)
30
31
32 30
33 (defn triangles [#^Geometry geom] 31 (defn triangles [#^Geometry geom]
34 (let 32 (let
35 [mesh (.getMesh geom) 33 [mesh (.getMesh geom)
36 triangles (transient [])] 34 triangles (transient [])]
41 (.calculateNormal tri) 39 (.calculateNormal tri)
42 (.calculateCenter tri) 40 (.calculateCenter tri)
43 (conj! triangles tri)))) 41 (conj! triangles tri))))
44 (persistent! triangles))) 42 (persistent! triangles)))
45 43
46
47 (defn get-ray-origin 44 (defn get-ray-origin
48 [geom tri] 45 [geom tri]
49 (let [new (Vector3f.)] 46 (let [new (Vector3f.)]
50 (.calculateCenter tri) 47 (.calculateCenter tri)
51 (.localToWorld geom (.getCenter tri) new) 48 (.localToWorld geom (.getCenter tri) new)
61 )) 58 ))
62 59
63 (defn ray-origin-debug 60 (defn ray-origin-debug
64 [ray color] 61 [ray color]
65 (make-shape 62 (make-shape
66 (assoc base-shape 63 (assoc base-shape
67 :shape (Sphere. 5 5 0.05) 64 :shape (Sphere. 5 5 0.05)
68 :name "arrow" 65 :name "arrow"
69 :color color 66 :color color
70 :texture false 67 :texture false
71 :physical? false 68 :physical? false
72 :position 69 :position
73 (.getOrigin ray)))) 70 (.getOrigin ray))))
74 71
75 (defn ray-debug [ray color] 72 (defn ray-debug [ray color]
76 (make-shape 73 (make-shape
77 (assoc 74 (assoc
78 base-shape 75 base-shape
124 (do 121 (do
125 (.attachChild 122 (.attachChild
126 debug-node 123 debug-node
127 (doto (Node.) 124 (doto (Node.)
128 (.attachChild (ray-origin-debug ray ColorRGBA/Gray)) 125 (.attachChild (ray-origin-debug ray ColorRGBA/Gray))
129 ;;(.attachChild (ray-debug ray ColorRGBA/Gray)) 126 (.attachChild (ray-debug ray ColorRGBA/Gray))
130 )))))) 127 ))))))
131 128
132 (defn manage-ray-debug-node [debug-node geom touch-data limit] 129 (defn manage-ray-debug-node [debug-node geom touch-data limit]
133 (let [rays (normal-rays limit geom)] 130 (let [rays (normal-rays limit geom)]
134 (if (not= (count (.getChildren debug-node)) (count touch-data)) 131 (if (not= (count (.getChildren debug-node)) (count touch-data))
163 (.setLevel (Logger/getLogger "com.jme3") Level/OFF)) 160 (.setLevel (Logger/getLogger "com.jme3") Level/OFF))
164 161
165 (defn set-accuracy [world new-accuracy] 162 (defn set-accuracy [world new-accuracy]
166 (let [physics-manager (.getState (.getStateManager world) BulletAppState)] 163 (let [physics-manager (.getState (.getStateManager world) BulletAppState)]
167 (.setAccuracy (.getPhysicsSpace physics-manager) (float new-accuracy)))) 164 (.setAccuracy (.getPhysicsSpace physics-manager) (float new-accuracy))))
168
169 165
170 (defn transparent-sphere [] 166 (defn transparent-sphere []
171 (doto 167 (doto
172 (make-shape 168 (make-shape
173 (merge base-shape 169 (merge base-shape
225 ] 221 ]
226 222
227 (world 223 (world
228 root-node 224 root-node
229 {"key-return" (fire-cannon-ball node)} 225 {"key-return" (fire-cannon-ball node)}
230 ;;no-op
231 (fn [world] 226 (fn [world]
232 ;; (Capture/SimpleCaptureVideo 227 ;; (Capture/SimpleCaptureVideo
233 ;; world 228 ;; world
234 ;; (file-str "/home/r/proj/cortex/tmp/blob.avi")) 229 ;; (file-str "/home/r/proj/cortex/tmp/blob.avi"))
235 ;; (no-logging) 230 ;; (no-logging)
236 ;;(enable-debug world) 231 ;;(enable-debug world)
237 ;; (set-accuracy world (/ 1 60)) 232 ;; (set-accuracy world (/ 1 60))
238 ) 233 )
239 234
240 (fn [& _] 235 (fn [& _]
241 (let [sensitivity 0.2 236 (let [sensitivity 0.2
242 touch-data (touch-percieve sensitivity b node)] 237 touch-data (touch-percieve sensitivity b node)]