# HG changeset patch # User Robert McIntyre # Date 1321331423 25200 # Node ID 00d0e1639d4bc9e12be69ae237f70950c0391745 # Parent 2a6ede6d8ad89c2feb23b8d23bd3d32650645590 simplified world, got buggy physics ragdoll working diff -r 2a6ede6d8ad8 -r 00d0e1639d4b assets/Models/anim2/Cube.material --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/assets/Models/anim2/Cube.material Mon Nov 14 21:30:23 2011 -0700 @@ -0,0 +1,32 @@ + +// blender material: Material +material Material +{ + receive_shadows on + technique b2ogre_1321319923.771223 + { + pass b2ogre_1321319923.77125 + { + ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0 + diffuse 0.6400000190734865 0.6400000190734865 0.6400000190734865 1.0 + specular 0.5 0.5 0.5 1.0 12.5 + emissive 0.0 0.0 0.0 1.0 + alpha_to_coverage off + colour_write on + cull_hardware clockwise + depth_check on + depth_func less_equal + depth_write on + illumination_stage + light_clip_planes off + light_scissor off + lighting on + normalise_normals off + polygon_mode solid + scene_blend one zero + scene_blend_op add + shading gouraud + transparent_sorting on + } + } +} diff -r 2a6ede6d8ad8 -r 00d0e1639d4b org/body.org --- a/org/body.org Mon Nov 14 19:44:30 2011 -0700 +++ b/org/body.org Mon Nov 14 21:30:23 2011 -0700 @@ -58,6 +58,14 @@ (first (seq (.getChildren (load-blender-model "Models/anim2/worm3.blend"))))) +(defn skel [node] + (doto + (.getSkeleton + (.getControl node SkeletonControl)) + ;; this is necessary to force the skeleton to have accurate world + ;; transforms before it is rendered to the screen. + (.resetAndUpdate))) + (defprotocol Textual (text [something] "Display a detailed textual analysis of the given object.")) @@ -76,7 +84,7 @@ Textual (text [control] (let [animations (.getAnimationNames control)] - (println "Animation Control with " (count animations) " animations:") + (println "Animation Control with " (count animations) " animation(s):") (dorun (map println animations))))) (extend-type com.jme3.animation.SkeletonControl @@ -85,6 +93,12 @@ (println "Skeleton Control with the following skeleton:") (println (.getSkeleton control)))) +(extend-type com.jme3.bullet.control.KinematicRagdollControl + Textual + (text [control] + (println "Ragdoll Control"))) + + (extend-type com.jme3.scene.Geometry Textual (text [control] @@ -94,26 +108,49 @@ (defn body - "given a node with a skeleton, will produce a body sutiable for AI - control with movement and proprioception." + "given a node with a SkeletonControl, will produce a body sutiable + for AI control with movement and proprioception." [node] (let [skeleton-control (.getControl node SkeletonControl) krc (KinematicRagdollControl. (float 0.5))] (dorun (map #(.addBoneName krc %) - ["mid1" "mid2" "mid3" "tail" "head"])) + ["mid1" "mid2" "mid3" "tail" "head"] + ;; ["Ulna.L" + ;; "Ulna.R" + ;; "Chest" + ;; "Foot.L" + ;; "Foot.R" + ;; "Hand.R" + ;; "Hand.L" + ;; "Neck" + ;; "Root" + ;; "Stomach" + ;; "Waist" + ;; "Humerus.L" + ;; "Humerus.R" + ;; "Thigh.L" + ;; "Thigh.R" + ;; "Calf.L" + ;; "Calf.R" + ;; "Clavicle.L" + ;; "Clavicle.R"] + )) + + + (.addControl node krc) - (.setRagdollMode krc)) + (.setRagdollMode krc) + ) node ) -(defn - green-x-ray [] +(defn green-x-ray [] (doto (Material. (asset-manager) "Common/MatDefs/Misc/Unshaded.j3md") (.setColor "Color" ColorRGBA/Green) - (-> (.getAdditionalRenderState) (.setDepthTest - false)))) + (-> (.getAdditionalRenderState) + (.setDepthTest false)))) (defn view-skeleton [node] (let [sd @@ -154,33 +191,17 @@ bones))) debug-node) -(defn skel [node] - (doto - (.getSkeleton - (.getControl node SkeletonControl)) - ;; this is necessary to force the skeleton to have accurate world - ;; transforms before it is rendered to the screen. - (.resetAndUpdate))) - - - - - -(view - (init-debug-skel-node - (fn [b] (.getWorldBindPosition b)) - (Node. "skel-debug") (skel (worm)))) - - - - +(import jme3test.bullet.PhysicsTestHelper) (defn test-ragdoll [] (let [the-worm (body - (.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml") + ;;(.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml") ;;(worm-blender) + (worm) + ;;(oto) + ;;(sinbad) ) ] @@ -192,6 +213,11 @@ {"mouse-left" (fire-cannon-ball)} (fn [world] (light-up-everything world) + (PhysicsTestHelper/createPhysicsTestWorld + (.getRootNode world) + (asset-manager) + (.getPhysicsSpace + (.getState (.getStateManager world) BulletAppState))) ;;(.setTimer world (NanoTimer.)) ;;(org.lwjgl.input.Mouse/setGrabbed false) ) @@ -203,60 +229,6 @@ - - - - - - - - - - - - - - - -(defn test-worm-anim [] - - (let [the-worm -;; (oto) - (worm-blender) - anim-control (.getControl the-worm AnimControl) - channel (doto (.createChannel anim-control) -;; (.setAnim "Walk") - (.setAnim "moveHead") - ) - - play-anim - no-op - ;; (fn [world pressed] -;; (if (not pressed) -;; (do -;; (println-repl "space") -;; ;; (.setAnim channel "moveHead") -;; (.setAnim channel "Walk" (float 0.5)) -;; ))) - - ] - - (.start - (world - (doto (Node.) - (.attachChild the-worm)) - {"key-space" play-anim - "mouse-left" (fire-cannon-ball)} - (fn [world] - (light-up-everything world) - ;;(.setTimer world (NanoTimer.)) - (org.lwjgl.input.Mouse/setGrabbed false) - ) - no-op - ) - - - ))) diff -r 2a6ede6d8ad8 -r 00d0e1639d4b org/skin.org --- a/org/skin.org Mon Nov 14 19:44:30 2011 -0700 +++ b/org/skin.org Mon Nov 14 21:30:23 2011 -0700 @@ -112,7 +112,7 @@ (cortex.import/mega-import-jme3) -(use 'hello.brick-wall) + (defn ray-origin-debug [ray color] diff -r 2a6ede6d8ad8 -r 00d0e1639d4b org/world.org --- a/org/world.org Mon Nov 14 19:44:30 2011 -0700 +++ b/org/world.org Mon Nov 14 21:30:23 2011 -0700 @@ -293,14 +293,18 @@ (Vector3f. 0 -9.81 0)) ;; go through every object and add it to the physics ;; manager if relevant. - (traverse (fn [geom] - (dorun - (for [n (range (.getNumControls geom))] - (do - (.add (.getPhysicsSpace physics-manager) - (.getControl geom n)))))) - (.getRootNode this)) + ;;(traverse (fn [geom] + ;; (dorun + ;; (for [n (range (.getNumControls geom))] + ;; (do + ;; (cortex.util/println-repl + ;; "adding " (.getControl geom n)) + ;; (.add (.getPhysicsSpace physics-manager) + ;; (.getControl geom n)))))) + ;; (.getRootNode this)) ;; call the supplied setup-fn + ;; simpler ! + (.addAll (.getPhysicsSpace physics-manager) root-node) (if setup-fn (setup-fn this)))) (simpleUpdate