public class DynamicAnimControl extends DacLinks implements PhysicsCollisionListener
DacConfiguration.link(java.lang.String, float, com.jme3.bullet.animation.RangeOfMotion)
for each bone that should have its own rigid body. Leave unlinked bones near
the root of the skeleton to form the torso of the ragdoll.
When you add the control to a spatial, it generates a ragdoll consisting of a rigid body for the torso and another for each linked bone. It also creates a SixDofJoint connecting each rigid body to its parent in the link hierarchy. The mass of each rigid body and the range-of-motion of each joint can be reconfigured on the fly.
Each link is either dynamic (driven by forces and torques) or kinematic (unperturbed by forces and torques). Transitions from dynamic to kinematic can be immediate or gradual.
This class is shared between JBullet and Native Bullet.
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Logger |
logger35
message logger for this class
|
logger2, torsoName
added, applyLocal, enabled, space, spatial
Constructor and Description |
---|
DynamicAnimControl()
Instantiate an enabled control without any linked bones (torso only).
|
Modifier and Type | Method and Description |
---|---|
void |
addCollisionListener(RagdollCollisionListener listener)
Add a collision listener to this control.
|
protected void |
addPhysics(PhysicsSpace space)
Add all managed physics objects to the PhysicsSpace.
|
void |
animateSubtree(PhysicsLink rootLink,
float blendInterval)
Begin blending the specified link and all its descendants to kinematic
animation.
|
void |
blendToKinematicMode(float blendInterval,
Transform endModelTransform)
Begin blending all links to purely kinematic mode, driven by animation.
|
float |
centerOfMass(Vector3f storeLocation,
Vector3f storeVelocity)
Calculate the ragdoll's total mass and center of mass.
|
void |
cloneFields(Cloner cloner,
java.lang.Object original)
Callback from
Cloner to convert this
shallow-cloned control into a deep-cloned one, using the specified cloner
and original to resolve copied fields. |
void |
collision(PhysicsCollisionEvent event)
For internal use only: callback for collision events.
|
DynamicAnimControl |
jmeClone()
Create a shallow clone for the JME cloner.
|
void |
read(JmeImporter im)
De-serialize this control, for example when loading from a J3O file.
|
protected void |
removePhysics(PhysicsSpace space)
Remove all managed physics objects from the PhysicsSpace.
|
void |
setContactResponseSubtree(PhysicsLink rootLink,
boolean desiredResponse)
Alter the contact-response setting of the specified link and all its
descendants.
|
void |
setDynamicChain(PhysicsLink startLink,
int chainLength,
Vector3f uniformAcceleration)
Immediately put the specified link and all its ancestors (excluding the
torso) into dynamic mode.
|
void |
setDynamicSubtree(PhysicsLink rootLink,
Vector3f uniformAcceleration)
Immediately put the specified link and all its descendants into dynamic
mode.
|
void |
setKinematicMode()
Immediately put all links into purely kinematic mode.
|
void |
setRagdollMode()
Immediately put this control into ragdoll mode.
|
void |
write(JmeExporter ex)
Serialize this control, for example when saving to a J3O file.
|
createSpatialData, findBone, findBoneLink, findLink, getBoneLinks, getSkeleton, getTorsoLink, isReady, listLinks, listRigidBodies, mass, physicsTick, prePhysicsTick, rebuild, removeSpatialData, setDamping, setGravity, setJointLimits, setMass, setMass, setPhysicsLocation, setPhysicsRotation, update, verifyAddedToSpatial, verifyReadyForDynamicMode
addUnlinkedDescendants, countLinkedBones, countLinks, damping, eventDispatchImpulseThreshold, findManager, getJointLimits, gravity, hasBoneLink, link, listLinkedBoneNames, managerMap, render, setApplyPhysicsLocal, setEventDispatchImpulseThreshold, totalMass, unlinkBone
applyPhysicsTransform, cloneForSpatial, getPhysicsSpace, getSpatial, getSpatialRotation, getSpatialTranslation, isApplyPhysicsLocal, isEnabled, setEnabled, setPhysicsSpace, setSpatial
public static final java.util.logging.Logger logger35
public DynamicAnimControl()
public void addCollisionListener(RagdollCollisionListener listener)
listener
- (not null, alias created)public void animateSubtree(PhysicsLink rootLink, float blendInterval)
rootLink
- the root of the subtree to bind (not null)blendInterval
- the duration of the blend interval (in seconds,
≥0)public void blendToKinematicMode(float blendInterval, Transform endModelTransform)
Allowed only when the control IS added to a spatial.
blendInterval
- the duration of the blend interval (in seconds,
≥0)endModelTransform
- the desired local transform for the controlled
spatial when the transition completes or null for no change to local
transform (unaffected)public float centerOfMass(Vector3f storeLocation, Vector3f storeVelocity)
Allowed only when the control IS added to a spatial.
storeLocation
- storage for the location of the center (in
physics-space coordinates, modified if not null)storeVelocity
- storage for the velocity of the center (psu/second
in physics-space coordinates, modified if not null)public void setContactResponseSubtree(PhysicsLink rootLink, boolean desiredResponse)
Allowed only when the control IS added to a spatial.
rootLink
- the root of the subtree to modify (not null)desiredResponse
- true for the usual rigid-body response, false for
ghost-like responsepublic void setDynamicChain(PhysicsLink startLink, int chainLength, Vector3f uniformAcceleration)
Allowed only when the control IS added to a spatial.
startLink
- the start of the chain to modify (not null)chainLength
- the maximum number of links to modify (≥0)uniformAcceleration
- the uniform acceleration vector (in
physics-space coordinates, not null, unaffected)public void setDynamicSubtree(PhysicsLink rootLink, Vector3f uniformAcceleration)
Allowed only when the control IS added to a spatial.
rootLink
- the root of the subtree to modify (not null)uniformAcceleration
- the uniform acceleration vector (in
physics-space coordinates, not null, unaffected)public void setKinematicMode()
Allowed only when the control IS added to a spatial.
public void setRagdollMode()
Allowed only when the control IS added to a spatial and all links are "ready".
protected void addPhysics(PhysicsSpace space)
addPhysics
in class DacLinks
space
- which physics space to add to (not null)public void cloneFields(Cloner cloner, java.lang.Object original)
Cloner
to convert this
shallow-cloned control into a deep-cloned one, using the specified cloner
and original to resolve copied fields.cloneFields
in interface JmeCloneable
cloneFields
in class DacLinks
cloner
- the cloner that's cloning this control (not null, modified)original
- the control from which this control was shallow-cloned
(not null, unaffected)public DynamicAnimControl jmeClone()
jmeClone
in interface JmeCloneable
jmeClone
in class DacLinks
public void read(JmeImporter im) throws java.io.IOException
protected void removePhysics(PhysicsSpace space)
removePhysics
in class DacLinks
space
- which physics space to remove from (not null)public void write(JmeExporter ex) throws java.io.IOException
public void collision(PhysicsCollisionEvent event)
collision
in interface PhysicsCollisionListener
event
- (not null)