Package com.jme3.bullet
Class MultiBodyLink
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.MultiBodyLink
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
public class MultiBodyLink
extends NativePhysicsObject
implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
A single link in a MultiBody, based on Bullet's
btMultibodyLink
.-
Field Summary
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil. -
Method Summary
Modifier and TypeMethodDescriptionaddCollider
(CollisionShape shape) Add a collider for this link.void
addConstraintForce
(com.jme3.math.Vector3f force) Add an external force to this link.void
addConstraintTorque
(com.jme3.math.Vector3f torque) Add an external torque to this link.void
addForce
(com.jme3.math.Vector3f force) Add an external force to this link.void
addJointTorque
(int dofIndex, float torque) Add an external torque to this link's joint.void
addTorque
(com.jme3.math.Vector3f torque) Add an external torque to this link.com.jme3.math.Vector3f
appliedForce
(com.jme3.math.Vector3f storeResult) Determine the net applied force on this link.com.jme3.math.Vector3f
appliedTorque
(com.jme3.math.Vector3f storeResult) Determine the net applied torque on this link.com.jme3.math.Vector3f
axis
(com.jme3.math.Vector3f storeResult) Determine the direction of the joint's axis for a planar, prismatic, or revolute joint.void
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned object into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3f
constraintForce
(com.jme3.math.Vector3f storeResult) Determine the net constraint force on this link.com.jme3.math.Vector3f
constraintTorque
(com.jme3.math.Vector3f storeResult) Determine the net constraint torque on this link.int
Count the degrees of freedom in the joint.int
Count the position variables in the joint.Access the collider for this link.Access the MultiBody that contains this link.Determine the parent of this link.int
index()
Determine the index of this link in its MultiBody.com.jme3.math.Vector3f
inertia
(com.jme3.math.Vector3f storeResult) Determine the rotational inertia of this link.boolean
Test whether collisions with the immediate parent link are enabled.jmeClone()
Create a shallow clone for the JME cloner.float
jointPosition
(int dofIndex) Determine the position of the indexed DOF.float
jointTorque
(int dofIndex) Determine the torque applied to the indexed DOF usingaddJointTorque(int, float)
, which is zeroed after each simulation step.Determine the type of joint between this link and its parent.float
jointVelocity
(int dofIndex) Determine the velocity of the indexed DOF.com.jme3.math.Vector3f
location
(com.jme3.math.Vector3f storeResult) Determine the location of this link's center of mass.float
mass()
Determine the mass of this link.com.jme3.math.Quaternion
orientation
(com.jme3.math.Quaternion storeResult) Determine the orientation of the link relative to its parent when Q=0.com.jme3.math.Vector3f
parent2Link
(com.jme3.math.Vector3f storeResult) Determine the offset of the link's center relative to its parent's center for a planar joint.com.jme3.math.Vector3f
parent2Pivot
(com.jme3.math.Vector3f storeResult) Determine the offset from the parent's center to the pivot for a non-planar joint.com.jme3.math.Vector3f
pivot2Link
(com.jme3.math.Vector3f storeResult) Determine the offset from the pivot to this link's center for a non-planar joint.void
read
(com.jme3.export.JmeImporter importer) De-serialize this object from the specified importer, for example when loading from a J3O file.void
setJointPosition
(int dofIndex, float position) Alter the position of the indexed DOF.void
setJointVelocity
(int dofIndex, float velocity) Alter the velocity of the indexed DOF.com.jme3.math.Transform
worldTransform
(com.jme3.math.Transform storeResult) Determine the transform of this link.void
write
(com.jme3.export.JmeExporter exporter) Serialize this object to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, toString, unassignNativeObject
-
Field Details
-
logger
message logger for this class
-
-
Constructor Details
-
MultiBodyLink
protected MultiBodyLink()No-argument constructor needed by SavableClassUtil.
-
-
Method Details
-
addCollider
Add a collider for this link.- Parameters:
shape
- (not null, alias created)- Returns:
- a new collider
-
addConstraintForce
public void addConstraintForce(com.jme3.math.Vector3f force) Add an external force to this link.- Parameters:
force
- the force to add (in physics-space coordinates, not null, unaffected)
-
addConstraintTorque
public void addConstraintTorque(com.jme3.math.Vector3f torque) Add an external torque to this link.- Parameters:
torque
- the torque to add (in physics-space coordinates, not null, unaffected)
-
addForce
public void addForce(com.jme3.math.Vector3f force) Add an external force to this link.- Parameters:
force
- the force to add (in physics-space coordinates, not null, unaffected)
-
addJointTorque
public void addJointTorque(int dofIndex, float torque) Add an external torque to this link's joint.- Parameters:
dofIndex
- which degree of freedom (≥0, <numDofs)torque
- the torque to add
-
addTorque
public void addTorque(com.jme3.math.Vector3f torque) Add an external torque to this link.- Parameters:
torque
- the torque to add (in physics-space coordinates, not null, unaffected)
-
appliedForce
public com.jme3.math.Vector3f appliedForce(com.jme3.math.Vector3f storeResult) Determine the net applied force on this link.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the force vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
appliedTorque
public com.jme3.math.Vector3f appliedTorque(com.jme3.math.Vector3f storeResult) Determine the net applied torque on this link.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the torque vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
axis
public com.jme3.math.Vector3f axis(com.jme3.math.Vector3f storeResult) Determine the direction of the joint's axis for a planar, prismatic, or revolute joint.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the direction (a unit vector, either storeResult or a new vector)
-
constraintForce
public com.jme3.math.Vector3f constraintForce(com.jme3.math.Vector3f storeResult) Determine the net constraint force on this link.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the force vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
constraintTorque
public com.jme3.math.Vector3f constraintTorque(com.jme3.math.Vector3f storeResult) Determine the net constraint torque on this link.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the torque vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
countDofs
public int countDofs()Count the degrees of freedom in the joint.- Returns:
- the count (≥0)
-
countPositionVariables
public int countPositionVariables()Count the position variables in the joint.- Returns:
- the count (≥0)
-
getCollider
Access the collider for this link.- Returns:
- the pre-existing instance, or null if none
-
getMultiBody
Access the MultiBody that contains this link.- Returns:
- the pre-existing instance (not null)
-
getParentLink
Determine the parent of this link.- Returns:
- the pre-existing instance, or null if this link's parent is the base
-
index
public int index()Determine the index of this link in its MultiBody.- Returns:
- the index (≥0)
-
inertia
public com.jme3.math.Vector3f inertia(com.jme3.math.Vector3f storeResult) Determine the rotational inertia of this link.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the principal (diagonal) components of the inertia tensor (in the link's local coordinates, either storeResult or a new vector, not null)
-
isCollisionWithParent
public boolean isCollisionWithParent()Test whether collisions with the immediate parent link are enabled.- Returns:
- true if collisions are enabled, otherwise false
-
jointPosition
public float jointPosition(int dofIndex) Determine the position of the indexed DOF.- Parameters:
dofIndex
- which degree of freedom (≥0, <numDofs)- Returns:
- the position
-
jointTorque
public float jointTorque(int dofIndex) Determine the torque applied to the indexed DOF usingaddJointTorque(int, float)
, which is zeroed after each simulation step.- Parameters:
dofIndex
- which degree of freedom (≥0, <numDofs)- Returns:
- the torque
-
jointType
Determine the type of joint between this link and its parent.- Returns:
- an enum value (not null)
-
jointVelocity
public float jointVelocity(int dofIndex) Determine the velocity of the indexed DOF.- Parameters:
dofIndex
- which degree of freedom (≥0, <numDofs)- Returns:
- the velocity
-
location
public com.jme3.math.Vector3f location(com.jme3.math.Vector3f storeResult) Determine the location of this link's center of mass.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the location vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
mass
public float mass()Determine the mass of this link.- Returns:
- the mass (in physics-space units, >0)
-
orientation
public com.jme3.math.Quaternion orientation(com.jme3.math.Quaternion storeResult) Determine the orientation of the link relative to its parent when Q=0.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the orientation (either storeResult or a new Quaternion)
-
parent2Link
public com.jme3.math.Vector3f parent2Link(com.jme3.math.Vector3f storeResult) Determine the offset of the link's center relative to its parent's center for a planar joint.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the offset (in this link's coordinate system, either storeResult or a new vector)
-
parent2Pivot
public com.jme3.math.Vector3f parent2Pivot(com.jme3.math.Vector3f storeResult) Determine the offset from the parent's center to the pivot for a non-planar joint.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the offset (in the parent's coordinate system, either storeResult or a new vector)
-
pivot2Link
public com.jme3.math.Vector3f pivot2Link(com.jme3.math.Vector3f storeResult) Determine the offset from the pivot to this link's center for a non-planar joint.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the offset (in this link's coordinate system, either storeResult or a new vector)
-
setJointPosition
public void setJointPosition(int dofIndex, float position) Alter the position of the indexed DOF.- Parameters:
dofIndex
- which degree of freedom (≥0, <numDofs)position
- the desired position
-
setJointVelocity
public void setJointVelocity(int dofIndex, float velocity) Alter the velocity of the indexed DOF.- Parameters:
dofIndex
- which degree of freedom (≥0, <numDofs)velocity
- the desired velocity
-
worldTransform
public com.jme3.math.Transform worldTransform(com.jme3.math.Transform storeResult) Determine the transform of this link. Assumes the physics simulation has been stepped.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the Transform (either storeResult or a new instance, not null)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned object 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 object (not null)original
- the instance from which this object was shallow-cloned (unused)
-
jmeClone
Create a shallow clone for the JME cloner. Note that the cloned MultiBody won't be added to any PhysicsSpace, even if the original was.- Specified by:
jmeClone
in interfacecom.jme3.util.clone.JmeCloneable
- Returns:
- a new instance
-
read
De-serialize this object 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 object 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
-