|
|
@ -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()) { |
|
|
|
|
|
|
|
|
|
|
@ -92,9 +93,13 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener |
|
|
|
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); |
|
|
|
|
|
|
|
link.bone.setUserControl(true); |
|
|
|
|
|
|
|
link.bone.setUserTransformsWorld(position, q2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
if (boneList.isEmpty()) { |
|
|
|
if (boneList.isEmpty()) { |
|
|
|
link.bone.setUserControl(true); |
|
|
|
link.bone.setUserControl(true); |
|
|
|
link.bone.setUserTransformsWorld(position, q2); |
|
|
|
link.bone.setUserTransformsWorld(position, q2); |
|
|
@ -102,8 +107,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener |
|
|
|
setTransform(link.bone, position, q2); |
|
|
|
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
|
|
|
@ -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) { |
|
|
|