comparison org/skin.org @ 5:93ff2b4e7e6a

trying to resolve sensitivity bugs with tough implementation
author Robert McIntyre <rlm@mit.edu>
date Sat, 22 Oct 2011 01:20:34 -0700
parents 50c92af2018e
children e3c6d1c1cb00
comparison
equal deleted inserted replaced
4:50c92af2018e 5:93ff2b4e7e6a
4 #+description: Simulating touch in JMonkeyEngine 4 #+description: Simulating touch in JMonkeyEngine
5 #+SETUPFILE: ../../aurellem/org/setup.org 5 #+SETUPFILE: ../../aurellem/org/setup.org
6 #+INCLUDE: ../../aurellem/org/level-0.org 6 #+INCLUDE: ../../aurellem/org/level-0.org
7 7
8 8
9 let's see what checkboxes look like:
10
11 * test [1/2]
12 - [ ] item 1
13 - [X] item 2
9 14
10 15
11 * skin! 16 * skin!
17
18
19
20
21
22
23
12 24
13 #+srcname: skin-main 25 #+srcname: skin-main
14 #+begin_src clojure 26 #+begin_src clojure
15 (ns body.skin) 27 (ns body.skin)
16 (use 'cortex.world) 28 (use 'cortex.world)
83 (for [n (range (.getTriangleCount mesh))] 95 (for [n (range (.getTriangleCount mesh))]
84 (do 96 (do
85 (.getTriangle mesh n tri) 97 (.getTriangle mesh n tri)
86 (.calculateCenter tri) 98 (.calculateCenter tri)
87 (.calculateNormal tri) 99 (.calculateNormal tri)
88 (println-repl tri) 100 ;; (println-repl tri)
89 (println-repl (.get1 tri)) 101 ;; (println-repl (.get1 tri))
90 (println-repl (.get2 tri)) 102 ;; (println-repl (.get2 tri))
91 (println-repl (.get3 tri)) 103 ;; (println-repl (.get3 tri))
92 (println-repl (.getCenter tri)) 104 ;; (println-repl (.getCenter tri))
93 (println-repl (.getNormal tri)) 105 ;; (println-repl (.getNormal tri))
94 (let [control 106 (let [control
95 (doto 107 (doto
96 (GhostControl. 108 (GhostControl.
97 109
98 (doto (CompoundCollisionShape.) 110 (doto (CompoundCollisionShape.)
100 (SimplexCollisionShape. Vector3f/ZERO) 112 (SimplexCollisionShape. Vector3f/ZERO)
101 (.mult (.getCenter tri) (float 1))) 113 (.mult (.getCenter tri) (float 1)))
102 (.setMargin 0) 114 (.setMargin 0)
103 )) 115 ))
104 (.setApplyPhysicsLocal true))] 116 (.setApplyPhysicsLocal true))]
105
106 (.addControl geom control) 117 (.addControl geom control)
107 (conj! controls! control))))) 118 (conj! controls! control)))))
108 (persistent! controls!))) 119 (persistent! controls!)))
109
110 (defn make-fucked-touch [#^Geometry geom]
111 (let [tri (Triangle.)
112 mesh (.getMesh geom)
113 controls! (transient [])]
114 (dorun
115 (for [n (range (.getTriangleCount mesh))]
116 (do
117 (.getTriangle mesh n tri)
118 (.calculateCenter tri)
119 (.calculateNormal tri)
120 (println-repl tri)
121 (println-repl (.get1 tri))
122 (println-repl (.get2 tri))
123 (println-repl (.get3 tri))
124 (println-repl (.getCenter tri))
125 (println-repl (.getNormal tri))
126 (let [control1
127 (doto
128 (GhostControl.
129 (doto (CompoundCollisionShape.)
130 (.addChildShape
131 (SimplexCollisionShape. Vector3f/ZERO)
132 (.get1 tri))))
133 (.setApplyPhysicsLocal true))]
134
135 (.addControl geom control1)
136 (conj! controls! control1)
137 )
138
139 ;; (let [control1
140 ;; (doto
141 ;; (GhostControl.
142 ;; (doto (CompoundCollisionShape.)
143 ;; (.addChildShape
144 ;; (SimplexCollisionShape. Vector3f/ZERO)
145 ;; (.get2 tri))))
146 ;; (.setApplyPhysicsLocal true))]
147
148 ;; (.addControl geom control1)
149 ;; (conj! controls! control1)
150 ;; )
151
152 ;; (let [control1
153 ;; (doto
154 ;; (GhostControl.
155 ;; (doto (CompoundCollisionShape.)
156 ;; (.addChildShape
157 ;; (SimplexCollisionShape. Vector3f/ZERO)
158 ;; (.get3 tri))))
159 ;; (.setApplyPhysicsLocal true))]
160
161 ;; (.addControl geom control1)
162 ;; (conj! controls! control1)
163
164 )))
165 (persistent! controls!)))
166
167
168 120
169 (use 'hello.brick-wall) 121 (use 'hello.brick-wall)
170 122
171 (defn touch-reception [controls] 123 (defn touch-reception [controls]
172 (let [control 124 (let [control
187 139
188 (defn html-color [html-str] 140 (defn html-color [html-str]
189 ((fn [[r g b]] (ColorRGBA. r g b (float 1))) 141 ((fn [[r g b]] (ColorRGBA. r g b (float 1)))
190 (map #(float (/ (Integer/parseInt % 16) 255)) 142 (map #(float (/ (Integer/parseInt % 16) 255))
191 (map (partial apply str) (partition 2 html-str))))) 143 (map (partial apply str) (partition 2 html-str)))))
192
193 144
194 (defn color-touch [controls] 145 (defn color-touch [controls]
195 (no-exceptions 146 (no-exceptions
196 (dorun 147 (dorun
197 (map 148 (map
213 (.getPhysicsSpace 164 (.getPhysicsSpace
214 (.getState 165 (.getState
215 (.getStateManager world) 166 (.getStateManager world)
216 BulletAppState)) 167 BulletAppState))
217 (asset-manager))) 168 (asset-manager)))
218
219 (def with-debug
220 '(1 1 1 1 0 1 2 0 2 0 1 1 1 1 0 2 0 2 2 1 0 0 0 1 0 0 0 0 1 0))
221 (def no-debug
222 '(1 1 1 1 0 1 2 0 2 0 1 1 1 1 0 2 0 2 2 1 0 0 0 1 0 0 0 0 1 0))
223
224
225 169
226 (defn transparent-sphere [] 170 (defn transparent-sphere []
227 (doto 171 (doto
228 (make-shape 172 (make-shape
229 (merge base-shape 173 (merge base-shape
299 (enable-debug world) 243 (enable-debug world)
300 (set-accuracy world (/ 1 60)) 244 (set-accuracy world (/ 1 60))
301 ) 245 )
302 246
303 (fn [& _] 247 (fn [& _]
304 (touch-print controls) 248 ;;(touch-print controls)
305 (color-touch controls) 249 (color-touch controls)
306 )))) 250 ))))
307 251
308 #+end_src 252 #+end_src
309 253