|
|
@ -65,33 +65,29 @@ import java.util.*; |
|
|
|
import java.util.logging.Level; |
|
|
|
import java.util.logging.Level; |
|
|
|
import java.util.logging.Logger; |
|
|
|
import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
|
|
|
/**<strong>This control is still a WIP, use it at your own risk</strong><br> |
|
|
|
/** |
|
|
|
* To use this control you need a model with an AnimControl and a SkeletonControl.<br> |
|
|
|
* <strong>This control is still a WIP, use it at your own risk</strong><br> To |
|
|
|
* This should be the case if you imported an animated model from Ogre or blender.<br> |
|
|
|
* use this control you need a model with an AnimControl and a |
|
|
|
* Note enabling/disabling the control add/removes it from the physic space<br> |
|
|
|
* SkeletonControl.<br> This should be the case if you imported an animated |
|
|
|
* <p> |
|
|
|
* model from Ogre or blender.<br> Note enabling/disabling the control |
|
|
|
* This control creates collision shapes for each bones of the skeleton when you call spatial.addControl(ragdollControl). |
|
|
|
* add/removes it from the physic space<br> <p> This control creates collision |
|
|
|
* <ul> |
|
|
|
* shapes for each bones of the skeleton when you call |
|
|
|
* <li>The shape is HullCollision shape based on the vertices associated with each bone and based on a tweakable weight threshold (see setWeightThreshold)</li> |
|
|
|
* spatial.addControl(ragdollControl). <ul> <li>The shape is HullCollision shape |
|
|
|
* <li>If you don't want each bone to be a collision shape, you can specify what bone to use by using the addBoneName method<br> |
|
|
|
* based on the vertices associated with each bone and based on a tweakable |
|
|
|
* By using this method, bone that are not used to create a shape, are "merged" to their parent to create the collision shape. |
|
|
|
* weight threshold (see setWeightThreshold)</li> <li>If you don't want each |
|
|
|
* </li> |
|
|
|
* bone to be a collision shape, you can specify what bone to use by using the |
|
|
|
* </ul> |
|
|
|
* addBoneName method<br> By using this method, bone that are not used to create |
|
|
|
*</p> |
|
|
|
* a shape, are "merged" to their parent to create the collision shape. </li> |
|
|
|
*<p> |
|
|
|
* </ul> </p> <p> There are 2 modes for this control : <ul> <li><strong>The |
|
|
|
*There are 2 modes for this control : |
|
|
|
* kinematic modes :</strong><br> this is the default behavior, this means that |
|
|
|
* <ul> |
|
|
|
* the collision shapes of the body are able to interact with physics enabled |
|
|
|
* <li><strong>The kinematic modes :</strong><br> |
|
|
|
* objects. in this mode physic shapes follow the moovements of the animated |
|
|
|
* this is the default behavior, this means that the collision shapes of the body are able to interact with physics enabled objects. |
|
|
|
* skeleton (for example animated by a key framed animation) this mode is |
|
|
|
* in this mode physic shapes follow the moovements of the animated skeleton (for example animated by a key framed animation) |
|
|
|
* enabled by calling setKinematicMode(); </li> <li><strong>The ragdoll modes |
|
|
|
* this mode is enabled by calling setKinematicMode(); |
|
|
|
* :</strong><br> To enable this behavior, you need to call setRagdollMode() |
|
|
|
* </li> |
|
|
|
* method. In this mode the charater is entirely controled by physics, so it |
|
|
|
* <li><strong>The ragdoll modes :</strong><br> |
|
|
|
* will fall under the gravity and move if any force is applied to it. </li> |
|
|
|
* To enable this behavior, you need to call setRagdollMode() method. |
|
|
|
* </ul> </p> |
|
|
|
* In this mode the charater is entirely controled by physics, so it will fall under the gravity and move if any force is applied to it. |
|
|
|
|
|
|
|
* </li> |
|
|
|
|
|
|
|
* </ul> |
|
|
|
|
|
|
|
*</p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @author Normen Hansen and Rémy Bouquet (Nehon) |
|
|
|
* @author Normen Hansen and Rémy Bouquet (Nehon) |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -334,20 +330,15 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P |
|
|
|
* after it's been initialized, same as reattaching. |
|
|
|
* after it's been initialized, same as reattaching. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void reBuild() { |
|
|
|
public void reBuild() { |
|
|
|
if (added) { |
|
|
|
if (spatial == null) { |
|
|
|
removePhysics(space); |
|
|
|
return; |
|
|
|
setSpatial(targetModel); |
|
|
|
|
|
|
|
addPhysics(space); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setSpatial(targetModel); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
removeSpatialData(spatial); |
|
|
|
|
|
|
|
createSpatialData(spatial); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void createSpatialData(Spatial model) { |
|
|
|
protected void createSpatialData(Spatial model) { |
|
|
|
if (added) { |
|
|
|
|
|
|
|
removePhysics(space); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
targetModel = model; |
|
|
|
targetModel = model; |
|
|
|
Node parent = model.getParent(); |
|
|
|
Node parent = model.getParent(); |
|
|
|
|
|
|
|
|
|
|
@ -390,7 +381,6 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P |
|
|
|
protected void removeSpatialData(Spatial spat) { |
|
|
|
protected void removeSpatialData(Spatial spat) { |
|
|
|
if (added) { |
|
|
|
if (added) { |
|
|
|
removePhysics(space); |
|
|
|
removePhysics(space); |
|
|
|
added = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
boneLinks.clear(); |
|
|
|
boneLinks.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|