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:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addVelocity
(com.jme3.math.Vector3f velocity) Add velocity to this entire body.void
addVelocity
(com.jme3.math.Vector3f velocity, int nodeIndex) Add velocity to the indexed node of this body.void
appendFaces
(com.jme3.scene.mesh.IndexBuffer nodeIndices) Append faces to this body.void
appendLinks
(com.jme3.scene.mesh.IndexBuffer nodeIndices) Append links to this body.void
appendNodes
(FloatBuffer nodeLocations) Append nodes to this body, each with mass=1.void
appendTetras
(com.jme3.scene.mesh.IndexBuffer tetrahedra) Append tetrahedra to this body.void
applyForce
(com.jme3.math.Vector3f force) Apply a force that acts uniformly across the entire body.void
applyForce
(com.jme3.math.Vector3f force, int nodeIndex) Apply a force to the indexed node of this body.void
applyRotation
(com.jme3.math.Quaternion rotation) Rotate this body.void
applyScale
(com.jme3.math.Vector3f factors) Scale this body.void
applyTransform
(com.jme3.math.Transform transform) Transform this body.void
applyTranslation
(com.jme3.math.Vector3f offset) Translate this body.com.jme3.bounding.BoundingBox
boundingBox
(com.jme3.bounding.BoundingBox storeResult) Calculate the axis-aligned bounding box for this body.void
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned body into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3f
clusterCenter
(int clusterIndex, com.jme3.math.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.com.jme3.math.Vector3f
getGravity
(com.jme3.math.Vector3f storeResult) Copy this body's gravitational acceleration.float
getMass()
Determine the total mass of this body.com.jme3.math.Vector3f
getPhysicsLocation
(com.jme3.math.Vector3f storeResult) Locate the center of this body's axis-aligned bounding box.com.simsilica.mathd.Vec3d
getPhysicsLocationDp
(com.simsilica.mathd.Vec3d storeResult) Locate the center of this body's axis-aligned bounding box.com.jme3.math.Quaternion
getPhysicsRotation
(com.jme3.math.Quaternion storeResult) Copy the orientation (rotation) of this body to a Quaternion.com.simsilica.mathd.Quatd
getPhysicsRotationDp
(com.simsilica.mathd.Quatd storeResult) Copy the orientation (rotation) of this body to a Quatd.com.jme3.math.Matrix3f
getPhysicsRotationMatrix
(com.jme3.math.Matrix3f storeResult) Copy the orientation of this body (the basis of its local coordinate system) to a Matrix3f.com.simsilica.mathd.Matrix3d
getPhysicsRotationMatrixDp
(com.simsilica.mathd.Matrix3d storeResult) Copy the orientation of this body (the basis of its local coordinate system) to a Matrix3d.com.jme3.math.Vector3f
getScale
(com.jme3.math.Vector3f storeResult) 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.com.jme3.math.Vector3f
nodeLocation
(int nodeIndex, com.jme3.math.Vector3f storeResult) Copy the location of the indexed node.float
nodeMass
(int nodeIndex) Read the mass of the indexed node.com.jme3.math.Vector3f
nodeNormal
(int nodeIndex, com.jme3.math.Vector3f storeResult) Copy the normal vector of the indexed node.com.jme3.math.Vector3f
nodeVelocity
(int nodeIndex, com.jme3.math.Vector3f storeResult) Copy the velocity of the indexed node.void
Randomize constraints to reduce solver bias.void
read
(com.jme3.export.JmeImporter importer) De-serialize this body from the specified importer, for example when loading from a J3O file.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.void
setDebugMeshNormals
(jme3utilities.MeshNormals newSetting) Alter which normals to include in new debug meshes.void
setGravity
(com.jme3.math.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, com.jme3.math.Vector3f velocity) Alter the velocity of the indexed node.void
setNormals
(FloatBuffer normals) Alter the normal vectors of all nodes.void
setPhysicsLocation
(com.jme3.math.Vector3f location) Directly relocate the center of this body's bounding box.void
setPhysicsLocationDp
(com.simsilica.mathd.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
(com.jme3.math.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
(com.jme3.math.Vector3f velocity) Alter the wind velocity.void
setWorldInfo
(SoftBodyWorldInfo worldInfo) Replace the world info of this body.float
volume()
Calculate the volume of this body.com.jme3.math.Vector3f
windVelocity
(com.jme3.math.Vector3f storeResult) Copy the wind velocity.void
write
(com.jme3.export.JmeExporter exporter) Serialize this body to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.objects.PhysicsBody
addJoint, cloneJoints, countJoints, getDeactivationDeadline, isDeactivationEnabled, listJoints, readJoints, removeJoint, setDeactivationDeadline, setDeactivationEnabled, writeJoints
Methods inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
activate, addCollideWithGroup, addToIgnoreList, attachCollisionShape, clearIgnoreList, cloneIgnoreList, collisionFlags, copyPcoProperties, countIgnored, debugMeshInitListener, debugMeshNormals, debugMeshResolution, debugNumSides, finalizeNative, findInstance, getActivationState, getAnisotropicFriction, getApplicationData, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getCollideWithGroups, getCollisionGroup, getCollisionShape, getCollisionSpace, getContactDamping, getContactProcessingThreshold, getContactStiffness, getDeactivationTime, getDebugMaterial, getFriction, getInternalType, getPhysicsLocation, getRestitution, getRollingFriction, getSpinningFriction, getTransform, getUserObject, hasAnisotropicFriction, ignores, initUserPointer, isActive, isContactResponse, isInWorld, isStatic, jmeClone, listIgnoredPcos, proxyGroup, proxyMask, readPcoProperties, removeCollideWithGroup, removeFromIgnoreList, setActivationState, setAnisotropicFriction, setApplicationData, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollideWithGroups, setCollisionFlags, setCollisionGroup, setCollisionShape, setContactDamping, setContactProcessingThreshold, setContactStiffness, setDeactivationTime, setDebugMaterial, setDebugMeshInitListener, setDebugMeshResolution, setDebugNumSides, 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.
-
-
Method Details
-
addVelocity
public void addVelocity(com.jme3.math.Vector3f velocity) Add velocity to this entire body.- Parameters:
velocity
- the velocity to add (in physics-space coordinates, not null, unaffected)
-
addVelocity
public void addVelocity(com.jme3.math.Vector3f velocity, int nodeIndex) 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
public void appendFaces(com.jme3.scene.mesh.IndexBuffer nodeIndices) 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
public void appendLinks(com.jme3.scene.mesh.IndexBuffer nodeIndices) 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
public void appendTetras(com.jme3.scene.mesh.IndexBuffer tetrahedra) 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
public void applyForce(com.jme3.math.Vector3f force) Apply a force that acts uniformly across the entire body.- Parameters:
force
- the force to add (in physics-space coordinates, not null, unaffected)
-
applyForce
public void applyForce(com.jme3.math.Vector3f force, int nodeIndex) 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
public void applyRotation(com.jme3.math.Quaternion rotation) Rotate this body.- Parameters:
rotation
- the rotation to apply (not null, unaffected)
-
applyScale
public void applyScale(com.jme3.math.Vector3f factors) Scale this body.- Parameters:
factors
- the scale factor to apply to each axis (not null, unaffected)
-
applyTransform
public void applyTransform(com.jme3.math.Transform transform) Transform this body.- Parameters:
transform
- the transform to apply (not null, unaffected)
-
applyTranslation
public void applyTranslation(com.jme3.math.Vector3f offset) Translate this body.- Parameters:
offset
- the translation to apply to each axis (not null, unaffected)
-
clusterCenter
public com.jme3.math.Vector3f clusterCenter(int clusterIndex, com.jme3.math.Vector3f storeResult) 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
public com.jme3.math.Vector3f nodeLocation(int nodeIndex, com.jme3.math.Vector3f storeResult) 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
public com.jme3.math.Vector3f nodeNormal(int nodeIndex, com.jme3.math.Vector3f storeResult) 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
public com.jme3.math.Vector3f nodeVelocity(int nodeIndex, com.jme3.math.Vector3f storeResult) 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
public void setNodeVelocity(int nodeIndex, com.jme3.math.Vector3f velocity) 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
public void setPhysicsLocationDp(com.simsilica.mathd.Vec3d location) Directly relocate the center of this body's bounding box.- Parameters:
location
- the desired location (in physics-space coordinates, not null, 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
public void setVelocity(com.jme3.math.Vector3f velocity) 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
public void setWindVelocity(com.jme3.math.Vector3f velocity) 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
public com.jme3.math.Vector3f windVelocity(com.jme3.math.Vector3f storeResult) 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. -
boundingBox
public com.jme3.bounding.BoundingBox boundingBox(com.jme3.bounding.BoundingBox storeResult) 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)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned body 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 classPhysicsBody
- Parameters:
cloner
- the Cloner that's cloning this body (not null)original
- the instance from which this body was shallow-cloned (not null, unaffected)
-
getGravity
public com.jme3.math.Vector3f getGravity(com.jme3.math.Vector3f storeResult) 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
public com.jme3.math.Vector3f getPhysicsLocation(com.jme3.math.Vector3f storeResult) 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
public com.simsilica.mathd.Vec3d getPhysicsLocationDp(com.simsilica.mathd.Vec3d storeResult) 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
public com.jme3.math.Quaternion getPhysicsRotation(com.jme3.math.Quaternion storeResult) 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
public com.simsilica.mathd.Quatd getPhysicsRotationDp(com.simsilica.mathd.Quatd storeResult) 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
public com.jme3.math.Matrix3f getPhysicsRotationMatrix(com.jme3.math.Matrix3f storeResult) 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
public com.simsilica.mathd.Matrix3d getPhysicsRotationMatrixDp(com.simsilica.mathd.Matrix3d storeResult) 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
public com.jme3.math.Vector3f getScale(com.jme3.math.Vector3f storeResult) 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)
-
read
De-serialize this body from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classPhysicsCollisionObject
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
setDebugMeshNormals
public void setDebugMeshNormals(jme3utilities.MeshNormals newSetting) Alter which normals to include in new debug meshes.- Overrides:
setDebugMeshNormals
in classPhysicsCollisionObject
- Parameters:
newSetting
- an enum value (either None or Smooth)
-
setGravity
public void setGravity(com.jme3.math.Vector3f acceleration) 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
public void setPhysicsLocation(com.jme3.math.Vector3f location) 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)
-
write
Serialize this body to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classPhysicsCollisionObject
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-