Package com.jme3.bullet.animation
Class DacLinks
java.lang.Object
com.jme3.bullet.control.AbstractPhysicsControl
com.jme3.bullet.animation.DacConfiguration
com.jme3.bullet.animation.DacLinks
- All Implemented Interfaces:
PhysicsControl
,PhysicsTickListener
,com.jme3.export.Savable
,com.jme3.scene.control.Control
,com.jme3.util.clone.JmeCloneable
,Cloneable
- Direct Known Subclasses:
DynamicAnimControl
Access a DynamicAnimControl at the PhysicsLink level once it's been added to
a Spatial.
-
Field Summary
Fields inherited from class com.jme3.bullet.animation.DacConfiguration
logger2, torsoName
Fields inherited from class com.jme3.bullet.control.AbstractPhysicsControl
added, logger
-
Constructor Summary
ModifierConstructorDescriptionprotected
DacLinks()
Instantiate an enabled control without any linked bones or attachments (torso only). -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Add all managed physics objects to the PhysicsSpace.float
attachmentMass
(String boneName) Return the mass of the attachment associated with the named bone.void
cloneFields
(com.jme3.util.clone.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.protected void
createSpatialData
(com.jme3.scene.Spatial spatial) Create spatial-dependent data.com.jme3.anim.Joint
findArmatureJoint
(String jointName) Access the named armature joint.findAttachmentLink
(String boneName) Access the AttachmentLink for the named bone.com.jme3.animation.Bone
Access the named Bone.findBoneLink
(String boneName) Access the BoneLink for the named bone.Access the named link.com.jme3.anim.Armature
Access the Armature.Access the list of bone links in a pre-order, depth-first traversal of the link hierarchy.com.jme3.animation.Skeleton
Access the Skeleton.Access the TorsoLink.com.jme3.scene.Spatial
Access the Spatial with the mesh-coordinate transform.boolean
isReady()
Test whether this control is ready for dynamic mode.protected Collection<AttachmentLink>
Enumerate attachment links.<T extends PhysicsLink>
List<T>Enumerate physics links of the specified type managed by this control.Enumerate all rigid bodies managed by this control.float
Return the mass of the named bone/torso.void
physicsTick
(PhysicsSpace space, float timeStep) Callback from Bullet, invoked just after the physics has been stepped.void
prePhysicsTick
(PhysicsSpace space, float timeStep) Callback from Bullet, invoked just before the physics is stepped.void
read
(com.jme3.export.JmeImporter importer) De-serialize this Control from the specified importer, for example when loading from a J3O file.void
rebuild()
Rebuild the ragdoll.protected void
Remove all managed physics objects from the PhysicsSpace.protected void
removeSpatialData
(com.jme3.scene.Spatial spatial) Remove spatial-dependent data.void
setAttachmentConfig
(String boneName, LinkConfig config) Alter the configuration of the attachment associated with the named bone.void
setAttachmentMass
(String boneName, float mass) Alter the mass of the attachment associated with the named bone.void
setDamping
(float dampingRatio) Alter the viscous damping ratio for all rigid bodies, including new ones.void
setGravity
(com.jme3.math.Vector3f gravity) Alter this control's gravitational acceleration for Ragdoll mode.void
setJointLimits
(String boneName, RangeOfMotion rom) Alter the range of motion of the joint connecting the named BoneLink to its parent in the link hierarchy.void
setMainBoneName
(String boneName) Specify the main bone.void
setMass
(PhysicsLink link, float mass) Alter the mass of the specified link.void
Alter the mass of the named bone/torso.protected void
setPhysicsLocation
(com.jme3.math.Vector3f vec) Translate the torso to the specified location.protected void
setPhysicsRotation
(com.jme3.math.Quaternion quat) Rotate the torso to the specified orientation.float
Return the ragdoll's total mass, including attachments.void
update
(float tpf) Update this Control.protected void
verifyAddedToSpatial
(String desiredAction) Verify that this control is added to a Spatial.void
verifyReadyForDynamicMode
(String desiredAction) Verify that this control is ready for dynamic mode, which implies that it is added to a Spatial, added to a PhysicsSpace, and the physics has been stepped.void
write
(com.jme3.export.JmeExporter exporter) Serialize this Control to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.animation.DacConfiguration
addUnlinkedDescendants, addUnlinkedDescendants, attach, attach, attachmentConfig, config, countAttachments, countLinkedBones, countLinks, damping, detach, eventDispatchImpulseThreshold, findManager, findManager, getAttachmentModel, getJointLimits, gravity, hasAttachmentLink, hasBoneLink, ignoredHops, link, link, listAttachmentBoneNames, listLinkedBoneNames, mainBoneName, managerMap, managerMap, relativeTolerance, setApplyPhysicsLocal, setConfig, setEventDispatchImpulseThreshold, setIgnoredHops, setRelativeTolerance, unlinkBone
Methods inherited from class com.jme3.bullet.control.AbstractPhysicsControl
applyPhysicsTransform, cloneForSpatial, getPhysicsSpace, getSpatial, getSpatialRotation, getSpatialTranslation, isApplyPhysicsLocal, isEnabled, jmeClone, render, setEnabled, setPhysicsSpace, setSpatial
-
Field Details
-
logger3
message logger for this class
-
-
Constructor Details
-
DacLinks
protected DacLinks()Instantiate an enabled control without any linked bones or attachments (torso only).
-
-
Method Details
-
findArmatureJoint
Access the named armature joint.Allowed only when the Control IS added to a Spatial.
- Parameters:
jointName
- the name of the armature joint to access- Returns:
- the pre-existing instance, or null if not found
-
findAttachmentLink
Access the AttachmentLink for the named bone. Returns null if the bone is not associated with an attachment, or if the control is not added to a Spatial.- Parameters:
boneName
- the name of the bone (not null, not empty)- Returns:
- the pre-existing link, or null if not found
-
findBone
Access the named Bone.Allowed only when the Control IS added to a Spatial.
- Parameters:
boneName
- the name of the skeleton bone to access- Returns:
- the pre-existing instance, or null if not found
-
findBoneLink
Access the BoneLink for the named bone. Returns null if bone is not linked, or if the control is not added to a Spatial.- Parameters:
boneName
- the name of the bone (not null, not empty)- Returns:
- the pre-existing BoneLink, or null if not found
-
findLink
Access the named link. Returns null if the name is invalid, or if the control is not added to a Spatial.- Parameters:
linkName
- the name of the link (not null, not empty)- Returns:
- the pre-existing link, or null if not found
-
getArmature
public com.jme3.anim.Armature getArmature()Access the Armature. Returns null if the Control is not added to a Spatial.- Returns:
- the pre-existing Armature, or null
-
getSkeleton
public com.jme3.animation.Skeleton getSkeleton()Access the Skeleton. Returns null if the Control is not added to a Spatial.- Returns:
- the pre-existing Skeleton, or null
-
getTorsoLink
Access the TorsoLink. Returns null if the control is not added to a Spatial.- Returns:
- the pre-existing TorsoLink, or null
-
getTransformer
public com.jme3.scene.Spatial getTransformer()Access the Spatial with the mesh-coordinate transform. Returns null if the control is not added to a Spatial.- Returns:
- the pre-existing spatial, or null
-
isReady
public boolean isReady()Test whether this control is ready for dynamic mode.- Returns:
- true if ready, otherwise false
-
listLinks
Enumerate physics links of the specified type managed by this control.- Type Parameters:
T
- subclass of PhysicsLink- Parameters:
linkType
- the subclass of PhysicsLink to search for (not null)- Returns:
- a new array of links (not null, not empty)
-
listRigidBodies
Enumerate all rigid bodies managed by this control.Allowed only when the control IS added to a Spatial.
- Returns:
- a new array of pre-existing rigid bodies (not null, not empty)
-
rebuild
public void rebuild()Rebuild the ragdoll. This is useful if you applied scale to the model after it was initialized.Allowed only when the control IS added to a Spatial.
-
setMass
Alter the mass of the specified link.- Parameters:
link
- the link to modify (not null)mass
- the desired mass (>0)
-
verifyReadyForDynamicMode
Verify that this control is ready for dynamic mode, which implies that it is added to a Spatial, added to a PhysicsSpace, and the physics has been stepped.- Parameters:
desiredAction
- (not null, not empty)
-
getBoneLinks
Access the list of bone links in a pre-order, depth-first traversal of the link hierarchy.- Returns:
- the pre-existing list (not null)
-
listAttachmentLinks
Enumerate attachment links.- Returns:
- a collection view of values in the internal map (not null)
-
verifyAddedToSpatial
Verify that this control is added to a Spatial.- Parameters:
desiredAction
- (not null, not empty)
-
addPhysics
protected void addPhysics()Add all managed physics objects to the PhysicsSpace.- Specified by:
addPhysics
in classAbstractPhysicsControl
-
attachmentMass
Return the mass of the attachment associated with the named bone.- Overrides:
attachmentMass
in classDacConfiguration
- Parameters:
boneName
- the name of the associated bone (not null, not empty)- Returns:
- the mass (in physics units, >0) or NaN if undetermined
-
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 interfacecom.jme3.util.clone.JmeCloneable
- Overrides:
cloneFields
in classDacConfiguration
- Parameters:
cloner
- the Cloner that's cloning this Control (not null, modified)original
- the instance from which this Control was shallow-cloned (not null, unaffected)
-
createSpatialData
protected void createSpatialData(com.jme3.scene.Spatial spatial) Create spatial-dependent data. Invoked each time the Control is added to a Spatial. Also invoked byrebuild()
.- Specified by:
createSpatialData
in classAbstractPhysicsControl
- Parameters:
spatial
- the controlled spatial (not null)
-
mass
Return the mass of the named bone/torso.- Overrides:
mass
in classDacConfiguration
- Parameters:
boneName
- the name of the bone/torso (not null)- Returns:
- the mass (>0) or NaN if undetermined
-
read
De-serialize this Control from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classDacConfiguration
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
removePhysics
protected void removePhysics()Remove all managed physics objects from the PhysicsSpace.- Specified by:
removePhysics
in classAbstractPhysicsControl
-
removeSpatialData
protected void removeSpatialData(com.jme3.scene.Spatial spatial) Remove spatial-dependent data. Invoked each time this control is rebuilt or removed from a Spatial.- Specified by:
removeSpatialData
in classAbstractPhysicsControl
- Parameters:
spatial
- the Spatial to which this Control was added (unused)
-
setAttachmentConfig
Alter the configuration of the attachment associated with the named bone.- Overrides:
setAttachmentConfig
in classDacConfiguration
- Parameters:
boneName
- the name of the associated bone (not null, not empty)config
- the desired configuration (not null)
-
setAttachmentMass
Alter the mass of the attachment associated with the named bone.- Overrides:
setAttachmentMass
in classDacConfiguration
- Parameters:
boneName
- the name of the associated bone (not null, not empty)mass
- the desired mass (>0)
-
setDamping
public void setDamping(float dampingRatio) Alter the viscous damping ratio for all rigid bodies, including new ones.- Overrides:
setDamping
in classDacConfiguration
- Parameters:
dampingRatio
- the desired damping ratio (non-negative, 0→no damping, 1→critically damped, default=0.6)
-
setGravity
public void setGravity(com.jme3.math.Vector3f gravity) Alter this control's gravitational acceleration for Ragdoll mode.- Overrides:
setGravity
in classDacConfiguration
- Parameters:
gravity
- the desired acceleration vector (in physics-space coordinates, not null, unaffected, default=(0,-9.8,0))
-
setJointLimits
Alter the range of motion of the joint connecting the named BoneLink to its parent in the link hierarchy.- Overrides:
setJointLimits
in classDacConfiguration
- Parameters:
boneName
- the name of the BoneLink (not null, not empty)rom
- the desired range of motion (not null)
-
setMainBoneName
Specify the main bone.- Overrides:
setMainBoneName
in classDacConfiguration
- Parameters:
boneName
- the name of the desired bone, or null to determine the main bone heuristically when the control is added to a spatial
-
setMass
Alter the mass of the named bone/torso.- Overrides:
setMass
in classDacConfiguration
- Parameters:
boneName
- the name of the bone, or torsoName (not null)mass
- the desired mass (>0)
-
setPhysicsLocation
protected void setPhysicsLocation(com.jme3.math.Vector3f vec) Translate the torso to the specified location.- Specified by:
setPhysicsLocation
in classAbstractPhysicsControl
- Parameters:
vec
- desired location (not null, finite, unaffected)
-
setPhysicsRotation
protected void setPhysicsRotation(com.jme3.math.Quaternion quat) Rotate the torso to the specified orientation.- Specified by:
setPhysicsRotation
in classAbstractPhysicsControl
- Parameters:
quat
- desired orientation (not null, not zero, unaffected)
-
totalMass
public float totalMass()Return the ragdoll's total mass, including attachments.- Overrides:
totalMass
in classDacConfiguration
- Returns:
- the total mass (>0) or NaN if undetermined
-
update
public void update(float tpf) Update this Control. Invoked once per frame during the logical-state update, provided the control is added to a scene. Do not invoke directly from user code.- Specified by:
update
in interfacecom.jme3.scene.control.Control
- Parameters:
tpf
- the time interval between frames (in seconds, ≥0)
-
write
Serialize this Control to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classDacConfiguration
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-
physicsTick
Callback from Bullet, invoked just after the physics has been stepped. Used to re-activate any deactivated rigid bodies.- Specified by:
physicsTick
in interfacePhysicsTickListener
- Parameters:
space
- the space that was just stepped (not null)timeStep
- the duration of the simulation step (in seconds, ≥0)
-
prePhysicsTick
Callback from Bullet, invoked just before the physics is stepped. A good time to clear/apply forces.- Specified by:
prePhysicsTick
in interfacePhysicsTickListener
- Parameters:
space
- the space that is about to be stepped (not null)timeStep
- the duration of the simulation step (in seconds, ≥0)
-