Package com.jme3.bullet.animation
Class PhysicsLink
java.lang.Object
com.jme3.bullet.animation.PhysicsLink
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
- Direct Known Subclasses:
AttachmentLink
,BoneLink
,TorsoLink
public abstract class PhysicsLink
extends Object
implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
The abstract base class used by DynamicAnimControl to link pieces of a JME
model to their corresponding collision objects in a ragdoll. Subclasses
include: AttachmentLink, BoneLink, and TorsoLink. The links in each
DynamicAnimControl form a hierarchy with the TorsoLink at its root.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIKController
(IKController controller) Add an IK controller.protected void
blendToKinematicMode
(float blendInterval) Begin blending this link to a purely kinematic mode.boneName()
Read the name of the corresponding skeleton bone or armature joint.void
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned link into a deep-cloned one, using the specified Cloner and original to resolve copied fields.int
Count this link's immediate children in the link hierarchy.float
density()
Read the average density of the rigid body.void
Disable all IK controllers.protected abstract void
Update this link in Dynamic mode, setting the linked bone's transform based on the transform of the rigid body.abstract void
freeze
(boolean forceKinematic) Immediately freeze this link.final com.jme3.anim.Joint
Access the corresponding armature joint.final com.jme3.animation.Bone
getBone()
Access the corresponding skeleton bone.Access the control that manages this link.getJoint()
Access the joint between this link's rigid body and that of its parent.Access this link's parent/manager in the link hierarchy.final PhysicsRigidBody
Access the linked rigid body.boolean
Test whether the link is in kinematic mode.boolean
Test whether the attached model (if any) has been released.jmeClone()
Create a shallow clone for the JME cloner.protected void
kinematicUpdate
(float tpf) Update this link in blended Kinematic mode.float
Read the kinematic weight of this link.Enumerate this link's immediate children in the link hierarchy.Enumerate inverse-kinematics controllers for this link.protected com.jme3.math.Vector3f
localOffset
(com.jme3.math.Vector3f storeResult) Copy the local offset of this link.abstract String
name()
Unambiguously identify this link by name, within its DynamicAnimControl.com.jme3.math.Transform
physicsTransform
(com.jme3.math.Transform storeResult) Calculate a physics transform for the rigid body (to match the skeleton bone).void
read
(com.jme3.export.JmeImporter importer) De-serialize this link from the specified importer, for example when loading from a J3O file.boolean
removeIKController
(IKController controller) Remove an IK controller.void
setDynamic
(com.jme3.math.Vector3f uniformAcceleration) Immediately put this link into dynamic mode.protected final void
setJoint
(PhysicsJoint joint) Assign a physics joint to this link, or cancel the assigned joint.protected final void
setParent
(PhysicsLink parent) Assign the parent/manager for this link.void
Immediately put this link (and all its controllers) into ragdoll mode.protected void
setRigidBody
(PhysicsRigidBody body) Replace the rigid body for this link.com.jme3.math.Vector3f
velocity
(com.jme3.math.Vector3f storeResult) Copy the body's linear velocity, or an estimate thereof.void
write
(com.jme3.export.JmeExporter exporter) Serialize this link to the specified exporter, for example when saving to a J3O file.
-
Field Details
-
logger
message logger for this class
-
-
Constructor Details
-
PhysicsLink
protected PhysicsLink()No-argument constructor needed by SavableClassUtil.
-
-
Method Details
-
addIKController
Add an IK controller.- Parameters:
controller
- the controller to add (not null, alias created)
-
boneName
Read the name of the corresponding skeleton bone or armature joint.- Returns:
- the bone/joint name (not null)
-
countChildren
public int countChildren()Count this link's immediate children in the link hierarchy.- Returns:
- the count (≥0)
-
density
public float density()Read the average density of the rigid body.- Returns:
- the density (>0)
-
disableAllIKControllers
public void disableAllIKControllers()Disable all IK controllers. -
freeze
public abstract void freeze(boolean forceKinematic) Immediately freeze this link.- Parameters:
forceKinematic
- true→force to kinematic mode, false→preserve mode
-
getArmatureJoint
public final com.jme3.anim.Joint getArmatureJoint()Access the corresponding armature joint.- Returns:
- the pre-existing instance, or null if none
-
getBone
public final com.jme3.animation.Bone getBone()Access the corresponding skeleton bone.- Returns:
- the pre-existing instance, or null if none
-
getControl
Access the control that manages this link.- Returns:
- the pre-existing instance (not null)
-
getJoint
Access the joint between this link's rigid body and that of its parent.- Returns:
- the pre-existing instance, or null for the torso
-
getParent
Access this link's parent/manager in the link hierarchy.- Returns:
- the link, or null if none
-
getRigidBody
Access the linked rigid body.- Returns:
- the pre-existing instance (not null)
-
isKinematic
public boolean isKinematic()Test whether the link is in kinematic mode.- Returns:
- true if kinematic, or false if purely dynamic
-
isReleased
public boolean isReleased()Test whether the attached model (if any) has been released.- Returns:
- false unless this is an AttachmentLink
-
kinematicWeight
public float kinematicWeight()Read the kinematic weight of this link.- Returns:
- 0 if purely dynamic, 1 if purely kinematic
-
listChildren
Enumerate this link's immediate children in the link hierarchy.- Returns:
- a new array (not null)
-
listIKControllers
Enumerate inverse-kinematics controllers for this link.- Returns:
- a new array of pre-existing instances
-
name
Unambiguously identify this link by name, within its DynamicAnimControl.- Returns:
- a text string (not null, not empty)
-
physicsTransform
public com.jme3.math.Transform physicsTransform(com.jme3.math.Transform storeResult) Calculate a physics transform for the rigid body (to match the skeleton bone).- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the calculated transform (in physics-space coordinates, either storeResult or a new transform, not null)
-
removeIKController
Remove an IK controller.- Parameters:
controller
- the controller to remove (not null, unaffected)- Returns:
- true if successful, otherwise false
-
setDynamic
public void setDynamic(com.jme3.math.Vector3f uniformAcceleration) Immediately put this link into dynamic mode. The control must be "ready".- Parameters:
uniformAcceleration
- the uniform acceleration vector to apply (in physics-space coordinates, not null, unaffected)
-
setRagdollMode
public void setRagdollMode()Immediately put this link (and all its controllers) into ragdoll mode. -
velocity
public com.jme3.math.Vector3f velocity(com.jme3.math.Vector3f storeResult) Copy the body's linear velocity, or an estimate thereof.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a new velocity vector (psu/sec in physics-space coordinates)
-
blendToKinematicMode
protected void blendToKinematicMode(float blendInterval) Begin blending this link to a purely kinematic mode.- Parameters:
blendInterval
- the duration of the blend interval (in seconds, ≥0)
-
dynamicUpdate
protected abstract void dynamicUpdate()Update this link in Dynamic mode, setting the linked bone's transform based on the transform of the rigid body. -
kinematicUpdate
protected void kinematicUpdate(float tpf) Update this link in blended Kinematic mode.- Parameters:
tpf
- the time interval between frames (in seconds, ≥0)
-
localOffset
protected com.jme3.math.Vector3f localOffset(com.jme3.math.Vector3f storeResult) Copy the local offset of this link.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the offset (in bone local coordinates, either storeResult or a new vector, not null)
-
setJoint
Assign a physics joint to this link, or cancel the assigned joint.- Parameters:
joint
- (may be null, alias created)
-
setParent
Assign the parent/manager for this link.- Parameters:
parent
- the link to use (not null, alias created)
-
setRigidBody
Replace the rigid body for this link.- Parameters:
body
- the rigid body to use (not null, alias created)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned link into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Parameters:
cloner
- the Cloner that's cloning this link (not null)original
- the instance from which this link was shallow-cloned (unused)
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClone
in interfacecom.jme3.util.clone.JmeCloneable
- Returns:
- a new instance
-
read
De-serialize this link from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
write
Serialize this link to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-