Package com.jme3.bullet.joints
Class GearJoint
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
com.jme3.bullet.joints.Constraint
com.jme3.bullet.joints.GearJoint
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
A joint that couples the angular velocities of two bodies, based on Bullet's
btGearConstraint.
From the Bullet manual:
The btGearConstraint will couple the angular velocity for two bodies around given local axis and ratio.
-
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.GearJoint
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f axisInA, com.jme3.math.Vector3f axisInB) Instantiate a double-ended GearJoint with a 1:1 ratio.GearJoint
(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f axisInA, com.jme3.math.Vector3f axisInB, float ratio) Instantiate a double-ended GearJoint with the specified gear ratio. -
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.com.jme3.math.Vector3f
getAxisA
(com.jme3.math.Vector3f storeResult) Copy A body's axis of rotation.com.jme3.math.Vector3f
getAxisB
(com.jme3.math.Vector3f storeResult) Copy the B body's axis of rotation.float
getRatio()
Get the gear ratio.void
read
(com.jme3.export.JmeImporter importer) De-serialize this joint from the specified importer, for example when loading from a J3O file.void
setAxisA
(com.jme3.math.Vector3f axisInA) Alter the A body's axis of rotation.void
setAxisB
(com.jme3.math.Vector3f axisInB) Alter the B body's axis of rotation.void
setRatio
(float ratio) Alter the joint's gear ratio.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
-
GearJoint
protected GearJoint()No-argument constructor needed by SavableClassUtil. -
GearJoint
public GearJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f axisInA, com.jme3.math.Vector3f axisInB) Instantiate a double-ended GearJoint with a 1:1 ratio.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)axisInA
- the A body's axis of rotation in its local coordinates (unit vector, not null, unaffected)axisInB
- the B body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
-
GearJoint
public GearJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f axisInA, com.jme3.math.Vector3f axisInB, float ratio) Instantiate a double-ended GearJoint with the specified gear ratio.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)axisInA
- the A body's axis of rotation in its local coordinates (unit vector, not null, unaffected)axisInB
- the B body's axis of rotation in its local coordinates (unit vector, not null, unaffected)ratio
- the number of revolutions the A body should make for each revolution of the B body
-
-
Method Details
-
getAxisA
public com.jme3.math.Vector3f getAxisA(com.jme3.math.Vector3f storeResult) Copy A body's axis of rotation.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the A body's axis of rotation in its local coordinates (either storeResult or new vector)
-
getAxisB
public com.jme3.math.Vector3f getAxisB(com.jme3.math.Vector3f storeResult) Copy the B body's axis of rotation.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the B body's axis of rotation in its local coordinates (either storeResult or new vector)
-
getRatio
public float getRatio()Get the gear ratio.- Returns:
- the number of revolutions the A body makes for each revolution of the B body
-
setAxisA
public void setAxisA(com.jme3.math.Vector3f axisInA) Alter the A body's axis of rotation.- Parameters:
axisInA
- the desired axis in local coordinates (unit vector, not null, unaffected)
-
setAxisB
public void setAxisB(com.jme3.math.Vector3f axisInB) Alter the B body's axis of rotation.- Parameters:
axisInB
- the axisInB axis in local coordinates (unit vector, not null, unaffected)
-
setRatio
public void setRatio(float ratio) Alter the joint's gear ratio.- Parameters:
ratio
- the number of revolutions the A body should make for each revolution of the B body (default=1)
-
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
-