Package com.jme3.bullet.joints
Class NewHinge
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
com.jme3.bullet.joints.Constraint
com.jme3.bullet.joints.New6Dof
com.jme3.bullet.joints.NewHinge
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
A 3 degree-of-freedom Constraint that mimics ODE's Hinge2 joint, such as
might be used to model one of the front wheels on a motor vehicle.
Rotation is enabled only for the Z and X axes, with limits on Z-axis rotation. The X axis rotates freely. Translation is enabled only for the Z axis, with a suspension spring.
Inspired by Bullet's btHinge2Constraint.
-
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
NewHinge()
No-argument constructor needed by SavableClassUtil.NewHinge
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f anchor, com.jme3.math.Vector3f axis1, com.jme3.math.Vector3f axis2) Instantiate a double-ended constraint. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned constraint into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3f
getAnchor
(com.jme3.math.Vector3f storeResult) Determine the anchor location for body A.com.jme3.math.Vector3f
getAnchor2
(com.jme3.math.Vector3f storeResult) Determine the anchor location for body B.float
Determine the rotation angle for axis1.float
Determine the rotation angle for axis2.com.jme3.math.Vector3f
getAxis1
(com.jme3.math.Vector3f storeResult) Determine the direction of axis1.com.jme3.math.Vector3f
getAxis2
(com.jme3.math.Vector3f storeResult) Determine the direction of axis2.void
read
(com.jme3.export.JmeImporter importer) De-serialize this Constraint from the specified importer, for example when loading from a J3O file.final void
setLowerLimit
(float angle1Min) Alter the lower limit for axis1 rotation.final void
setUpperLimit
(float angle1Max) Alter the upper limit for axis1 rotation.void
write
(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.New6Dof
calculatedBasisA, calculatedBasisB, calculatedOriginA, calculatedOriginB, checkRotationOrder, enableSpring, get, getAngles, getAxis, getFrameTransform, getPivotOffset, getRotationMatrix, getRotationMotor, getRotationOrder, getTranslationMotor, isMotorEnabled, isServoEnabled, isSpringEnabled, newInstance, set, setDamping, setEquilibriumPoint, setEquilibriumPoint, setEquilibriumPoint, setRotationOrder, setStiffness
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
-
logger3
message logger for this class
-
-
Constructor Details
-
NewHinge
protected NewHinge()No-argument constructor needed by SavableClassUtil. -
NewHinge
public NewHinge(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f anchor, com.jme3.math.Vector3f axis1, com.jme3.math.Vector3f axis2) Instantiate a 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:
rigidBodyA
- the body for the A end (not null, alias created)rigidBodyB
- the body for the B end (not null, alias created)anchor
- initial anchor location for the constraint frame (in physics-space coordinates, not null, unaffected)axis1
- initial Z-axis direction for the constraint frame (in physics-space coordinates, not null, not zero, unaffected)axis2
- initial X-axis direction for the constraint frame (in physics-space coordinates, not null, not zero, unaffected)
-
-
Method Details
-
getAnchor
public com.jme3.math.Vector3f getAnchor(com.jme3.math.Vector3f storeResult) Determine the anchor location for body A.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the location (either storeResult or a new vector, not null)
-
getAnchor2
public com.jme3.math.Vector3f getAnchor2(com.jme3.math.Vector3f storeResult) Determine the anchor location for body B.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the location (either storeResult or a new vector, not null)
-
getAngle1
public float getAngle1()Determine the rotation angle for axis1.- Returns:
- the rotation angle (in radians)
-
getAngle2
public float getAngle2()Determine the rotation angle for axis2.- Returns:
- the rotation angle (in radians)
-
getAxis1
public com.jme3.math.Vector3f getAxis1(com.jme3.math.Vector3f storeResult) Determine the direction of axis1.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a direction vector (either storeResult or a new vector, not null)
-
getAxis2
public com.jme3.math.Vector3f getAxis2(com.jme3.math.Vector3f storeResult) Determine the direction of axis2.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a direction vector (either storeResult or a new vector, not null)
-
setLowerLimit
public final void setLowerLimit(float angle1Min) Alter the lower limit for axis1 rotation.- Parameters:
angle1Min
- the desired angle (in radians)
-
setUpperLimit
public final void setUpperLimit(float angle1Max) Alter the upper limit for axis1 rotation.- Parameters:
angle1Max
- the desired angle (in radians)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned constraint 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 classNew6Dof
- Parameters:
cloner
- the Cloner that's cloning this constraint (not null)original
- the instance from which this constraint was shallow-cloned (not null, unaffected)
-
read
De-serialize this Constraint from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classNew6Dof
- 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:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classNew6Dof
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-