- Ragdolled model position now updates when ragdoll has control
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7248 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
3824676354
commit
9b5aa824fd
@ -60,6 +60,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
protected float eventDiscardImpulseThreshold = 3;
|
protected float eventDiscardImpulseThreshold = 3;
|
||||||
protected RagdollPreset preset = new HumanoidRagdollPreset();
|
protected RagdollPreset preset = new HumanoidRagdollPreset();
|
||||||
protected List<String> boneList = new LinkedList<String>();
|
protected List<String> boneList = new LinkedList<String>();
|
||||||
|
protected Vector3f initPosition = new Vector3f();
|
||||||
|
|
||||||
public RagdollControl() {
|
public RagdollControl() {
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
|
|
||||||
Quaternion q2 = vars.quat1;
|
Quaternion q2 = vars.quat1;
|
||||||
Quaternion q3 = vars.quat2;
|
Quaternion q3 = vars.quat2;
|
||||||
Vector3f p2 = vars.vect2;
|
Vector3f pos = vars.vect2;
|
||||||
// skeleton.reset();
|
// skeleton.reset();
|
||||||
for (PhysicsBoneLink link : boneLinks.values()) {
|
for (PhysicsBoneLink link : boneLinks.values()) {
|
||||||
|
|
||||||
@ -90,20 +91,23 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat();
|
Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat();
|
||||||
|
|
||||||
q2.set(q).multLocal(link.initalWorldRotation).normalize();
|
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();
|
q2.normalize();
|
||||||
|
if (link.bone.getParent() == null) {
|
||||||
|
initPosition.set(p).subtractLocal(link.bone.getInitialPos());
|
||||||
|
targetModel.setLocalTranslation(initPosition);
|
||||||
if (boneList.isEmpty()) {
|
|
||||||
link.bone.setUserControl(true);
|
link.bone.setUserControl(true);
|
||||||
link.bone.setUserTransformsWorld(position, q2);
|
link.bone.setUserTransformsWorld(position, q2);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setTransform(link.bone, position, q2);
|
if (boneList.isEmpty()) {
|
||||||
|
link.bone.setUserControl(true);
|
||||||
|
link.bone.setUserTransformsWorld(position, q2);
|
||||||
|
} else {
|
||||||
|
setTransform(link.bone, position, q2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
targetModel.updateModelBound();
|
|
||||||
} else {
|
} else {
|
||||||
for (PhysicsBoneLink link : boneLinks.values()) {
|
for (PhysicsBoneLink link : boneLinks.values()) {
|
||||||
//the ragdoll does not control the skeleton
|
//the ragdoll does not control the skeleton
|
||||||
@ -121,7 +125,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
|
|
||||||
//computing rotation
|
//computing rotation
|
||||||
rotation.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getWorldBindInverseRotation());
|
rotation.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getWorldBindInverseRotation());
|
||||||
targetModel.getWorldRotation().mult(rotation,rotation);
|
targetModel.getWorldRotation().mult(rotation, rotation);
|
||||||
rotation.normalize();
|
rotation.normalize();
|
||||||
|
|
||||||
// scale.set(link.bone.getModelSpaceScale());
|
// scale.set(link.bone.getModelSpaceScale());
|
||||||
@ -531,6 +535,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
Bone hitBone = null;
|
Bone hitBone = null;
|
||||||
PhysicsCollisionObject hitObject = null;
|
PhysicsCollisionObject hitObject = null;
|
||||||
|
|
||||||
|
|
||||||
if (objA.getUserObject() instanceof PhysicsBoneLink) {
|
if (objA.getUserObject() instanceof PhysicsBoneLink) {
|
||||||
PhysicsBoneLink link = (PhysicsBoneLink) objA.getUserObject();
|
PhysicsBoneLink link = (PhysicsBoneLink) objA.getUserObject();
|
||||||
if (link != null) {
|
if (link != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user