Java Code Examples for com.jme3.animation.AnimControl#setEnabled()
The following examples show how to use
com.jme3.animation.AnimControl#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KinematicRagdollControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * Enable or disable the ragdoll behaviour. * if ragdollEnabled is true, the character motion will only be powerd by physics * else, the characted will be animated by the keyframe animation, * but will be able to physically interact with its physic environnement * @param ragdollEnabled */ protected void setMode(Mode mode) { this.mode = mode; AnimControl animControl = targetModel.getControl(AnimControl.class); animControl.setEnabled(mode == Mode.Kinetmatic); baseRigidBody.setKinematic(mode == Mode.Kinetmatic); TempVars vars = TempVars.get(); for (PhysicsBoneLink link : boneLinks.values()) { link.rigidBody.setKinematic(mode == Mode.Kinetmatic); if (mode == Mode.Ragdoll) { Quaternion tmpRot1 = vars.quat1; Vector3f position = vars.vect1; //making sure that the ragdoll is at the correct place. matchPhysicObjectToBone(link, position, tmpRot1); } } vars.release(); for (Bone bone : skeleton.getRoots()) { RagdollUtils.setUserControl(bone, mode == Mode.Ragdoll); } }
Example 2
Source File: KinematicRagdollControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * Enable or disable the ragdoll behaviour. * if ragdollEnabled is true, the character motion will only be powerd by physics * else, the characted will be animated by the keyframe animation, * but will be able to physically interact with its physic environnement * @param ragdollEnabled */ protected void setMode(Mode mode) { this.mode = mode; AnimControl animControl = targetModel.getControl(AnimControl.class); animControl.setEnabled(mode == Mode.Kinetmatic); baseRigidBody.setKinematic(mode == Mode.Kinetmatic); TempVars vars = TempVars.get(); for (PhysicsBoneLink link : boneLinks.values()) { link.rigidBody.setKinematic(mode == Mode.Kinetmatic); if (mode == Mode.Ragdoll) { Quaternion tmpRot1 = vars.quat1; Vector3f position = vars.vect1; //making sure that the ragdoll is at the correct place. matchPhysicObjectToBone(link, position, tmpRot1); } } vars.release(); for (Bone bone : skeleton.getRoots()) { RagdollUtils.setUserControl(bone, mode == Mode.Ragdoll); } }
Example 3
Source File: KinematicRagdollControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Smoothly blend from Ragdoll mode to Kinematic mode * This is useful to blend ragdoll actual position to a keyframe animation for example * @param blendTime the blending time between ragdoll to anim. */ public void blendToKinematicMode(float blendTime) { if (mode == Mode.Kinetmatic) { return; } blendedControl = true; this.blendTime = blendTime; mode = Mode.Kinetmatic; AnimControl animControl = targetModel.getControl(AnimControl.class); animControl.setEnabled(true); TempVars vars = TempVars.get(); for (PhysicsBoneLink link : boneLinks.values()) { Vector3f p = link.rigidBody.getMotionState().getWorldLocation(); Vector3f position = vars.vect1; targetModel.getWorldTransform().transformInverseVector(p, position); Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat(); Quaternion q2 = vars.quat1; Quaternion q3 = vars.quat2; q2.set(q).multLocal(link.initalWorldRotation).normalizeLocal(); q3.set(targetModel.getWorldRotation()).inverseLocal().mult(q2, q2); q2.normalizeLocal(); link.startBlendingPos.set(position); link.startBlendingRot.set(q2); link.rigidBody.setKinematic(true); } vars.release(); for (Bone bone : skeleton.getRoots()) { RagdollUtils.setUserControl(bone, false); } blendStart = 0; }
Example 4
Source File: KinematicRagdollControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Smoothly blend from Ragdoll mode to Kinematic mode * This is useful to blend ragdoll actual position to a keyframe animation for example * @param blendTime the blending time between ragdoll to anim. */ public void blendToKinematicMode(float blendTime) { if (mode == Mode.Kinetmatic) { return; } blendedControl = true; this.blendTime = blendTime; mode = Mode.Kinetmatic; AnimControl animControl = targetModel.getControl(AnimControl.class); animControl.setEnabled(true); TempVars vars = TempVars.get(); for (PhysicsBoneLink link : boneLinks.values()) { Vector3f p = link.rigidBody.getMotionState().getWorldLocation(); Vector3f position = vars.vect1; targetModel.getWorldTransform().transformInverseVector(p, position); Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat(); Quaternion q2 = vars.quat1; Quaternion q3 = vars.quat2; q2.set(q).multLocal(link.initalWorldRotation).normalizeLocal(); q3.set(targetModel.getWorldRotation()).inverseLocal().mult(q2, q2); q2.normalizeLocal(); link.startBlendingPos.set(position); link.startBlendingRot.set(q2); link.rigidBody.setKinematic(true); } vars.release(); for (Bone bone : skeleton.getRoots()) { RagdollUtils.setUserControl(bone, false); } blendStart = 0; }