Package com.jme3.bullet.joints
Class HingeJoint
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
com.jme3.bullet.joints.Constraint
com.jme3.bullet.joints.HingeJoint
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
A single degree-of-freedom joint based on Bullet's btHingeConstraint.
From the Bullet manual:
Hinge constraint, or revolute joint restricts two additional angular degrees
of freedom, so the body can only rotate around one axis, the hinge axis. This
can be useful to represent doors or wheels rotating around one axis. The user
can specify limits and motor for the hinge.
-
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
ConstructorDescriptionHingeJoint
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, Vector3f axisInA, Vector3f axisInB) Instantiate a double-ended HingeJoint.HingeJoint
(PhysicsRigidBody rigidBodyA, Vector3f pivotInA, Vector3f pivotInWorld, Vector3f axisInA, Vector3f axisInWorld, JointEnd referenceFrame) Instantiate a single-ended HingeJoint. -
Method Summary
Modifier and TypeMethodDescriptionvoid
enableMotor
(boolean enable, float targetVelocity, float maxMotorImpulse) Enable or disable this joint's motor.float
Read this joint's bias factor.boolean
Test whether this joint's motor is enabled.getFrameTransform
(JointEnd end, Transform storeResult) Copy the joint's frame transform relative to the specified end.float
Read the hinge angle.float
Read this joint's limit softness.final float
Read the lower limit of the hinge angle.float
Read the motor's maximum impulse.float
Read the motor's target velocity.float
Read this joint's relaxation factor.final float
Read the upper limit of the hinge angle.boolean
Test whether this joint is angular-only, meaning no constraints on translation.void
setAngularOnly
(boolean angularOnly) Alter whether this joint is angular-only, meaning no constraints on translation.void
setLimit
(float low, float high) Alter the angular limits for this joint.void
setLimit
(float low, float high, float softness, float bias, float relaxation) Alter the angular limits for this joint.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
-
logger2
message logger for this class
-
-
Constructor Details
-
HingeJoint
public HingeJoint(PhysicsRigidBody rigidBodyA, Vector3f pivotInA, Vector3f pivotInWorld, Vector3f axisInA, Vector3f axisInWorld, JointEnd referenceFrame) Instantiate a single-ended HingeJoint.To be effective, the joint must be added to the body's PhysicsSpace and the body must be dynamic.
- Parameters:
rigidBodyA
- the body to constrain (not null, alias created)pivotInA
- the pivot location in A's scaled local coordinates (not null, unaffected)pivotInWorld
- the pivot location in physics-space coordinates (not null, unaffected)axisInA
- the joint axis in A's local coordinates (unit vector, unaffected)axisInWorld
- the joint axis in physics-space coordinates (unit vector, unaffected)referenceFrame
- which end to use as the reference frame (not null)
-
HingeJoint
public HingeJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, Vector3f axisInA, Vector3f axisInB) Instantiate a double-ended HingeJoint.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)axisInA
- the joint axis in A's local coordinates (unit vector, unaffected)axisInB
- the joint axis in B's local coordinates (unit vector, unaffected)
-
-
Method Details
-
enableMotor
public void enableMotor(boolean enable, float targetVelocity, float maxMotorImpulse) Enable or disable this joint's motor.- Parameters:
enable
- true to enable, false to disable (default=false)targetVelocity
- the desired target velocitymaxMotorImpulse
- the desired maximum rotational force
-
getBiasFactor
public float getBiasFactor()Read this joint's bias factor.- Returns:
- the magnitude of the position correction: how strictly position errors (drift) are corrected
-
getEnableMotor
public boolean getEnableMotor()Test whether this joint's motor is enabled.- Returns:
- true if enabled, otherwise false
-
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
-
getHingeAngle
public float getHingeAngle()Read the hinge angle.- Returns:
- the angle (in radians)
-
getLimitSoftness
public float getLimitSoftness()Read this joint's limit softness.- Returns:
- the range fraction at which velocity-error correction starts operating
-
getLowerLimit
public final float getLowerLimit()Read the lower limit of the hinge angle.- Returns:
- the angle (in radians)
-
getMotorTargetVelocity
public float getMotorTargetVelocity()Read the motor's target velocity.- Returns:
- velocity
-
getMaxMotorImpulse
public float getMaxMotorImpulse()Read the motor's maximum impulse.- Returns:
- impulse
-
getRelaxationFactor
public float getRelaxationFactor()Read this joint's relaxation factor.- Returns:
- the rate at which velocity errors are corrected
-
getUpperLimit
public final float getUpperLimit()Read the upper limit of the hinge angle.- Returns:
- angle (in radians)
-
isAngularOnly
public boolean isAngularOnly()Test whether this joint is angular-only, meaning no constraints on translation.- Returns:
- true if angular-only, otherwise false
-
setAngularOnly
public void setAngularOnly(boolean angularOnly) Alter whether this joint is angular-only, meaning no constraints on translation.- Parameters:
angularOnly
- true→translation is free, false→translation is constrained (default=false)
-
setLimit
public void setLimit(float low, float high) Alter the angular limits for this joint.- Parameters:
low
- the desired lower limit of the hinge angle (in radians, default=1)high
- the desired upper limit of the hinge angle (in radians, default=-1)
-
setLimit
public void setLimit(float low, float high, float softness, float bias, float relaxation) Alter the angular limits for this joint.If you're above the softness, velocities that would shoot through the actual limit are slowed down. The bias should be in the range of 0.2 - 0.5.
- Parameters:
low
- the desired lower limit of the hinge angle (in radians, default=1)high
- the desired upper limit of the hinge angle (in radians, default=-1)softness
- the desired range fraction at which velocity-error correction starts operating. A softness of 0.9 means that the correction starts at 90% of the limit range. (default=0.9)bias
- the desired magnitude of the position correction: how strictly position errors (drift) are corrected (default=0.3)relaxation
- the desired rate at which velocity errors are corrected. This can be seen as the strength of the limits. A low value will make the limits more spongy. (default=1)
-