Package com.jme3.bullet.joints
Class Anchor
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
com.jme3.bullet.joints.Anchor
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
A PhysicsJoint to join a particular node of a soft body (A) to a rigid body
(B), based on Bullet's btSoftBody::Anchor.
-
Field Summary
Fields inherited from class com.jme3.bullet.joints.PhysicsJoint
logger
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionprotected
Anchor()
No-argument constructor needed by SavableClassUtil.Anchor
(PhysicsSoftBody softBodyA, int nodeIndexA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInB, boolean allowCollisions) Instantiate an anchor with influence=1. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned Anchor into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3f
copyPivot
(com.jme3.math.Vector3f storeResult) Copy the location of the connection point in the rigid body at the B end.Access the rigid body at the B end.Access the soft body at the A end.float
Return how much influence the anchor has on the bodies.boolean
Test whether collisions are allowed between the bodies.boolean
Test whether this Anchor is enabled.int
Return the index of the anchored node in body A.void
read
(com.jme3.export.JmeImporter importer) De-serialize this joint from the specified importer, for example when loading from a J3O file.void
setInfluence
(float amount) Alter how much influence the anchor has on the bodies.void
setPivotInB
(com.jme3.math.Vector3f location) Alter the pivot location in B's local coordinates.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.PhysicsJoint
countEnds, destroy, findEnd, findOtherBody, getBody, getBodyA, getBodyB, 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
-
Anchor
protected Anchor()No-argument constructor needed by SavableClassUtil. -
Anchor
public Anchor(PhysicsSoftBody softBodyA, int nodeIndexA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInB, boolean allowCollisions) Instantiate an anchor with influence=1.- Parameters:
softBodyA
- the soft body for the A end (not null, alias created)nodeIndexA
- the index of the node for the A end (≥0, <numNodes)rigidBodyB
- the rigid body for the B end (not null, alias created)pivotInB
- the pivot location in B's scaled local coordinates (not null, unaffected)allowCollisions
- true→allow collisions between the bodies, false→disallow such collisions
-
-
Method Details
-
copyPivot
public com.jme3.math.Vector3f copyPivot(com.jme3.math.Vector3f storeResult) Copy the location of the connection point in the rigid 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)
-
getRigidBody
Access the rigid body at the B end.- Returns:
- the pre-existing body (not null)
-
getSoftBody
Access the soft body at the A end.- Returns:
- the pre-existing soft body (not null)
-
influence
public float influence()Return how much influence the anchor has on the bodies.- Returns:
- the amount (≥0, ≤1, 0→no influence, 1→strong influence)
-
isAllowCollision
public boolean isAllowCollision()Test whether collisions are allowed between the bodies.- Returns:
- true if collisions are allowed, otherwise false
-
nodeIndex
public int nodeIndex()Return the index of the anchored node in body A.- Returns:
- the node index (≥0)
-
setInfluence
public void setInfluence(float amount) Alter how much influence the anchor has on the bodies.- Parameters:
amount
- the degree of influence (≥0, ≤1, 0→no influence, 1→strong influence, default=1)
-
setPivotInB
public void setPivotInB(com.jme3.math.Vector3f location) Alter the pivot location in B's local coordinates.- Parameters:
location
- the desired location (not null, unaffected)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned Anchor 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 classPhysicsJoint
- Parameters:
cloner
- the Cloner that's cloning this Anchor (not null)original
- the instance from which this Anchor was shallow-cloned (not null, unaffected)
-
isEnabled
public boolean isEnabled()Test whether this Anchor is enabled.- Specified by:
isEnabled
in classPhysicsJoint
- Returns:
- true
-
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 classPhysicsJoint
- 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 classPhysicsJoint
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-