|
|
@ -126,6 +126,7 @@ public class KinematicRagdollControl implements PhysicsControl, PhysicsCollision |
|
|
|
protected float totalMass = 0; |
|
|
|
protected float totalMass = 0; |
|
|
|
protected boolean added = false; |
|
|
|
protected boolean added = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static enum Mode { |
|
|
|
public static enum Mode { |
|
|
|
|
|
|
|
|
|
|
|
Kinetmatic, |
|
|
|
Kinetmatic, |
|
|
@ -171,7 +172,7 @@ public class KinematicRagdollControl implements PhysicsControl, PhysicsCollision |
|
|
|
Quaternion tmpRot2 = vars.quat2; |
|
|
|
Quaternion tmpRot2 = vars.quat2; |
|
|
|
|
|
|
|
|
|
|
|
//if the ragdoll has the control of the skeleton, we update each bone with its position in physic world space.
|
|
|
|
//if the ragdoll has the control of the skeleton, we update each bone with its position in physic world space.
|
|
|
|
if (mode == mode.Ragdoll) { |
|
|
|
if (mode == mode.Ragdoll && targetModel.getLocalTranslation().equals(modelPosition)){ |
|
|
|
for (PhysicsBoneLink link : boneLinks.values()) { |
|
|
|
for (PhysicsBoneLink link : boneLinks.values()) { |
|
|
|
|
|
|
|
|
|
|
|
Vector3f position = vars.vect1; |
|
|
|
Vector3f position = vars.vect1; |
|
|
@ -192,12 +193,15 @@ public class KinematicRagdollControl implements PhysicsControl, PhysicsCollision |
|
|
|
|
|
|
|
|
|
|
|
//if the bone is the root bone, we apply the physic's transform to the model, so its position and rotation are correctly updated
|
|
|
|
//if the bone is the root bone, we apply the physic's transform to the model, so its position and rotation are correctly updated
|
|
|
|
if (link.bone.getParent() == null) { |
|
|
|
if (link.bone.getParent() == null) { |
|
|
|
|
|
|
|
|
|
|
|
//offsetting the physic's position/rotation by the root bone inverse model space position/rotaion
|
|
|
|
//offsetting the physic's position/rotation by the root bone inverse model space position/rotaion
|
|
|
|
modelPosition.set(p).subtractLocal(link.bone.getInitialPos()); |
|
|
|
modelPosition.set(p).subtractLocal(link.bone.getInitialPos()); |
|
|
|
modelRotation.set(q).multLocal(tmpRot2.set(link.bone.getInitialRot()).inverseLocal()); |
|
|
|
modelRotation.set(q).multLocal(tmpRot2.set(link.bone.getInitialRot()).inverseLocal()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//applying transforms to the model
|
|
|
|
//applying transforms to the model
|
|
|
|
targetModel.setLocalTranslation(modelPosition); |
|
|
|
targetModel.setLocalTranslation(modelPosition); |
|
|
|
|
|
|
|
|
|
|
|
targetModel.setLocalRotation(modelRotation); |
|
|
|
targetModel.setLocalRotation(modelRotation); |
|
|
|
|
|
|
|
|
|
|
|
//Applying computed transforms to the bone
|
|
|
|
//Applying computed transforms to the bone
|
|
|
@ -249,6 +253,7 @@ public class KinematicRagdollControl implements PhysicsControl, PhysicsCollision |
|
|
|
} |
|
|
|
} |
|
|
|
//setting skeleton transforms to the ragdoll
|
|
|
|
//setting skeleton transforms to the ragdoll
|
|
|
|
matchPhysicObjectToBone(link, position, tmpRot1); |
|
|
|
matchPhysicObjectToBone(link, position, tmpRot1); |
|
|
|
|
|
|
|
modelPosition.set(targetModel.getLocalTranslation()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|