Package com.jme3.bullet.joints
Class Constraint
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
com.jme3.bullet.joints.Constraint
- All Implemented Interfaces:
com.jme3.export.Savable,com.jme3.util.clone.JmeCloneable,Cloneable,Comparable<NativePhysicsObject>
- Direct Known Subclasses:
ConeJoint,GearJoint,HingeJoint,New6Dof,Point2PointJoint,SixDofJoint,SliderJoint
The abstract base class for rigid-body physics joints based on Bullet's
btTypedConstraint. A Constraint can be single-ended or double-ended:
- A single-ended Constraint constrains the motion of a dynamic rigid body.
- A double-ended Constraint connects 2 rigid bodies together in the same PhysicsSpace. One or both of the bodies must be dynamic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Loggermessage logger for this classprotected com.jme3.math.Vector3fcopy of the pivot location: in physics-space coordinates if bodyA is null, or else in A's scaled local coordinatesprotected com.jme3.math.Vector3fcopy of the pivot location: in physics-space coordinates if bodyB is null, or else in B's scaled local coordinatesFields inherited from class com.jme3.bullet.joints.PhysicsJoint
loggerFields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNo-argument constructor needed by SavableClassUtil.protectedConstraint(PhysicsBody bodyA, PhysicsBody bodyB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB) Instantiate an enabled, double-ended Constraint.protectedConstraint(PhysicsRigidBody body, JointEnd bodyEnd, com.jme3.math.Vector3f pivotInBody) Instantiate an enabled, single-ended Constraint using the specified body at the specified end.protectedConstraint(PhysicsRigidBody body, JointEnd bodyEnd, com.jme3.math.Vector3f pivotInBody, com.jme3.math.Vector3f pivotInWorld) Instantiate an enabled, single-ended Constraint using the specified body at the specified end. -
Method Summary
Modifier and TypeMethodDescriptionvoidcloneFields(com.jme3.util.clone.Cloner cloner, Object original) Callback fromClonerto convert this shallow-cloned Constraint into a deep-cloned one, using the specified Cloner and original to resolve copied fields.protected final voidCopy common properties from another constraint.floatDetermine the magnitude of the applied impulse.getBodyA()Access the rigid body at the A end.getBodyB()Access the rigid body at the B end.floatDetermine the breaking impulse threshold.protected static final intgetConstraintType(long constraintId) Read the constraint type.intDetermine the number of iterations used to solve this Constraint.com.jme3.math.Vector3fCopy the location of the specified connection point in the specified body.com.jme3.math.Vector3fgetPivotA(com.jme3.math.Vector3f storeResult) Copy the location of the connection point in the body at the A end.com.jme3.math.Vector3fgetPivotB(com.jme3.math.Vector3f storeResult) Copy the location of the connection point in the body at the B end.booleanTest whether collisions are handled between the ends.booleanTest whether this Constraint is enabled.booleanTest whether this Constraint has feedback enabled.voidoverrideIterations(int numIterations) Override the number of iterations used to solve this Constraint.voidread(com.jme3.export.JmeImporter importer) De-serialize this Constraint from the specified importer, for example when loading from a J3O file.protected final voidreadConstraintProperties(com.jme3.export.InputCapsule capsule) Read common properties from a capsule.voidsetBreakingImpulseThreshold(float desiredThreshold) Alter the breaking impulse threshold.voidsetCollisionBetweenLinkedBodies(boolean allow) Handle/ignore collisions between the ends of a double-ended joint.voidsetEnabled(boolean enable) Enable or disable this Constraint.voidsetFeedback(boolean enable) Enable or disable feedback for this Constraint.protected voidsetPivotInA(com.jme3.math.Vector3f location) Alter the pivot location in A's scaled local coordinates.protected voidsetPivotInB(com.jme3.math.Vector3f location) Alter the pivot location in B's scaled local coordinates.voidwrite(com.jme3.export.JmeExporter exporter) Serialize this Constraint to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.joints.PhysicsJoint
countEnds, destroy, findEnd, findOtherBody, getBody, getPhysicsSpace, jmeClone, setBodyA, setBodyB, setNativeId, setPhysicsSpace, toStringMethods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger15
message logger for this class -
pivotA
protected com.jme3.math.Vector3f pivotAcopy of the pivot location: in physics-space coordinates if bodyA is null, or else in A's scaled local coordinates -
pivotB
protected com.jme3.math.Vector3f pivotBcopy of the pivot location: in physics-space coordinates if bodyB is null, or else in B's scaled local coordinates
-
-
Constructor Details
-
Constraint
protected Constraint()No-argument constructor needed by SavableClassUtil. -
Constraint
Instantiate an enabled, single-ended Constraint using the specified body at the specified end.To be effective, the Constraint must be added to the body's PhysicsSpace and the body must be dynamic.
- Parameters:
body- the body to constrain (not null, alias created)bodyEnd- at which end to attach the body (not null)pivotInBody- the pivot location in the body's scaled local coordinates (not null, unaffected)
-
Constraint
protected Constraint(PhysicsRigidBody body, JointEnd bodyEnd, com.jme3.math.Vector3f pivotInBody, com.jme3.math.Vector3f pivotInWorld) Instantiate an enabled, single-ended Constraint using the specified body at the specified end.To be effective, the Constraint must be added to the body's PhysicsSpace and the body must be dynamic.
- Parameters:
body- the body to constrain (not null, alias created)bodyEnd- at which end to attach the body (not null)pivotInBody- the pivot location in the body's scaled local coordinates (not null, unaffected)pivotInWorld- the pivot location in physics-space coordinates (not null, unaffected)
-
Constraint
protected Constraint(PhysicsBody bodyA, PhysicsBody bodyB, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB) Instantiate an enabled, double-ended Constraint.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:
bodyA- the body for the A end (not null, alias created)bodyB- 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)
-
-
Method Details
-
getAppliedImpulse
public float getAppliedImpulse()Determine the magnitude of the applied impulse. Requires feedback.- Returns:
- impulse magnitude (≥0)
- Throws:
IllegalStateException- if feedback is not enabled
-
getBreakingImpulseThreshold
public float getBreakingImpulseThreshold()Determine the breaking impulse threshold.- Returns:
- the threshold value
-
getOverrideIterations
public int getOverrideIterations()Determine the number of iterations used to solve this Constraint.- Returns:
- the number of iterations (≥0) or -1 if using the solver's default
-
getPivot
Copy the location of the specified connection point in the specified body.- Parameters:
end- which end of the Constraint to access (not null)storeResult- storage for the result (modified if not null)- Returns:
- a location vector (in scaled local coordinates, either storeResult or a new instance)
-
getPivotA
public com.jme3.math.Vector3f getPivotA(com.jme3.math.Vector3f storeResult) Copy the location of the connection point in the body at the A end.- Parameters:
storeResult- storage for the result (modified if not null)- Returns:
- a location vector (in A's scaled local coordinates, either storeResult or a new instance)
-
getPivotB
public com.jme3.math.Vector3f getPivotB(com.jme3.math.Vector3f storeResult) Copy the location of the connection point in the body at the B end.- Parameters:
storeResult- storage for the result (modified if not null)- Returns:
- a location vector (in B's scaled local coordinates, either storeResult or a new instance)
-
isCollisionBetweenLinkedBodies
public boolean isCollisionBetweenLinkedBodies()Test whether collisions are handled between the ends.- Returns:
- true if collisions are handled, otherwise false
-
isFeedback
public boolean isFeedback()Test whether this Constraint has feedback enabled.- Returns:
- true if enabled, otherwise false
-
overrideIterations
public void overrideIterations(int numIterations) Override the number of iterations used to solve this Constraint.- Parameters:
numIterations- the desired number of iterations (≥0) or -1 to use the solver's default (default=-1)
-
setBreakingImpulseThreshold
public void setBreakingImpulseThreshold(float desiredThreshold) Alter the breaking impulse threshold.- Parameters:
desiredThreshold- the desired value (default=MAX_VALUE with SP library or +Infinity with DP library)
-
setCollisionBetweenLinkedBodies
public void setCollisionBetweenLinkedBodies(boolean allow) Handle/ignore collisions between the ends of a double-ended joint.- Parameters:
allow- true to handle collisions, false to ignore them (default=true)
-
setEnabled
public void setEnabled(boolean enable) Enable or disable this Constraint.- Parameters:
enable- true to enable, false to disable (default=true)
-
setFeedback
public void setFeedback(boolean enable) Enable or disable feedback for this Constraint.- Parameters:
enable- true to enable, false to disable (default=false)
-
copyConstraintProperties
Copy common properties from another constraint. Used during cloning.- Parameters:
old- (not null, unaffected)
-
getConstraintType
protected static final int getConstraintType(long constraintId) Read the constraint type.- Parameters:
constraintId- identifier of thebtTypedConstraint(not zero)- Returns:
- a btTypedConstraintType ordinal value (≥3)
-
readConstraintProperties
protected final void readConstraintProperties(com.jme3.export.InputCapsule capsule) throws IOException Read common properties from a capsule.- Parameters:
capsule- the input capsule (not null, modified)- Throws:
IOException- from the importer
-
setPivotInA
protected void setPivotInA(com.jme3.math.Vector3f location) Alter the pivot location in A's scaled local coordinates. The subclass is responsible for updating the native object.- Parameters:
location- the desired location (not null, unaffected)
-
setPivotInB
protected void setPivotInB(com.jme3.math.Vector3f location) Alter the pivot location in B's scaled local coordinates. The subclass is responsible for updating the native object.- Parameters:
location- the desired location (not null, unaffected)
-
cloneFields
Callback fromClonerto convert this shallow-cloned Constraint into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFieldsin interfacecom.jme3.util.clone.JmeCloneable- Overrides:
cloneFieldsin classPhysicsJoint- Parameters:
cloner- the Cloner that's cloning this Constraint (not null)original- the instance from which this Constraint was shallow-cloned (unused)
-
getBodyA
Access the rigid body at the A end.- Overrides:
getBodyAin classPhysicsJoint- Returns:
- the pre-existing rigid body, or null if none
-
getBodyB
Access the rigid body at the B end.- Overrides:
getBodyBin classPhysicsJoint- Returns:
- the pre-existing body, or null if none
-
isEnabled
public boolean isEnabled()Test whether this Constraint is enabled.- Specified by:
isEnabledin classPhysicsJoint- Returns:
- true if enabled, otherwise false
-
read
De-serialize this Constraint from the specified importer, for example when loading from a J3O file.- Specified by:
readin interfacecom.jme3.export.Savable- Overrides:
readin classPhysicsJoint- Parameters:
importer- (not null)- Throws:
IOException- from the importer
-
write
Serialize this Constraint to the specified exporter, for example when saving to a J3O file.- Specified by:
writein interfacecom.jme3.export.Savable- Overrides:
writein classPhysicsJoint- Parameters:
exporter- (not null)- Throws:
IOException- from the exporter
-