comparison org/test-creature.org @ 80:7af5ef686539

got a finger working!
author Robert McIntyre <rlm@mit.edu>
date Thu, 05 Jan 2012 02:35:07 -0700
parents 01dbdb0d5500
children 10f495560c59
comparison
equal deleted inserted replaced
79:01dbdb0d5500 80:7af5ef686539
171 (let [limit-xy (:limit-xz constraints) 171 (let [limit-xy (:limit-xz constraints)
172 limit-yz (:limit-xy constraints) 172 limit-yz (:limit-xy constraints)
173 twist (:twist constraints)] 173 twist (:twist constraints)]
174 174
175 (println-repl "creating CONE joint") 175 (println-repl "creating CONE joint")
176 (doto 176 (let [vector-1
177 (ConeJoint. 177 (.mult (.getWorldRotation joint)
178 control-a 178 Vector3f/UNIT_X)
179 control-b 179 vector-2
180 pivot-a 180 (.normalize
181 pivot-b 181 (.subtract
182 182 (.getWorldTranslation joint)
183 (doto (Matrix3f.) 183 (.getWorldTranslation obj-a)))
184 (.fromStartEndVectors 184 ]
185 Vector3f/UNIT_X 185 (println-repl
186 (.normalize 186 "vector-1 :" vector-1)
187 (.subtract 187 (println-repl
188 (.getWorldTranslation joint) 188 "vector-2 :" vector-2)
189 (.getWorldTranslation obj-a))))) 189
190 (doto (Matrix3f.) 190
191 (.set (.getWorldRotation joint))) 191
192 192 (doto
193 ) 193 (ConeJoint.
194 (.setLimit (float limit-xy) 194 control-a
195 (float limit-yz) 195 control-b
196 (float twist))))) 196 pivot-a
197 true 197 pivot-b
198 (println-repl 198
199 "joint-type" joint-type "not recognized"))) 199 ;;(doto (Matrix3f.)
200 200 ;; (.fromStartEndVectors
201 ;; Vector3f/UNIT_X
202 ;; (.normalize
203 ;; (.subtract
204 ;; (.getWorldTranslation joint)
205 ;; (.getWorldTranslation obj-a)))))
206
207 (.toRotationMatrix (.getWorldRotation joint))
208
209 (.toRotationMatrix
210 (.fromAngleAxis (Quaternion.)
211 (.angleBetween Vector3f/UNIT_X pivot-a)
212 (.cross Vector3f/UNIT_X pivot-a)))
213
214 ;; (doto (Matrix3f.)
215 ;; (.fromStartEndVectors
216 ;; Vector3f/UNIT_X
217 ;; (.normalize
218 ;; vector-1)))
219
220 ;; (doto (Matrix3f.)
221 ;; (.fromStartEndVectors
222 ;; Vector3f/UNIT_X
223 ;; vector-2))
224 )
225 (.setLimit (float limit-xy)
226 (float limit-yz)
227 (float twist))))))
228 true
229 (println-repl
230 "joint-type" joint-type "not recognized")))
231
201 (println-repl "could not find joint meta-data!"))))) 232 (println-repl "could not find joint meta-data!")))))
202 233
203 (defn assemble-creature [#^Node pieces joints] 234 (defn assemble-creature [#^Node pieces joints]
204 (dorun 235 (dorun
205 (map 236 (map
239 270
240 (def hand "Models/creature1/one.blend") 271 (def hand "Models/creature1/one.blend")
241 272
242 (def worm "Models/creature1/try-again.blend") 273 (def worm "Models/creature1/try-again.blend")
243 274
275 (defn x-ray [#^ColorRGBA color]
276 (doto (Material. (asset-manager)
277 "Common/MatDefs/Misc/Unshaded.j3md")
278 (.setColor "Color" color)
279 (-> (.getAdditionalRenderState)
280 (.setDepthTest false))))
281
244 (defn test-creature [thing] 282 (defn test-creature [thing]
283 (let [x-axis
284 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red)
285 y-axis
286 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green)
287 z-axis
288 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue)]
245 (world 289 (world
246 (nodify [(blender-creature thing) 290 (nodify [(blender-creature thing)
247 (box 10 2 10 :position (Vector3f. 0 -5.5 0) 291 (box 10 2 10 :position (Vector3f. 0 -5.5 0)
248 :color ColorRGBA/Gray :mass 0)]) 292 :color ColorRGBA/Gray :mass 0)
293 x-axis y-axis z-axis
294 ])
249 standard-debug-controls 295 standard-debug-controls
250 (comp light-up-everything enable-debug 296 (comp light-up-everything enable-debug
251 (fn [world] 297 (fn [world]
252 (.setTimer world (NanoTimer.)) 298 (.setTimer world (NanoTimer.))
253 ;;(set-gravity world (Vector3f. 0 0 0)) 299 (set-gravity world (Vector3f. 0 0 0))
254 (speed-up world) 300 (speed-up world)
255 world 301 world
256 )) 302 ))
257 no-op)) 303 no-op)))
258 304
259 (defn world-setup [joint] 305 (defn world-setup [joint]
260 (let [top (doto 306 (let [top (doto
261 (sphere 0.1 :physical? false :color ColorRGBA/Yellow 307 (sphere 0.1 :physical? false :color ColorRGBA/Yellow
262 :position (Vector3f. 0 7 0)) 308 :position (Vector3f. 0 7 0))
307 (.fromStartEndVectors Vector3f/UNIT_X 353 (.fromStartEndVectors Vector3f/UNIT_X
308 Vector3f/UNIT_Y)) 354 Vector3f/UNIT_Y))
309 (doto (Matrix3f.) 355 (doto (Matrix3f.)
310 (.fromStartEndVectors Vector3f/UNIT_X 356 (.fromStartEndVectors Vector3f/UNIT_X
311 (.normalize 357 (.normalize
312 (Vector3f. 5 5 0)))) 358 (Vector3f. 0 0 -1))))
313 ) 359 )
314 ;;(.setAngularOnly true) 360 ;;(.setAngularOnly true)
315 361
316 (.setCollisionBetweenLinkedBodys false) 362 (.setCollisionBetweenLinkedBodys false)
317 (.setLimit (* 1 (/ Math/PI 4)) 363 (.setLimit (* 1 (/ Math/PI 4))