Package com.jme3.bullet.objects
Class PhysicsSoftBody
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.PhysicsCollisionObject
com.jme3.bullet.objects.PhysicsBody
com.jme3.bullet.objects.PhysicsSoftBody
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
- Direct Known Subclasses:
ReducedDeformableBody
A collision object to simulate a soft body, based on Bullet's btSoftBody. It
is modeled as a mesh of nodes. Unlike other collision objects, the
CollisionShape is ignored and is typically null.
-
Field Summary
Fields inherited from class com.jme3.bullet.objects.PhysicsBody
massForStatic
Fields inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
COLLISION_GROUP_01, COLLISION_GROUP_02, COLLISION_GROUP_03, COLLISION_GROUP_04, COLLISION_GROUP_05, COLLISION_GROUP_06, COLLISION_GROUP_07, COLLISION_GROUP_08, COLLISION_GROUP_09, COLLISION_GROUP_10, COLLISION_GROUP_11, COLLISION_GROUP_12, COLLISION_GROUP_13, COLLISION_GROUP_14, COLLISION_GROUP_15, COLLISION_GROUP_16, COLLISION_GROUP_NONE, logger
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionInstantiate an empty soft body.protected
PhysicsSoftBody
(boolean unused) Instantiate an uninitialized soft body, for internal use. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addVelocity
(Vector3f velocity) Add velocity to this entire body.void
addVelocity
(Vector3f velocity, int nodeIndex) Add velocity to the indexed node of this body.void
appendFaces
(IndexBuffer nodeIndices) Append faces to this body.void
appendLinks
(IndexBuffer nodeIndices) Append links to this body.void
appendNodes
(FloatBuffer nodeLocations) Append nodes to this body, each with mass=1.void
appendTetras
(IndexBuffer tetrahedra) Append tetrahedra to this body.void
applyForce
(Vector3f force) Apply a force that acts uniformly across the entire body.void
applyForce
(Vector3f force, int nodeIndex) Apply a force to the indexed node of this body.void
applyRotation
(Quaternion rotation) Rotate this body.void
applyScale
(Vector3f factors) Scale this body.void
applyTransform
(Transform transform) Transform this body.void
applyTranslation
(Vector3f offset) Translate this body.boundingBox
(BoundingBox storeResult) Calculate the axis-aligned bounding box for this body.clusterCenter
(int clusterIndex, Vector3f storeResult) Copy the center location of the indexed cluster.copyClusterCenters
(FloatBuffer storeResult) Copy the center-of-mass locations of all clusters in this body.copyClusterMasses
(FloatBuffer storeResult) Copy the masses of all clusters in this body.copyClusterVelocities
(FloatBuffer storeResult) Copy the (linear) velocities of all clusters in this body.Copy the node indices of all faces in this body.Copy the node indices of all links in this body.copyLocations
(FloatBuffer storeResult) Copy the locations of all nodes in this body.copyMasses
(FloatBuffer storeResult) Copy the masses of all nodes in this body.copyNormals
(FloatBuffer storeResult) Copy the normal vectors of all nodes in this body.copyTetras
(IntBuffer storeResult) Copy the node indices of all tetrahedra in this body.copyVelocities
(FloatBuffer storeResult) Copy the (linear) velocities of all nodes in this body.final int
Count the clusters in this body.final int
Count the faces in this body.final int
Count the links in this body.final int
Count the nodes in this body.int
countNodesInCluster
(int clusterIndex) Count the nodes in the indexed cluster.final int
Count the pinned nodes in this body.final int
Count the tetrahedra in this body.boolean
cutLink
(int nodeIndex0, int nodeIndex1, float cutLocation) Cut a pre-existing link in this body.protected void
Destroy the pre-existing btSoftBody (if any) except for its worldInfo.void
generateBendingConstraints
(int numHops, SoftBodyMaterial material) Generate bending constraints based on hops in the adjacency graph.void
Generate one cluster per tetrahedron (or one per face if there are no tetrahedra).void
generateClusters
(int k, int maxIterations) Generate clusters (K-mean).float
Read the specified parameter of the indexed cluster.getGravity
(Vector3f storeResult) Copy this body's gravitational acceleration.float
getMass()
Determine the total mass of this body.getPhysicsLocation
(Vector3f storeResult) Locate the center of this body's axis-aligned bounding box.getPhysicsLocationDp
(Vec3d storeResult) Locate the center of this body's axis-aligned bounding box.getPhysicsRotation
(Quaternion storeResult) Copy the orientation (rotation) of this body to a Quaternion.getPhysicsRotationDp
(Quatd storeResult) Copy the orientation (rotation) of this body to a Quatd.getPhysicsRotationMatrix
(Matrix3f storeResult) Copy the orientation of this body (the basis of its local coordinate system) to a Matrix3f.getPhysicsRotationMatrixDp
(Matrix3d storeResult) Copy the orientation of this body (the basis of its local coordinate system) to a Matrix3d.Copy the scale factors of this object.Access the SoftBodyConfig of this body.Access the Material of this body.Access the world info.protected void
Reinitialize the btSoftBody to the default values.boolean
isCollisionAllowed
(long pcoId) Test whether collisions are allowed between this body and the identified collision object.final boolean
isEmpty()
Test whether this body is empty.boolean
Test whether this body's world info should be replaced when added to a space.listNodesInCluster
(int clusterIndex, IntBuffer storeResult) List all nodes in the indexed cluster.float
margin()
Read the collision margin of this body.protected void
Create an emptybtSoftBody
for this PhysicsSoftBody, using the pre-existing worldInfo.nodeLocation
(int nodeIndex, Vector3f storeResult) Copy the location of the indexed node.float
nodeMass
(int nodeIndex) Read the mass of the indexed node.nodeNormal
(int nodeIndex, Vector3f storeResult) Copy the normal vector of the indexed node.nodeVelocity
(int nodeIndex, Vector3f storeResult) Copy the velocity of the indexed node.void
Randomize constraints to reduce solver bias.void
Release all clusters.void
releaseCluster
(int clusterIndex) Release the indexed cluster.void
Set the resting lengths of all links to their current lengths.float
Read the scale factor for resting lengths.void
Alter the specified parameter of the indexed cluster.protected void
setConfig
(SoftBodyConfig newConfig) Replace the configuration properties.void
setGravity
(Vector3f acceleration) Alter this body's gravitational acceleration.final void
setMargin
(float margin) Alter the collision margin of this body.void
setMass
(float totalMass) Alter the total mass for this body, distributing it in proportion to the current mass of each node.void
setMassByArea
(float totalMass) Alter the total mass for this body, distributing it based on the area of each face.void
setMassByCurrent
(float totalMass) Alter the total mass for this body, distributing it to nodes in proportion to their current masses.void
setMasses
(FloatBuffer masses) Alter the masses of all nodes.void
setMassFromDensity
(float density) Alter the total mass of this body, weighted by volume.void
setNodeMass
(int nodeIndex, float mass) Alter the mass of the indexed node.void
setNodeVelocity
(int nodeIndex, Vector3f velocity) Alter the velocity of the indexed node.void
setNormals
(FloatBuffer normals) Alter the normal vectors of all nodes.void
setPhysicsLocation
(Vector3f location) Directly relocate the center of this body's bounding box.void
setPhysicsLocationDp
(Vec3d location) Directly relocate the center of this body's bounding box.void
setPose
(boolean setVolumePose, boolean setFramePose) Set the "default pose" (lowest energy state) of this body based on its current pose.void
setProtectWorldInfo
(boolean newState) Alter whether this body's world info should be replaced when the body gets added to a space.void
setRestingLengthScale
(float scale) Alter the scale factor for resting lengths.void
setVelocities
(FloatBuffer velocities) Alter the velocities of all nodes.void
setVelocity
(Vector3f velocity) Alter the velocities of all nodes to make them identical.void
setVolumeDensity
(float density) Set volume density (using tetrahedra) TODO clarify semanticsvoid
setVolumeMass
(float mass) Set volume mass (using tetrahedra) TODO clarify semanticsvoid
setWindVelocity
(Vector3f velocity) Alter the wind velocity.void
setWorldInfo
(SoftBodyWorldInfo worldInfo) Replace the world info of this body.protected void
setWorldInfoInternal
(SoftBodyWorldInfo newInfo) Replace the world-dependent info.float
volume()
Calculate the volume of this body.windVelocity
(Vector3f storeResult) Copy the wind velocity.Methods inherited from class com.jme3.bullet.objects.PhysicsBody
addJoint, countJoints, getDeactivationDeadline, isDeactivationEnabled, listJoints, removeJoint, setDeactivationDeadline, setDeactivationEnabled
Methods inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
activate, addCollideWithGroup, addToIgnoreList, attachCollisionShape, clearIgnoreList, collisionFlags, copyPcoProperties, countIgnored, finalizeNative, findInstance, getActivationState, getAnisotropicFriction, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getCollideWithGroups, getCollisionGroup, getCollisionShape, getCollisionSpace, getContactDamping, getContactProcessingThreshold, getContactStiffness, getDeactivationTime, getFriction, getInternalType, getRestitution, getRollingFriction, getSpinningFriction, getTransform, getTransformDp, getUserObject, hasAnisotropicFriction, ignores, initUserPointer, isActive, isContactResponse, isInWorld, isStatic, listIgnoredPcos, proxyGroup, proxyMask, removeCollideWithGroup, removeFromIgnoreList, setActivationState, setAnisotropicFriction, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollideWithGroups, setCollisionFlags, setCollisionGroup, setCollisionShape, setContactDamping, setContactProcessingThreshold, setContactStiffness, setDeactivationTime, setFriction, setIgnoreList, setLocationAndBasis, setRestitution, setRollingFriction, setSpinningFriction, setUserIndex, setUserIndex2, setUserIndex3, setUserObject, spaceId, toString, userIndex, userIndex2, userIndex3
Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger2
message logger for this class
-
-
Constructor Details
-
PhysicsSoftBody
public PhysicsSoftBody()Instantiate an empty soft body. The new body is not added to any physics space. -
PhysicsSoftBody
protected PhysicsSoftBody(boolean unused) Instantiate an uninitialized soft body, for internal use.- Parameters:
unused
- to distinguish from the no-arg constructor
-
-
Method Details
-
addVelocity
Add velocity to this entire body.- Parameters:
velocity
- the velocity to add (in physics-space coordinates, not null, unaffected)
-
addVelocity
Add velocity to the indexed node of this body.- Parameters:
velocity
- the velocity to add (in physics-space coordinates, not null, unaffected)nodeIndex
- which node to add it to (≥0, <numNodes)
-
appendFaces
Append faces to this body. A Face is a triangle connecting 3 nodes.- Parameters:
nodeIndices
- a face is created for every 3 indices in this buffer (not null, direct, size a multiple of 3)
-
appendLinks
Append links to this body. A link is an interaction (or force) between 2 nodes.- Parameters:
nodeIndices
- a link is created for each pair of indices in this buffer (not null, direct, size a multiple of 2)
-
appendNodes
Append nodes to this body, each with mass=1. Nodes provide the shape of a soft body. Each node has its own location, velocity, mass, etcetera.- Parameters:
nodeLocations
- a node is created for every 3 floats in this buffer (not null, direct, limit a multiple of 3)
-
appendTetras
Append tetrahedra to this body. A tetrahedron defines a volume between 4 nodes.- Parameters:
tetrahedra
- a tetrahedron is created for every 4 indices in this buffer (not null, direct, size a multiple of 4)
-
applyForce
Apply a force that acts uniformly across the entire body.- Parameters:
force
- the force to add (in physics-space coordinates, not null, unaffected)
-
applyForce
Apply a force to the indexed node of this body.- Parameters:
force
- the force to add (in physics-space coordinates, not null, unaffected)nodeIndex
- which node to add it to (≥0, <numNodes)
-
applyRotation
Rotate this body.- Parameters:
rotation
- the rotation to apply (not null, unaffected)
-
applyScale
Scale this body.- Parameters:
factors
- the scale factor to apply to each axis (not null, unaffected)
-
applyTransform
Transform this body.- Parameters:
transform
- the transform to apply (not null, unaffected)
-
applyTranslation
Translate this body.- Parameters:
offset
- the translation to apply to each axis (not null, unaffected)
-
clusterCenter
Copy the center location of the indexed cluster.- Parameters:
clusterIndex
- which cluster (≥0, <numClusters)storeResult
- storage for the result (modified if not null)- Returns:
- a location vector (in physics-space coordinates, either storeResult or a new vector)
-
copyClusterCenters
Copy the center-of-mass locations of all clusters in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 3 floats per cluster (in physics-space coordinates, either storeResult or a new buffer)
-
copyClusterMasses
Copy the masses of all clusters in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing a float value per cluster (either storeResult or a new buffer)
-
copyClusterVelocities
Copy the (linear) velocities of all clusters in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 3 floats per cluster (in physics-space coordinates, either storeResult or a new buffer)
-
copyFaces
Copy the node indices of all faces in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 3 indices per face (either storeResult or a new buffer)
-
copyLinks
Copy the node indices of all links in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 2 indices per link (either storeResult or a new buffer)
-
copyLocations
Copy the locations of all nodes in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 3 floats per node (in physics-space coordinates, either storeResult or a new buffer)
-
copyMasses
Copy the masses of all nodes in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing a float value per node (either storeResult or a new buffer)
-
copyNormals
Copy the normal vectors of all nodes in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 3 floats per node (in physics-space coordinates, either storeResult or a new buffer)
-
copyTetras
Copy the node indices of all tetrahedra in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 4 indices per tetrahedron (either storeResult or a new buffer)
-
copyVelocities
Copy the (linear) velocities of all nodes in this body.- Parameters:
storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing 3 floats per node (in physics-space coordinates, either storeResult or a new buffer)
-
countClusters
public final int countClusters()Count the clusters in this body.- Returns:
- the number of clusters (≥0)
-
countFaces
public final int countFaces()Count the faces in this body.- Returns:
- the number of faces (≥0)
-
countLinks
public final int countLinks()Count the links in this body.- Returns:
- the number of links (≥0)
-
countNodes
public final int countNodes()Count the nodes in this body.- Returns:
- the number of nodes (≥0)
-
countNodesInCluster
public int countNodesInCluster(int clusterIndex) Count the nodes in the indexed cluster.- Parameters:
clusterIndex
- which cluster (≥0, <numClusters)- Returns:
- the number of nodes (≥0)
-
countPinnedNodes
public final int countPinnedNodes()Count the pinned nodes in this body.- Returns:
- the number of pinned nodes (≥0)
-
countTetras
public final int countTetras()Count the tetrahedra in this body.- Returns:
- the number of tetrahedra (≥0)
-
cutLink
public boolean cutLink(int nodeIndex0, int nodeIndex1, float cutLocation) Cut a pre-existing link in this body. TODO clarify the semantics- Parameters:
nodeIndex0
- the index of a node in the link (≥0,<numNodes)nodeIndex1
- the index of the other node in the link (≥0,<numNodes)cutLocation
- where to cut the link- Returns:
- true if successful, otherwise false
-
generateBendingConstraints
Generate bending constraints based on hops in the adjacency graph. This may increase the number of links.- Parameters:
numHops
- (in links, ≥2)material
- the material for appending links (not null)
-
generateClusters
public void generateClusters()Generate one cluster per tetrahedron (or one per face if there are no tetrahedra). Any pre-existing clusters are released. -
generateClusters
public void generateClusters(int k, int maxIterations) Generate clusters (K-mean). Any pre-existing clusters are released.- Parameters:
k
- (≥1, <numNodes)maxIterations
- the maximum number of iterations (>0, default=8192)
-
get
Read the specified parameter of the indexed cluster.- Parameters:
parameter
- which parameter to read (not null)clusterIndex
- which cluster (≥0, <numClusters)- Returns:
- the coefficient value
-
getSoftConfig
Access the SoftBodyConfig of this body.- Returns:
- the pre-existing instance (not null)
-
getSoftMaterial
Access the Material of this body.- Returns:
- the instance associated with this body (not null)
-
getWorldInfo
Access the world info.- Returns:
- the pre-existing instance (not null)
-
isCollisionAllowed
public boolean isCollisionAllowed(long pcoId) Test whether collisions are allowed between this body and the identified collision object. Disallowed collisions may result from anchors.- Parameters:
pcoId
- the native ID of the other collision object (not zero)- Returns:
- true if allowed, otherwise false
-
isEmpty
public final boolean isEmpty()Test whether this body is empty.- Returns:
- true if empty, otherwise false
-
isWorldInfoProtected
public boolean isWorldInfoProtected()Test whether this body's world info should be replaced when added to a space.- Returns:
- false if the info should be replaced, true if it should be preserved
-
listNodesInCluster
List all nodes in the indexed cluster.- Parameters:
clusterIndex
- which cluster (≥0, <numClusters)storeResult
- storage for the result (direct, modified) or null- Returns:
- a direct buffer containing node indices (either storeResult or a new buffer)
-
margin
public float margin()Read the collision margin of this body.- Returns:
- the margin distance (in physics-space units, >0)
-
nodeLocation
Copy the location of the indexed node.- Parameters:
nodeIndex
- which node (≥0, <numNodes)storeResult
- storage for the result (modified if not null)- Returns:
- a location vector (in physics-space coordinates, either storeResult or a new vector)
-
nodeMass
public float nodeMass(int nodeIndex) Read the mass of the indexed node.- Parameters:
nodeIndex
- which node to read (≥0, <numNodes)- Returns:
- the mass of the node (≥0)
-
nodeNormal
Copy the normal vector of the indexed node.- Parameters:
nodeIndex
- which node (≥0, <numNodes)storeResult
- storage for the result (modified if not null)- Returns:
- a normal vector (in physics-space coordinates, either storeResult or a new vector)
-
nodeVelocity
Copy the velocity of the indexed node.- Parameters:
nodeIndex
- which node (≥0, <numNodes)storeResult
- storage for the result (modified if not null)- Returns:
- a velocity vector (in physics-space coordinates, either storeResult or a new vector)
-
randomizeConstraints
public void randomizeConstraints()Randomize constraints to reduce solver bias. -
releaseAllClusters
public void releaseAllClusters()Release all clusters. -
releaseCluster
public void releaseCluster(int clusterIndex) Release the indexed cluster.- Parameters:
clusterIndex
- which cluster to release (≥0, <numClusters)
-
resetRestingLengths
public void resetRestingLengths()Set the resting lengths of all links to their current lengths. -
restingLengthsScale
public float restingLengthsScale()Read the scale factor for resting lengths.- Returns:
- the scale factor
-
set
Alter the specified parameter of the indexed cluster.- Parameters:
parameter
- which parameter to alter (not null)clusterIndex
- which cluster (≥0, <numClusters)value
- the desired value
-
setMargin
public final void setMargin(float margin) Alter the collision margin of this body.- Parameters:
margin
- the desired margin distance (in physics-space units, >0)
-
setMassByArea
public void setMassByArea(float totalMass) Alter the total mass for this body, distributing it based on the area of each face.- Parameters:
totalMass
- the desired total mass (>0)
-
setMassByCurrent
public void setMassByCurrent(float totalMass) Alter the total mass for this body, distributing it to nodes in proportion to their current masses.- Parameters:
totalMass
- the desired total mass (>0, default=numNodes)
-
setMasses
Alter the masses of all nodes.- Parameters:
masses
- a direct buffer containing the desired masses (not null, all elements ≥0)
-
setMassFromDensity
public void setMassFromDensity(float density) Alter the total mass of this body, weighted by volume.- Parameters:
density
- the desired density (>0)
-
setNodeMass
public void setNodeMass(int nodeIndex, float mass) Alter the mass of the indexed node.- Parameters:
nodeIndex
- which node to modify (≥0, <numNodes)mass
- the desired mass (≥0, default=1)
-
setNodeVelocity
Alter the velocity of the indexed node.- Parameters:
nodeIndex
- which node to modify (≥0, <numNodes)velocity
- the desired velocity vector (not null, unaffected)
-
setNormals
Alter the normal vectors of all nodes.- Parameters:
normals
- a direct buffer containing the desired normals (in physics-space coordinates, not null, unaffected)
-
setPhysicsLocationDp
Directly relocate the center of this body's bounding box.- Parameters:
location
- the desired location (in physics-space coordinates, not null, finite, unaffected)
-
setPose
public void setPose(boolean setVolumePose, boolean setFramePose) Set the "default pose" (lowest energy state) of this body based on its current pose.- Parameters:
setVolumePose
- true→alter the volume pose, false→ don't alter itsetFramePose
- true→alter the frame pose, false→ don't alter it
-
setProtectWorldInfo
public void setProtectWorldInfo(boolean newState) Alter whether this body's world info should be replaced when the body gets added to a space.- Parameters:
newState
- true to preserve the world info, false to allow it to be replaced (default=false)
-
setRestingLengthScale
public void setRestingLengthScale(float scale) Alter the scale factor for resting lengths.- Parameters:
scale
- the desired scale factor
-
setVelocities
Alter the velocities of all nodes.- Parameters:
velocities
- a direct buffer containing the desired velocities (in physics-space coordinates, not null, unaffected)
-
setVelocity
Alter the velocities of all nodes to make them identical.- Parameters:
velocity
- the desired velocity vector (in physics-space coordinates, not null, unaffected)
-
setVolumeDensity
public void setVolumeDensity(float density) Set volume density (using tetrahedra) TODO clarify semantics- Parameters:
density
- the desired density
-
setVolumeMass
public void setVolumeMass(float mass) Set volume mass (using tetrahedra) TODO clarify semantics- Parameters:
mass
- the desired mass
-
setWindVelocity
Alter the wind velocity.- Parameters:
velocity
- the desired velocity vector (in physics-space coordinates, not null, unaffected)
-
setWorldInfo
Replace the world info of this body.Invoke this method after adding the body to a space. Adding a body to a space may replace its world info.
- Parameters:
worldInfo
- the desired SoftBodyWorldInfo (not null, alias created)
-
volume
public float volume()Calculate the volume of this body.- Returns:
- the total volume (in cubic physics-space units, ≥0)
-
windVelocity
Copy the wind velocity.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a velocity vector (in physics-space coordinates, either storeResult or a new vector)
-
destroySoftBody
protected void destroySoftBody()Destroy the pre-existing btSoftBody (if any) except for its worldInfo. -
initDefault
protected void initDefault()Reinitialize the btSoftBody to the default values. -
newEmptySoftBody
protected void newEmptySoftBody()Create an emptybtSoftBody
for this PhysicsSoftBody, using the pre-existing worldInfo. The pre-existing btSoftBody (if any) will be destroyed. -
setConfig
Replace the configuration properties.- Parameters:
newConfig
- the desired configuration
-
setWorldInfoInternal
Replace the world-dependent info.- Parameters:
newInfo
- the desired info
-
boundingBox
Calculate the axis-aligned bounding box for this body.- Overrides:
boundingBox
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a bounding box (in physics-space coordinates, either storeResult or a new instance)
-
getGravity
Copy this body's gravitational acceleration.- Specified by:
getGravity
in classPhysicsBody
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an acceleration vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
getMass
public float getMass()Determine the total mass of this body.- Specified by:
getMass
in classPhysicsBody
- Returns:
- the total mass (≥0)
-
getPhysicsLocation
Locate the center of this body's axis-aligned bounding box.- Overrides:
getPhysicsLocation
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a location vector (in physics-space coordinates, either storeResult or a new instance, not null)
-
getPhysicsLocationDp
Locate the center of this body's axis-aligned bounding box.- Overrides:
getPhysicsLocationDp
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a location vector (in physics-space coordinates, either storeResult or a new instance, not null, finite)
-
getPhysicsRotation
Copy the orientation (rotation) of this body to a Quaternion.- Overrides:
getPhysicsRotation
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an identity quaternion (either storeResult or a new instance, not null)
-
getPhysicsRotationDp
Copy the orientation (rotation) of this body to a Quatd.- Overrides:
getPhysicsRotationDp
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an identity quaternion (either storeResult or a new instance, not null)
-
getPhysicsRotationMatrix
Copy the orientation of this body (the basis of its local coordinate system) to a Matrix3f.- Overrides:
getPhysicsRotationMatrix
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an identity matrix (either storeResult or a new instance, not null)
-
getPhysicsRotationMatrixDp
Copy the orientation of this body (the basis of its local coordinate system) to a Matrix3d.- Overrides:
getPhysicsRotationMatrixDp
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an identity matrix (either storeResult or a new instance, not null)
-
getScale
Copy the scale factors of this object.- Overrides:
getScale
in classPhysicsCollisionObject
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the value (1,1,1) (either storeResult or a new vector)
-
setGravity
Alter this body's gravitational acceleration.Invoke this method after adding the body to a space. Adding a body to a space may override its gravity.
- Specified by:
setGravity
in classPhysicsBody
- Parameters:
acceleration
- the desired acceleration vector (in physics-space coordinates, not null, unaffected)
-
setMass
public void setMass(float totalMass) Alter the total mass for this body, distributing it in proportion to the current mass of each node.- Specified by:
setMass
in classPhysicsBody
- Parameters:
totalMass
- the desired total mass (>0, default=numNodes)
-
setPhysicsLocation
Directly relocate the center of this body's bounding box.- Specified by:
setPhysicsLocation
in classPhysicsBody
- Parameters:
location
- the desired location (in physics-space coordinates, not null, finite, unaffected)
-