Package com.jme3.bullet.joints
Class SixDofSpringJoint
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
com.jme3.bullet.joints.Constraint
com.jme3.bullet.joints.SixDofJoint
com.jme3.bullet.joints.SixDofSpringJoint
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
A 6 degree-of-freedom joint based on Bullet's btGeneric6DofSpringConstraint.
From the Bullet manual:
For each axis:
- Lowerlimit = Upperlimit → axis is locked
- Lowerlimit > Upperlimit → axis is free
- Lowerlimit < Upperlimit → axis is limited in that range
It is recommended to use the btGeneric6DofSpring2Constraint, it has some improvements over the original btGeneric6Dof(Spring)Constraint.
- See Also:
-
Field Summary
Fields inherited from class com.jme3.bullet.joints.SixDofJoint
logger2
Fields inherited from class com.jme3.bullet.joints.Constraint
logger15, pivotA, pivotB
Fields inherited from class com.jme3.bullet.joints.PhysicsJoint
logger
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.SixDofSpringJoint
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInA, com.jme3.math.Matrix3f rotInB, boolean useLinearReferenceFrameA) Instantiate a double-ended SixDofSpringJoint.SixDofSpringJoint
(PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInB, com.jme3.math.Vector3f pivotInWorld, com.jme3.math.Matrix3f rotInB, com.jme3.math.Matrix3f rotInWorld, JointEnd linearReferenceFrame) Instantiate a single-ended SixDofSpringJoint. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned joint into a deep-cloned one, using the specified Cloner and original to resolve copied fields.protected long
createJoint
(long bodyIdA, long bodyIdB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Matrix3f rotInA, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInB, boolean useLinearReferenceFrameA) Create a double-endedbtGeneric6DofSpringConstraint
.protected long
createJoint1
(long bodyIdB, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInB, boolean useLinearReferenceFrameB) Create a single-endedbtGeneric6DofSpringConstraint
.void
enableSpring
(int dofIndex, boolean onOff) Enable or disable the spring for the indexed degree of freedom.float
getDamping
(int dofIndex) Return the damping of the indexed degree of freedom.float
getEquilibriumPoint
(int dofIndex) Return the equilibrium point of the indexed degree of freedom.float
getStiffness
(int dofIndex) Return the spring stiffness of the indexed degree of freedom.boolean
isSpringEnabled
(int dofIndex) Test whether the spring for the indexed degree of freedom is enabled.void
read
(com.jme3.export.JmeImporter importer) De-serialize this joint from the specified importer, for example when loading from a J3O file.void
setDamping
(int dofIndex, float damping) Alter the damping for the indexed degree of freedom.void
Alter the equilibrium points for all degrees of freedom, based on the joint's current location/orientation.void
setEquilibriumPoint
(int dofIndex) Alter the equilibrium point of the indexed degree of freedom, based on the joint's current location/orientation.void
setStiffness
(int dofIndex, float stiffness) Alter the spring stiffness for the indexed degree of freedom.void
write
(com.jme3.export.JmeExporter exporter) Serialize this joint to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.joints.SixDofJoint
getAngles, getAngularLowerLimit, getAngularUpperLimit, getFrameTransform, getLinearLowerLimit, getLinearUpperLimit, getPivotOffset, getRotationalLimitMotor, getTranslationalLimitMotor, setAngularLowerLimit, setAngularUpperLimit, setLinearLowerLimit, setLinearUpperLimit
Methods inherited from class com.jme3.bullet.joints.Constraint
copyConstraintProperties, getAppliedImpulse, getBodyA, getBodyB, getBreakingImpulseThreshold, getConstraintType, getOverrideIterations, getPivot, getPivotA, getPivotB, isCollisionBetweenLinkedBodies, isEnabled, isFeedback, overrideIterations, readConstraintProperties, setBreakingImpulseThreshold, setCollisionBetweenLinkedBodies, setEnabled, setFeedback, setPivotInA, setPivotInB
Methods inherited from class com.jme3.bullet.joints.PhysicsJoint
countEnds, destroy, findEnd, findOtherBody, getBody, getPhysicsSpace, jmeClone, setBodyA, setBodyB, setNativeId, setPhysicsSpace, toString
Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger3
message logger for this class
-
-
Constructor Details
-
SixDofSpringJoint
protected SixDofSpringJoint()No-argument constructor needed by SavableClassUtil. -
SixDofSpringJoint
public SixDofSpringJoint(PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInB, com.jme3.math.Vector3f pivotInWorld, com.jme3.math.Matrix3f rotInB, com.jme3.math.Matrix3f rotInWorld, JointEnd linearReferenceFrame) Instantiate a single-ended SixDofSpringJoint.To be effective, the joint must be added to the body's PhysicsSpace and the body must be dynamic.
- Parameters:
rigidBodyB
- the body to constrain (not null, alias created)pivotInB
- the pivot location in B's scaled local coordinates (not null, unaffected)pivotInWorld
- the pivot location in physics-space coordinates (not null, unaffected)rotInB
- the orientation of the joint in B's local coordinates (rotation matrix, not null, unaffected)rotInWorld
- the orientation of the joint in physics-space coordinates (rotation matrix, not null, unaffected)linearReferenceFrame
- which end to use as the linear reference frame (not null)
-
SixDofSpringJoint
public SixDofSpringJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInA, com.jme3.math.Matrix3f rotInB, boolean useLinearReferenceFrameA) Instantiate a double-ended SixDofSpringJoint.To be effective, the joint must be added to the PhysicsSpace of both bodies. Also, the bodies must be distinct and at least one of them must be dynamic.
- Parameters:
rigidBodyA
- the body for the A end (not null, alias created)rigidBodyB
- the body for the B end (not null, alias created)pivotInA
- the pivot location in A's scaled local coordinates (not null, unaffected)pivotInB
- the pivot location in B's scaled local coordinates (not null, unaffected)rotInA
- the orientation of the joint in A's local coordinates (not null, unaffected)rotInB
- the orientation of the joint in B's local coordinates (not null, unaffected)useLinearReferenceFrameA
- true→use body A, false→use body B
-
-
Method Details
-
enableSpring
public void enableSpring(int dofIndex, boolean onOff) Enable or disable the spring for the indexed degree of freedom. Enabling a spring also enables the corresponding limit motor. Disabling a spring also disables the corresponding limit motor.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)onOff
- true → enable, false → disable (default=false)
-
getDamping
public float getDamping(int dofIndex) Return the damping of the indexed degree of freedom.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)- Returns:
- the viscous damping ratio
-
getEquilibriumPoint
public float getEquilibriumPoint(int dofIndex) Return the equilibrium point of the indexed degree of freedom.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)- Returns:
- the equilibrium point
-
getStiffness
public float getStiffness(int dofIndex) Return the spring stiffness of the indexed degree of freedom.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)- Returns:
- the stiffness
-
isSpringEnabled
public boolean isSpringEnabled(int dofIndex) Test whether the spring for the indexed degree of freedom is enabled.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)- Returns:
- true if enabled, otherwise false
-
setDamping
public void setDamping(int dofIndex, float damping) Alter the damping for the indexed degree of freedom.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)damping
- the desired viscous damping ratio (0→no damping, 1→critically damped, default=1)
-
setEquilibriumPoint
public void setEquilibriumPoint()Alter the equilibrium points for all degrees of freedom, based on the joint's current location/orientation. -
setEquilibriumPoint
public void setEquilibriumPoint(int dofIndex) Alter the equilibrium point of the indexed degree of freedom, based on the joint's current location/orientation.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
-
setStiffness
public void setStiffness(int dofIndex, float stiffness) Alter the spring stiffness for the indexed degree of freedom.- Parameters:
dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)stiffness
- the desired stiffness (default=0)
-
createJoint
protected long createJoint(long bodyIdA, long bodyIdB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Matrix3f rotInA, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInB, boolean useLinearReferenceFrameA) Create a double-endedbtGeneric6DofSpringConstraint
.- Overrides:
createJoint
in classSixDofJoint
- Parameters:
bodyIdA
- the ID of the body for the A end (not zero)bodyIdB
- the ID of the body for the B end (not zero)pivotInA
- the pivot location in A's scaled local coordinates (not null, unaffected)rotInA
- the orientation of the joint in A's local coordinates (not null, unaffected)pivotInB
- the pivot location in B's scaled local coordinates (not null, unaffected)rotInB
- the orientation of the joint in B's local coordinates (not null, unaffected)useLinearReferenceFrameA
- true→use body A, false→use body B- Returns:
- the ID of the new joint
-
createJoint1
protected long createJoint1(long bodyIdB, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInB, boolean useLinearReferenceFrameB) Create a single-endedbtGeneric6DofSpringConstraint
.- Overrides:
createJoint1
in classSixDofJoint
- Parameters:
bodyIdB
- the ID of the body for the B end (not zero)pivotInB
- the pivot location in B's scaled local coordinates (not null, unaffected)rotInB
- the orientation of the joint in B's local coordinates (not null, unaffected)useLinearReferenceFrameB
- true→use body A, false→use body B- Returns:
- the ID of the new joint
-
cloneFields
Callback fromCloner
to convert this shallow-cloned joint 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 classSixDofJoint
- Parameters:
cloner
- the Cloner that's cloning this joint (not null)original
- the instance from which this joint was shallow-cloned (not null, unaffected)
-
read
De-serialize this joint from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classSixDofJoint
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
write
Serialize this joint to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classSixDofJoint
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-