Class New6Dof
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
- Direct Known Subclasses:
NewHinge
From the Bullet manual:
This generic constraint can emulate a variety of standard constraints, by
configuring each of the 6 degrees of freedom (dof). The first 3 dof axis are
linear axis, which represent translation of rigid bodies, and the latter 3
dof axis represent the angular motion. Each axis can be either locked, free
or limited.
For each axis:
- Lowerlimit = Upperlimit → axis is locked
- Lowerlimit > Upperlimit → axis is free
- Lowerlimit < Upperlimit → axis is limited in that range
-
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
ConstructorDescriptionNew6Dof
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, Matrix3f rotInA, Matrix3f rotInB, RotationOrder rotationOrder) Instantiate a double-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked.New6Dof
(PhysicsRigidBody rigidBodyB, Vector3f pivotInB, Vector3f pivotInWorld, Matrix3f rotInB, Matrix3f rotInWorld, RotationOrder rotationOrder) Instantiate a single-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked. -
Method Summary
Modifier and TypeMethodDescriptioncalculatedBasisA
(Matrix3f storeResult) Calculate the pivot orientation of the A end.calculatedBasisB
(Matrix3f storeResult) Calculate the pivot orientation of the B end.calculatedOriginA
(Vector3f storeResult) Calculate the pivot location of the A end (native field: m_calculatedTransformA.m_origin).calculatedOriginB
(Vector3f storeResult) Calculate the pivot location of the B end (native field: m_calculatedTransformB.m_origin).boolean
Compare Bullet's rotation order to the JVM copy.void
enableSpring
(int dofIndex, boolean onOff) Enable or disable the spring for the indexed degree of freedom.float
get
(MotorParam parameter, int dofIndex) Return the specified parameter of the indexed degree of freedom.Calculate the constraint's rotation angles (native field: m_calculatedAxisAngleDiff).Calculate the indexed axis of the Constraint (native field: m_calculatedAxis).getFrameTransform
(JointEnd end, Transform storeResult) Copy the constraint's frame transform relative to the specified end (native fields: m_frameInA, m_frameInB).getPivotOffset
(Vector3f storeResult) Copy the constraint's pivot offset (native field: m_calculatedLinearDiff).getRotationMatrix
(JointEnd end, Matrix3f storeResult) Copy the orientation of the constraint in the specified end's coordinate system.getRotationMotor
(int axisIndex) Access the indexed RotationMotor of this constraint, the motor which influences rotation around the indexed axis.Return the order in which axis rotations are applied (native field: m_rotateOrder).Access the TranslationMotor of this Constraint, the motor which influences translation on all 3 axes.boolean
isMotorEnabled
(int dofIndex) Test whether the motor is enabled for the indexed degree of freedom.boolean
isServoEnabled
(int dofIndex) Test whether the servo is enabled for the indexed degree of freedom.boolean
isSpringEnabled
(int dofIndex) Test whether the spring is enabled for the indexed degree of freedom.static New6Dof
newInstance
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInWorld, Quaternion rotInWorld, RotationOrder rotationOrder) Instantiate a double-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked at zero.void
set
(MotorParam parameter, int dofIndex, float value) Alter the specified parameter for the indexed degree of freedom.void
setDamping
(int dofIndex, float damping, boolean limitIfNeeded) Alter the damping for the indexed degree of freedom.void
Alter the equilibrium points for all degrees of freedom, based on the constraint's current location/orientation.void
setEquilibriumPoint
(int dofIndex) Alter the equilibrium point of the indexed degree of freedom, based on the constraint's current location/orientation.void
setEquilibriumPoint
(int dofIndex, float value) Alter the equilibrium point of the indexed degree of freedom.void
setPivotInA
(Vector3f location) Alter the pivot location in A's scaled local coordinates.void
setPivotInB
(Vector3f location) Alter the pivot location in B's scaled local coordinates.void
setRotationOrder
(RotationOrder rotationOrder) Alter the order in which to apply axis rotations.void
setStiffness
(int dofIndex, float stiffness, boolean limitIfNeeded) Alter the spring stiffness for the indexed degree of freedom.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
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
-
logger2
message logger for this class
-
-
Constructor Details
-
New6Dof
public New6Dof(PhysicsRigidBody rigidBodyB, Vector3f pivotInB, Vector3f pivotInWorld, Matrix3f rotInB, Matrix3f rotInWorld, RotationOrder rotationOrder) Instantiate a single-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked.To be effective, the constraint 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 constraint in B's local coordinates (rotation matrix, not null, unaffected)rotInWorld
- the orientation of the constraint in physics-space coordinates (rotation matrix, not null, unaffected)rotationOrder
- the order in which to apply axis rotations (not null)
-
New6Dof
public New6Dof(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, Matrix3f rotInA, Matrix3f rotInB, RotationOrder rotationOrder) Instantiate a double-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked.To be effective, the constraint 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 constraint in A's local coordinates (not null, unaffected)rotInB
- the orientation of the constraint in B's local coordinates (not null, unaffected)rotationOrder
- the order in which to apply axis rotations (not null)
-
-
Method Details
-
calculatedBasisA
Calculate the pivot orientation of the A end.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the orientation (a rotation matrix in physics-space coordinates, either storeResult or a new matrix, not null)
-
calculatedBasisB
Calculate the pivot orientation of the B end.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the orientation (a rotation matrix in physics-space coordinates, either storeResult or a new matrix, not null)
-
calculatedOriginA
Calculate the pivot location of the A end (native field: m_calculatedTransformA.m_origin).- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a location vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
calculatedOriginB
Calculate the pivot location of the B end (native field: m_calculatedTransformB.m_origin).- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a location vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
checkRotationOrder
public boolean checkRotationOrder()Compare Bullet's rotation order to the JVM copy.- Returns:
- true if rotation orders are identical, otherwise false
-
enableSpring
public void enableSpring(int dofIndex, boolean onOff) Enable or disable the spring 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)onOff
- true → enable, false → disable (default=false)
-
get
Return the specified parameter of the indexed degree of freedom.- Parameters:
parameter
- which parameter (not null)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 parameter value
-
getAngles
Calculate the constraint's rotation angles (native field: m_calculatedAxisAngleDiff).- 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)
-
getAxis
Calculate the indexed axis of the Constraint (native field: m_calculatedAxis).- Parameters:
axisIndex
- the axis index of the desired motor: 0→X, 1→Y, 2→ZstoreResult
- 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)
-
getFrameTransform
Copy the constraint's frame transform relative to the specified end (native fields: m_frameInA, m_frameInB).- 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
-
getPivotOffset
Copy the constraint's pivot offset (native field: m_calculatedLinearDiff).- 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)
-
getRotationMatrix
Copy the orientation of the constraint in the specified end's coordinate system.- Parameters:
end
- which end (not null)storeResult
- storage for the result (modified if not null)- Returns:
- a rotation matrix (either storeResult or a new instance)
- See Also:
-
getRotationMotor
Access the indexed RotationMotor of this constraint, 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
-
getRotationOrder
Return the order in which axis rotations are applied (native field: m_rotateOrder).- Returns:
- an enum value (not null)
-
getTranslationMotor
Access the TranslationMotor of this Constraint, the motor which influences translation on all 3 axes.- Returns:
- the pre-existing instance
-
isMotorEnabled
public boolean isMotorEnabled(int dofIndex) Test whether the motor is enabled 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)- Returns:
- true if enabled, otherwise false
-
isServoEnabled
public boolean isServoEnabled(int dofIndex) Test whether the servo is enabled 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)- Returns:
- true if enabled, otherwise false
-
isSpringEnabled
public boolean isSpringEnabled(int dofIndex) Test whether the spring is enabled 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)- Returns:
- true if enabled, otherwise false
-
newInstance
public static New6Dof newInstance(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInWorld, Quaternion rotInWorld, RotationOrder rotationOrder) Instantiate a double-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked at zero. The pivot calculations assume all DOFs are initially at zero.To be effective, the Constraint 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)pivotInWorld
- the pivot location (in physics-space coordinates, not null, unaffected)rotInWorld
- the orientation of the constraint (in physics-space coordinates, not null, not zero, unaffected)rotationOrder
- the order in which to apply axis rotations (not null)- Returns:
- a new instance, not in any PhysicsSpace
-
set
Alter the specified parameter for the indexed degree of freedom.- Parameters:
parameter
- which parameter (not null)dofIndex
- which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)value
- the desired parameter value
-
setDamping
public void setDamping(int dofIndex, float damping, boolean limitIfNeeded) 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)limitIfNeeded
- true→automatically limit damping to prevent the spring from blowing up
-
setEquilibriumPoint
public void setEquilibriumPoint()Alter the equilibrium points for all degrees of freedom, based on the constraint's current location/orientation. -
setEquilibriumPoint
public void setEquilibriumPoint(int dofIndex) Alter the equilibrium point of the indexed degree of freedom, based on the constraint'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)
-
setEquilibriumPoint
public void setEquilibriumPoint(int dofIndex, float value) Alter 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)value
- the desired equilibrium point
-
setRotationOrder
Alter the order in which to apply axis rotations.- Parameters:
rotationOrder
- the desired order (not null)
-
setStiffness
public void setStiffness(int dofIndex, float stiffness, boolean limitIfNeeded) 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)limitIfNeeded
- true→automatically limit stiffness to prevent the spring from moving too widely
-
setPivotInA
Alter the pivot location in A's scaled local coordinates.- Overrides:
setPivotInA
in classConstraint
- Parameters:
location
- the desired location (not null, unaffected)
-
setPivotInB
Alter the pivot location in B's scaled local coordinates.- Overrides:
setPivotInB
in classConstraint
- Parameters:
location
- the desired location (not null, unaffected)
-