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:
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
ConstructorDescriptionSixDofSpringJoint
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, Matrix3f rotInA, Matrix3f rotInB, boolean useLinearReferenceFrameA) Instantiate a double-ended SixDofSpringJoint.SixDofSpringJoint
(PhysicsRigidBody rigidBodyB, Vector3f pivotInB, Vector3f pivotInWorld, Matrix3f rotInB, Matrix3f rotInWorld, JointEnd linearReferenceFrame) Instantiate a single-ended SixDofSpringJoint. -
Method Summary
Modifier and TypeMethodDescriptionprotected long
createJoint
(long bodyIdA, long bodyIdB, Vector3f pivotInA, Matrix3f rotInA, Vector3f pivotInB, Matrix3f rotInB, boolean useLinearReferenceFrameA) Create a double-endedbtGeneric6DofSpringConstraint
.protected long
createJoint1
(long bodyIdB, Vector3f pivotInB, 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
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.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
getAppliedImpulse, getBodyA, getBodyB, getBreakingImpulseThreshold, getConstraintType, getOverrideIterations, getPivot, getPivotA, getPivotB, isCollisionBetweenLinkedBodies, isEnabled, isFeedback, overrideIterations, setBreakingImpulseThreshold, setCollisionBetweenLinkedBodies, setEnabled, setFeedback, setPivotInA, setPivotInB
Methods inherited from class com.jme3.bullet.joints.PhysicsJoint
countEnds, destroy, findEnd, findOtherBody, getBody, getPhysicsSpace, 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
public SixDofSpringJoint(PhysicsRigidBody rigidBodyB, Vector3f pivotInB, Vector3f pivotInWorld, Matrix3f rotInB, 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, Vector3f pivotInA, Vector3f pivotInB, Matrix3f rotInA, 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, Vector3f pivotInA, Matrix3f rotInA, Vector3f pivotInB, 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, Vector3f pivotInB, 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
-