Package com.jme3.bullet.joints
Class PhysicsJoint
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
- All Implemented Interfaces:
com.jme3.export.Savable,com.jme3.util.clone.JmeCloneable,Cloneable,Comparable<NativePhysicsObject>
- Direct Known Subclasses:
Anchor,Constraint,SoftPhysicsJoint
public abstract class PhysicsJoint
extends NativePhysicsObject
implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
The abstract base class for physics joints based on Bullet's
btTypedConstraint, btSoftBody::Anchor, or btSoftBody::Joint.
-
Field Summary
FieldsFields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcloneFields(com.jme3.util.clone.Cloner cloner, Object original) Callback fromClonerto convert this shallow-cloned object into a deep-cloned one, using the specified Cloner and original to resolve copied fields.intCount how many ends this joint has.voiddestroy()Remove this joint from the joint lists of both ends.findEnd(PhysicsBody body) Test whether the specified body is an end of this joint.findOtherBody(PhysicsBody body) Access the remaining body of this joint.Access the body at the specified end of this joint.getBodyA()Access the body at the joint's "A" end.getBodyB()Access the body at the joint's "B" end.Access the PhysicsSpace where this joint is added.abstract booleanTest whether this joint is enabled.jmeClone()Create a shallow clone for the JME cloner.voidread(com.jme3.export.JmeImporter importer) De-serialize this joint from the specified importer, for example when loading from a J3O file.protected final voidsetBodyA(PhysicsBody body) Specify the body at the joint's "A" end.protected final voidsetBodyB(PhysicsBody body) Specify the body at the joint's "B" end.protected voidsetNativeId(long jointId) Initialize the native ID.voidsetPhysicsSpace(PhysicsSpace physicsSpace) Alter which PhysicsSpace this joint is added to.toString()Represent this joint as a String.voidwrite(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.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger
message logger for this class
-
-
Constructor Details
-
PhysicsJoint
protected PhysicsJoint()Instantiate a PhysicsJoint.This no-arg constructor was made explicit to avoid javadoc warnings from JDK 18+.
-
-
Method Details
-
countEnds
public int countEnds()Count how many ends this joint has.- Returns:
- 1 if single-ended, 2 if double-ended
-
destroy
public void destroy()Remove this joint from the joint lists of both ends. -
findEnd
Test whether the specified body is an end of this joint.- Parameters:
body- the body to find (not null, unaffected)- Returns:
- the enum value if found, otherwise null
-
findOtherBody
Access the remaining body of this joint.- Parameters:
body- (not null, unaffected)- Returns:
- the body at the other end (null if not found or the joint is single-ended)
-
getBody
Access the body at the specified end of this joint.- Parameters:
end- which end of the joint to access (not null)- Returns:
- the pre-existing body, or null if none
-
getBodyA
Access the body at the joint's "A" end.- Returns:
- the pre-existing body, or null if none
-
getBodyB
Access the body at the joint's "B" end.- Returns:
- the pre-existing body, or null if none
-
getPhysicsSpace
Access the PhysicsSpace where this joint is added.- Returns:
- the pre-existing instance, or null if none
-
isEnabled
public abstract boolean isEnabled()Test whether this joint is enabled.- Returns:
- true if enabled, otherwise false
-
setPhysicsSpace
Alter which PhysicsSpace this joint is added to. Do not invoke directly! The field is updated automatically when added/removed.- Parameters:
physicsSpace- (may be null)
-
setBodyA
Specify the body at the joint's "A" end.- Parameters:
body- the desired body (not null, alias created)
-
setBodyB
Specify the body at the joint's "B" end.- Parameters:
body- the desired body (not null, alias created)
-
cloneFields
Callback fromClonerto convert this shallow-cloned object into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFieldsin interfacecom.jme3.util.clone.JmeCloneable- Parameters:
cloner- the Cloner that's cloning this joint (not null)original- the instance from which this joint was shallow-cloned (not null, unaffected)
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClonein interfacecom.jme3.util.clone.JmeCloneable- Returns:
- a new instance
-
read
De-serialize this joint from the specified importer, for example when loading from a J3O file.- Specified by:
readin interfacecom.jme3.export.Savable- 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:
writein interfacecom.jme3.export.Savable- Parameters:
exporter- (not null)- Throws:
IOException- from the exporter
-
setNativeId
protected void setNativeId(long jointId) Initialize the native ID.- Overrides:
setNativeIdin classNativePhysicsObject- Parameters:
jointId- the native identifier of the btTypedConstraint, btSoftBody::Anchor, or btSoftBody::Joint (not zero)
-
toString
Represent this joint as a String.- Overrides:
toStringin classNativePhysicsObject- Returns:
- a descriptive string of text (not null, not empty)
-