Class DynamicAnimControl
- All Implemented Interfaces:
PhysicsCollisionListener
,PhysicsControl
,PhysicsTickListener
,Savable
,Control
,JmeCloneable
,Cloneable
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.
-
Field Summary
Fields inherited from class com.jme3.bullet.animation.DacConfiguration
logger2, torsoName
Fields inherited from class com.jme3.bullet.control.AbstractPhysicsControl
added, applyLocal, enabled, space, spatial
-
Constructor Summary
ConstructorDescriptionInstantiate an enabled control without any linked bones (torso only). -
Method Summary
Modifier and TypeMethodDescriptionvoid
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, Object original) Callback fromCloner
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.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
Immediately put all links into purely kinematic mode.void
Immediately put this control into ragdoll mode.void
write
(JmeExporter ex) Serialize this control, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.animation.DacLinks
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
Methods inherited from class com.jme3.bullet.animation.DacConfiguration
addUnlinkedDescendants, countLinkedBones, countLinks, damping, eventDispatchImpulseThreshold, findManager, getJointLimits, gravity, hasBoneLink, link, listLinkedBoneNames, managerMap, render, setApplyPhysicsLocal, setEventDispatchImpulseThreshold, totalMass, unlinkBone
Methods inherited from class com.jme3.bullet.control.AbstractPhysicsControl
applyPhysicsTransform, cloneForSpatial, getPhysicsSpace, getSpatial, getSpatialRotation, getSpatialTranslation, isApplyPhysicsLocal, isEnabled, setEnabled, setPhysicsSpace, setSpatial
-
Field Details
-
logger35
message logger for this class
-
-
Constructor Details
-
DynamicAnimControl
public DynamicAnimControl()Instantiate an enabled control without any linked bones (torso only).
-
-
Method Details
-
addCollisionListener
Add a collision listener to this control.- Parameters:
listener
- (not null, alias created)
-
animateSubtree
Begin blending the specified link and all its descendants to kinematic animation.- Parameters:
rootLink
- the root of the subtree to bind (not null)blendInterval
- the duration of the blend interval (in seconds, ≥0)
-
blendToKinematicMode
Begin blending all links to purely kinematic mode, driven by animation. TODO callback when the transition completesAllowed only when the control IS added to a spatial.
- Parameters:
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)
-
centerOfMass
Calculate the ragdoll's total mass and center of mass.Allowed only when the control IS added to a spatial.
- Parameters:
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)- Returns:
- the total mass (>0)
-
setContactResponseSubtree
Alter the contact-response setting of the specified link and all its descendants. Note: recursive!Allowed only when the control IS added to a spatial.
- Parameters:
rootLink
- the root of the subtree to modify (not null)desiredResponse
- true for the usual rigid-body response, false for ghost-like response
-
setDynamicChain
Immediately put the specified link and all its ancestors (excluding the torso) into dynamic mode. Note: recursive!Allowed only when the control IS added to a spatial.
- Parameters:
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)
-
setDynamicSubtree
Immediately put the specified link and all its descendants into dynamic mode. Note: recursive!Allowed only when the control IS added to a spatial.
- Parameters:
rootLink
- the root of the subtree to modify (not null)uniformAcceleration
- the uniform acceleration vector (in physics-space coordinates, not null, unaffected)
-
setKinematicMode
public void setKinematicMode()Immediately put all links into purely kinematic mode.Allowed only when the control IS added to a spatial.
-
setRagdollMode
public void setRagdollMode()Immediately put this control into ragdoll mode.Allowed only when the control IS added to a spatial and all links are "ready".
-
addPhysics
Add all managed physics objects to the PhysicsSpace.- Overrides:
addPhysics
in classDacLinks
- Parameters:
space
- which physics space to add to (not null)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned control into a deep-cloned one, using the specified cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfaceJmeCloneable
- Overrides:
cloneFields
in classDacLinks
- Parameters:
cloner
- the cloner that's cloning this control (not null, modified)original
- the control from which this control was shallow-cloned (not null, unaffected)
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClone
in interfaceJmeCloneable
- Overrides:
jmeClone
in classDacLinks
- Returns:
- a new instance
-
read
De-serialize this control, for example when loading from a J3O file.- Specified by:
read
in interfaceSavable
- Overrides:
read
in classDacLinks
- Parameters:
im
- the importer (not null)- Throws:
IOException
- from the importer
-
removePhysics
Remove all managed physics objects from the PhysicsSpace.- Overrides:
removePhysics
in classDacLinks
- Parameters:
space
- which physics space to remove from (not null)
-
write
Serialize this control, for example when saving to a J3O file.- Specified by:
write
in interfaceSavable
- Overrides:
write
in classDacLinks
- Parameters:
ex
- the exporter (not null)- Throws:
IOException
- from the exporter
-
collision
For internal use only: callback for collision events.- Specified by:
collision
in interfacePhysicsCollisionListener
- Parameters:
event
- (not null)
-