- Ragdolled model position now updates when ragdoll has control

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7248 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent 3824676354
commit 9b5aa824fd
  1. 19
      engine/src/jbullet/com/jme3/bullet/control/RagdollControl.java

@ -60,6 +60,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
protected float eventDiscardImpulseThreshold = 3;
protected RagdollPreset preset = new HumanoidRagdollPreset();
protected List<String> boneList = new LinkedList<String>();
protected Vector3f initPosition = new Vector3f();
public RagdollControl() {
}
@ -78,7 +79,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
Quaternion q2 = vars.quat1;
Quaternion q3 = vars.quat2;
Vector3f p2 = vars.vect2;
Vector3f pos = vars.vect2;
// skeleton.reset();
for (PhysicsBoneLink link : boneLinks.values()) {
@ -90,11 +91,15 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat();
q2.set(q).multLocal(link.initalWorldRotation).normalize();
q3.set(targetModel.getWorldRotation()).inverseLocal().mult(q2,q2);
q3.set(targetModel.getWorldRotation()).inverseLocal().mult(q2, q2);
q2.normalize();
if (link.bone.getParent() == null) {
initPosition.set(p).subtractLocal(link.bone.getInitialPos());
targetModel.setLocalTranslation(initPosition);
link.bone.setUserControl(true);
link.bone.setUserTransformsWorld(position, q2);
} else {
if (boneList.isEmpty()) {
link.bone.setUserControl(true);
link.bone.setUserTransformsWorld(position, q2);
@ -102,8 +107,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
setTransform(link.bone, position, q2);
}
}
targetModel.updateModelBound();
}
} else {
for (PhysicsBoneLink link : boneLinks.values()) {
//the ragdoll does not control the skeleton
@ -121,7 +125,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
//computing rotation
rotation.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getWorldBindInverseRotation());
targetModel.getWorldRotation().mult(rotation,rotation);
targetModel.getWorldRotation().mult(rotation, rotation);
rotation.normalize();
// scale.set(link.bone.getModelSpaceScale());
@ -531,6 +535,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
Bone hitBone = null;
PhysicsCollisionObject hitObject = null;
if (objA.getUserObject() instanceof PhysicsBoneLink) {
PhysicsBoneLink link = (PhysicsBoneLink) objA.getUserObject();
if (link != null) {

Loading…
Cancel
Save