Package com.jme3.bullet.joints
Class SixDofJoint
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
com.jme3.bullet.joints.Constraint
com.jme3.bullet.joints.SixDofJoint
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
- Direct Known Subclasses:
SixDofSpringJoint
A 6 degree-of-freedom joint based on Bullet's btGeneric6DofConstraint. Axis
rotations are applied in XYZ order.
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.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.SixDofJoint
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB, boolean useLinearReferenceFrameA) Instantiate a double-ended SixDofJoint.SixDofJoint
(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 SixDofJoint.SixDofJoint
(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 SixDofJoint. -
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-endedbtGeneric6DofConstraint
.protected long
createJoint1
(long bodyIdB, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInB, boolean useLinearReferenceFrameB) Create a single-endedbtGeneric6DofConstraint
.com.jme3.math.Vector3f
getAngles
(com.jme3.math.Vector3f storeResult) Copy the joint's rotation angles.com.jme3.math.Vector3f
getAngularLowerLimit
(com.jme3.math.Vector3f storeResult) Copy the joint's lower limits for rotation on all 3 axes.com.jme3.math.Vector3f
getAngularUpperLimit
(com.jme3.math.Vector3f storeResult) Copy the joint's upper limits for rotation on all 3 axes.com.jme3.math.Transform
getFrameTransform
(JointEnd end, com.jme3.math.Transform storeResult) Copy the joint's frame transform relative to the specified end.com.jme3.math.Vector3f
getLinearLowerLimit
(com.jme3.math.Vector3f storeResult) Copy the joint's lower limits for translation on all 3 axes.com.jme3.math.Vector3f
getLinearUpperLimit
(com.jme3.math.Vector3f storeResult) Copy the joint's upper limits for translation on all 3 axes.com.jme3.math.Vector3f
getPivotOffset
(com.jme3.math.Vector3f storeResult) Copy the joint's pivot offset.getRotationalLimitMotor
(int axisIndex) Access the indexed RotationalLimitMotor of this joint, the motor which influences rotation around the indexed axis.Access the TranslationalLimitMotor of this joint, the motor which influences translation on all 3 axes.void
read
(com.jme3.export.JmeImporter importer) De-serialize this joint from the specified importer, for example when loading from a J3O file.void
setAngularLowerLimit
(com.jme3.math.Vector3f limits) Alter the joint's lower limits for rotation of all 3 axes.void
setAngularUpperLimit
(com.jme3.math.Vector3f limits) Alter the joint's upper limits for rotation of all 3 axes.void
setLinearLowerLimit
(com.jme3.math.Vector3f vector) Alter the joint's lower limits for translation of all 3 axes.void
setLinearUpperLimit
(com.jme3.math.Vector3f vector) Alter the joint's upper limits for translation of all 3 axes.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.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
-
logger2
message logger for this class
-
-
Constructor Details
-
SixDofJoint
protected SixDofJoint()No-argument constructor needed by SavableClassUtil. -
SixDofJoint
public SixDofJoint(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 SixDofJoint.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)
-
SixDofJoint
public SixDofJoint(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 SixDofJoint.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 joint orientation in A's local coordinates (rotation matrix, unaffected)rotInB
- the joint orientation in B's local coordinates (rotation matrix, unaffected)useLinearReferenceFrameA
- true→use body A, false→use body B
-
SixDofJoint
public SixDofJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB, boolean useLinearReferenceFrameA) Instantiate a double-ended SixDofJoint.To be effective, the joint must be added to the body's PhysicsSpace and the body must be dynamic.
- Parameters:
rigidBodyA
- the first body to constrain (not null, alias created)rigidBodyB
- the 2nd body to constrain (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)useLinearReferenceFrameA
- true→use body A, false→use body B
-
-
Method Details
-
getAngles
public com.jme3.math.Vector3f getAngles(com.jme3.math.Vector3f storeResult) Copy the joint's rotation angles.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the rotation angle for each local axis (in radians, either storeResult or a new vector, not null)
-
getAngularLowerLimit
public com.jme3.math.Vector3f getAngularLowerLimit(com.jme3.math.Vector3f storeResult) Copy the joint's lower limits for rotation on all 3 axes.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the lower limit for each local axis (in radians, either storeResult or a new vector, not null)
-
getAngularUpperLimit
public com.jme3.math.Vector3f getAngularUpperLimit(com.jme3.math.Vector3f storeResult) Copy the joint's upper limits for rotation on all 3 axes.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the upper limit for each local axis (in radians, either storeResult or a new vector, not null)
-
getFrameTransform
Copy the joint's frame transform relative to the specified end.- Parameters:
end
- which end (not null)storeResult
- storage for the result (modified if not null)- Returns:
- the transform of the constraint space relative to the end
-
getLinearLowerLimit
public com.jme3.math.Vector3f getLinearLowerLimit(com.jme3.math.Vector3f storeResult) Copy the joint's lower limits for translation on all 3 axes.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the lower limit for each local axis (in radians, either storeResult or a new vector, not null)
-
getLinearUpperLimit
public com.jme3.math.Vector3f getLinearUpperLimit(com.jme3.math.Vector3f storeResult) Copy the joint's upper limits for translation on all 3 axes.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the upper limit for each local axis (in radians, either storeResult or a new vector, not null)
-
getPivotOffset
public com.jme3.math.Vector3f getPivotOffset(com.jme3.math.Vector3f storeResult) Copy the joint's pivot offset.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the relative pivot position on each local axis (in physics-space units, either storeResult or a new vector, not null)
-
getRotationalLimitMotor
Access the indexed RotationalLimitMotor of this joint, the motor which influences rotation around the indexed axis.- Parameters:
axisIndex
- the axis index of the desired motor: 0→X, 1→Y, 2→Z- Returns:
- the pre-existing instance
-
getTranslationalLimitMotor
Access the TranslationalLimitMotor of this joint, the motor which influences translation on all 3 axes.- Returns:
- the pre-existing instance
-
setAngularLowerLimit
public void setAngularLowerLimit(com.jme3.math.Vector3f limits) Alter the joint's lower limits for rotation of all 3 axes.- Parameters:
limits
- the desired lower limits (in radians, not null, unaffected)
-
setAngularUpperLimit
public void setAngularUpperLimit(com.jme3.math.Vector3f limits) Alter the joint's upper limits for rotation of all 3 axes.- Parameters:
limits
- the desired upper limits (in radians, not null, unaffected)
-
setLinearLowerLimit
public void setLinearLowerLimit(com.jme3.math.Vector3f vector) Alter the joint's lower limits for translation of all 3 axes.- Parameters:
vector
- the desired lower limits (not null, unaffected)
-
setLinearUpperLimit
public void setLinearUpperLimit(com.jme3.math.Vector3f vector) Alter the joint's upper limits for translation of all 3 axes.- Parameters:
vector
- the desired upper limits (not null, unaffected)
-
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-endedbtGeneric6DofConstraint
.- 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-endedbtGeneric6DofConstraint
.- 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 classConstraint
- 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 classConstraint
- 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 classConstraint
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-