public class PhysicsSoftBody extends PhysicsBody
| Modifier and Type | Field and Description |
|---|---|
static java.util.logging.Logger |
logger2
message logger for this class
|
massForStaticCOLLISION_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, loggerloggerN| Modifier | Constructor and Description |
|---|---|
|
PhysicsSoftBody()
Instantiate an empty soft body.
|
protected |
PhysicsSoftBody(boolean unused)
Instantiate an uninitialized soft body, for internal use.
|
| Modifier and Type | Method and Description |
|---|---|
void |
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(java.nio.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(BoundingBox storeResult)
Calculate the axis-aligned bounding box for this body.
|
Vector3f |
clusterCenter(int clusterIndex,
Vector3f storeResult)
Copy the center location of the indexed cluster.
|
java.nio.FloatBuffer |
copyClusterCenters(java.nio.FloatBuffer storeResult)
Copy the center-of-mass locations of all clusters in this body.
|
java.nio.FloatBuffer |
copyClusterMasses(java.nio.FloatBuffer storeResult)
Copy the masses of all clusters in this body.
|
java.nio.FloatBuffer |
copyClusterVelocities(java.nio.FloatBuffer storeResult)
Copy the (linear) velocities of all clusters in this body.
|
java.nio.IntBuffer |
copyFaces(java.nio.IntBuffer storeResult)
Copy the node indices of all faces in this body.
|
java.nio.IntBuffer |
copyLinks(java.nio.IntBuffer storeResult)
Copy the node indices of all links in this body.
|
java.nio.FloatBuffer |
copyLocations(java.nio.FloatBuffer storeResult)
Copy the locations of all nodes in this body.
|
java.nio.FloatBuffer |
copyMasses(java.nio.FloatBuffer storeResult)
Copy the masses of all nodes in this body.
|
java.nio.FloatBuffer |
copyNormals(java.nio.FloatBuffer storeResult)
Copy the normal vectors of all nodes in this body.
|
java.nio.IntBuffer |
copyTetras(java.nio.IntBuffer storeResult)
Copy the node indices of all tetrahedra in this body.
|
java.nio.FloatBuffer |
copyVelocities(java.nio.FloatBuffer storeResult)
Copy the (linear) velocities of all nodes in this body.
|
int |
countClusters()
Count the clusters in this body.
|
int |
countFaces()
Count the faces in this body.
|
int |
countLinks()
Count the links in this body.
|
int |
countNodes()
Count the nodes in this body.
|
int |
countNodesInCluster(int clusterIndex)
Count the nodes in the indexed cluster.
|
int |
countPinnedNodes()
Count the pinned nodes in this body.
|
int |
countTetras()
Count the tetrahedra in this body.
|
boolean |
cutLink(int nodeIndex0,
int nodeIndex1,
float cutLocation)
Cut a pre-existing link in this body.
|
protected void |
destroySoftBody()
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 |
generateClusters()
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 |
get(Cluster parameter,
int clusterIndex)
Read the specified parameter of the indexed cluster.
|
Vector3f |
getGravity(Vector3f storeResult)
Copy this body's gravitational acceleration.
|
float |
getMass()
Determine the total mass of this body.
|
Vector3f |
getPhysicsLocation(Vector3f storeResult)
Locate the center of this body's axis-aligned bounding box.
|
Vec3d |
getPhysicsLocationDp(Vec3d storeResult)
Locate the center of this body's axis-aligned bounding box.
|
Quaternion |
getPhysicsRotation(Quaternion storeResult)
Copy the orientation (rotation) of this body to a Quaternion.
|
Quatd |
getPhysicsRotationDp(Quatd storeResult)
Copy the orientation (rotation) of this body to a Quatd.
|
Matrix3f |
getPhysicsRotationMatrix(Matrix3f storeResult)
Copy the orientation of this body (the basis of its local coordinate
system) to a Matrix3f.
|
Matrix3d |
getPhysicsRotationMatrixDp(Matrix3d storeResult)
Copy the orientation of this body (the basis of its local coordinate
system) to a Matrix3d.
|
Vector3f |
getScale(Vector3f storeResult)
Copy the scale factors of this object.
|
SoftBodyConfig |
getSoftConfig()
Access the SoftBodyConfig of this body.
|
SoftBodyMaterial |
getSoftMaterial()
Access the Material of this body.
|
SoftBodyWorldInfo |
getWorldInfo()
Access the world info.
|
protected void |
initDefault()
Reinitialize the btSoftBody to the default values.
|
boolean |
isCollisionAllowed(long pcoId)
Test whether collisions are allowed between this body and the identified
collision object.
|
boolean |
isEmpty()
Test whether this body is empty.
|
boolean |
isWorldInfoProtected()
Test whether this body's world info should be replaced when added to a
space.
|
java.nio.IntBuffer |
listNodesInCluster(int clusterIndex,
java.nio.IntBuffer storeResult)
List all nodes in the indexed cluster.
|
float |
margin()
Read the collision margin of this body.
|
protected void |
newEmptySoftBody()
Create an empty
btSoftBody for this PhysicsSoftBody, using the
pre-existing worldInfo. |
Vector3f |
nodeLocation(int nodeIndex,
Vector3f storeResult)
Copy the location of the indexed node.
|
float |
nodeMass(int nodeIndex)
Read the mass of the indexed node.
|
Vector3f |
nodeNormal(int nodeIndex,
Vector3f storeResult)
Copy the normal vector of the indexed node.
|
Vector3f |
nodeVelocity(int nodeIndex,
Vector3f storeResult)
Copy the velocity of the indexed node.
|
void |
randomizeConstraints()
Randomize constraints to reduce solver bias.
|
void |
releaseAllClusters()
Release all clusters.
|
void |
releaseCluster(int clusterIndex)
Release the indexed cluster.
|
void |
resetRestingLengths()
Set the resting lengths of all links to their current lengths.
|
float |
restingLengthsScale()
Read the scale factor for resting lengths.
|
void |
set(Cluster parameter,
int clusterIndex,
float value)
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.
|
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(java.nio.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(java.nio.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(java.nio.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 semantics
|
void |
setVolumeMass(float mass)
Set volume mass (using tetrahedra) TODO clarify semantics
|
void |
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.
|
Vector3f |
windVelocity(Vector3f storeResult)
Copy the wind velocity.
|
addJoint, countJoints, getDeactivationDeadline, isDeactivationEnabled, listJoints, removeJoint, setDeactivationDeadline, setDeactivationEnabledactivate, 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, userIndex3compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, unassignNativeObjectpublic static final java.util.logging.Logger logger2
public PhysicsSoftBody()
protected PhysicsSoftBody(boolean unused)
unused - to distinguish from the no-arg constructorpublic void addVelocity(Vector3f velocity)
velocity - the velocity to add (in physics-space coordinates, not
null, unaffected)public void addVelocity(Vector3f velocity, int nodeIndex)
velocity - the velocity to add (in physics-space coordinates, not
null, unaffected)nodeIndex - which node to add it to (≥0, <numNodes)public void appendFaces(IndexBuffer nodeIndices)
nodeIndices - a face is created for every 3 indices in this buffer
(not null, direct, size a multiple of 3)public void appendLinks(IndexBuffer nodeIndices)
nodeIndices - a link is created for each pair of indices in this
buffer (not null, direct, size a multiple of 2)public void appendNodes(java.nio.FloatBuffer nodeLocations)
nodeLocations - a node is created for every 3 floats in this buffer
(not null, direct, limit a multiple of 3)public void appendTetras(IndexBuffer tetrahedra)
tetrahedra - a tetrahedron is created for every 4 indices in this
buffer (not null, direct, size a multiple of 4)public void applyForce(Vector3f force)
force - the force to add (in physics-space coordinates, not null,
unaffected)public void applyForce(Vector3f force, int nodeIndex)
force - the force to add (in physics-space coordinates, not null,
unaffected)nodeIndex - which node to add it to (≥0, <numNodes)public void applyRotation(Quaternion rotation)
rotation - the rotation to apply (not null, unaffected)public void applyScale(Vector3f factors)
factors - the scale factor to apply to each axis (not null,
unaffected)public void applyTransform(Transform transform)
transform - the transform to apply (not null, unaffected)public void applyTranslation(Vector3f offset)
offset - the translation to apply to each axis (not null,
unaffected)public Vector3f clusterCenter(int clusterIndex, Vector3f storeResult)
clusterIndex - which cluster (≥0, <numClusters)storeResult - storage for the result (modified if not null)public java.nio.FloatBuffer copyClusterCenters(java.nio.FloatBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.FloatBuffer copyClusterMasses(java.nio.FloatBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.FloatBuffer copyClusterVelocities(java.nio.FloatBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.IntBuffer copyFaces(java.nio.IntBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.IntBuffer copyLinks(java.nio.IntBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.FloatBuffer copyLocations(java.nio.FloatBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.FloatBuffer copyMasses(java.nio.FloatBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.FloatBuffer copyNormals(java.nio.FloatBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.IntBuffer copyTetras(java.nio.IntBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic java.nio.FloatBuffer copyVelocities(java.nio.FloatBuffer storeResult)
storeResult - storage for the result (direct, modified) or nullpublic final int countClusters()
public final int countFaces()
public final int countLinks()
public final int countNodes()
public int countNodesInCluster(int clusterIndex)
clusterIndex - which cluster (≥0, <numClusters)public final int countPinnedNodes()
public final int countTetras()
public boolean cutLink(int nodeIndex0,
int nodeIndex1,
float cutLocation)
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 linkpublic void generateBendingConstraints(int numHops,
SoftBodyMaterial material)
numHops - (in links, ≥2)material - the material for appending links (not null)public void generateClusters()
public void generateClusters(int k,
int maxIterations)
k - (≥1, <numNodes)maxIterations - the maximum number of iterations (>0,
default=8192)public float get(Cluster parameter, int clusterIndex)
parameter - which parameter to read (not null)clusterIndex - which cluster (≥0, <numClusters)public SoftBodyConfig getSoftConfig()
public SoftBodyMaterial getSoftMaterial()
public SoftBodyWorldInfo getWorldInfo()
public boolean isCollisionAllowed(long pcoId)
pcoId - the native ID of the other collision object (not zero)public final boolean isEmpty()
public boolean isWorldInfoProtected()
public java.nio.IntBuffer listNodesInCluster(int clusterIndex,
java.nio.IntBuffer storeResult)
clusterIndex - which cluster (≥0, <numClusters)storeResult - storage for the result (direct, modified) or nullpublic float margin()
public Vector3f nodeLocation(int nodeIndex, Vector3f storeResult)
nodeIndex - which node (≥0, <numNodes)storeResult - storage for the result (modified if not null)public float nodeMass(int nodeIndex)
nodeIndex - which node to read (≥0, <numNodes)public Vector3f nodeNormal(int nodeIndex, Vector3f storeResult)
nodeIndex - which node (≥0, <numNodes)storeResult - storage for the result (modified if not null)public Vector3f nodeVelocity(int nodeIndex, Vector3f storeResult)
nodeIndex - which node (≥0, <numNodes)storeResult - storage for the result (modified if not null)public void randomizeConstraints()
public void releaseAllClusters()
public void releaseCluster(int clusterIndex)
clusterIndex - which cluster to release (≥0, <numClusters)public void resetRestingLengths()
public float restingLengthsScale()
public void set(Cluster parameter, int clusterIndex, float value)
parameter - which parameter to alter (not null)clusterIndex - which cluster (≥0, <numClusters)value - the desired valuepublic final void setMargin(float margin)
margin - the desired margin distance (in physics-space units, >0)public void setMassByArea(float totalMass)
totalMass - the desired total mass (>0)public void setMassByCurrent(float totalMass)
totalMass - the desired total mass (>0, default=numNodes)public void setMasses(java.nio.FloatBuffer masses)
masses - a direct buffer containing the desired masses (not null,
all elements ≥0)public void setMassFromDensity(float density)
density - the desired density (>0)public void setNodeMass(int nodeIndex,
float mass)
nodeIndex - which node to modify (≥0, <numNodes)mass - the desired mass (≥0, default=1)public void setNodeVelocity(int nodeIndex,
Vector3f velocity)
nodeIndex - which node to modify (≥0, <numNodes)velocity - the desired velocity vector (not null, unaffected)public void setNormals(java.nio.FloatBuffer normals)
normals - a direct buffer containing the desired normals (in
physics-space coordinates, not null, unaffected)public void setPhysicsLocationDp(Vec3d location)
location - the desired location (in physics-space coordinates, not
null, finite, unaffected)public void setPose(boolean setVolumePose,
boolean setFramePose)
setVolumePose - true→alter the volume pose, false→ don't
alter itsetFramePose - true→alter the frame pose, false→ don't
alter itpublic void setProtectWorldInfo(boolean newState)
newState - true to preserve the world info, false to allow it to be
replaced (default=false)public void setRestingLengthScale(float scale)
scale - the desired scale factorpublic void setVelocities(java.nio.FloatBuffer velocities)
velocities - a direct buffer containing the desired velocities (in
physics-space coordinates, not null, unaffected)public void setVelocity(Vector3f velocity)
velocity - the desired velocity vector (in physics-space
coordinates, not null, unaffected)public void setVolumeDensity(float density)
density - the desired densitypublic void setVolumeMass(float mass)
mass - the desired masspublic void setWindVelocity(Vector3f velocity)
velocity - the desired velocity vector (in physics-space
coordinates, not null, unaffected)public void setWorldInfo(SoftBodyWorldInfo worldInfo)
Invoke this method after adding the body to a space. Adding a body to a space may replace its world info.
worldInfo - the desired SoftBodyWorldInfo (not null, alias created)public float volume()
public Vector3f windVelocity(Vector3f storeResult)
storeResult - storage for the result (modified if not null)protected void destroySoftBody()
protected void initDefault()
protected void newEmptySoftBody()
btSoftBody for this PhysicsSoftBody, using the
pre-existing worldInfo. The pre-existing btSoftBody (if any) will be
destroyed.protected void setConfig(SoftBodyConfig newConfig)
newConfig - the desired configurationprotected void setWorldInfoInternal(SoftBodyWorldInfo newInfo)
newInfo - the desired infopublic BoundingBox boundingBox(BoundingBox storeResult)
boundingBox in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public Vector3f getGravity(Vector3f storeResult)
getGravity in class PhysicsBodystoreResult - storage for the result (modified if not null)public float getMass()
getMass in class PhysicsBodypublic Vector3f getPhysicsLocation(Vector3f storeResult)
getPhysicsLocation in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public Vec3d getPhysicsLocationDp(Vec3d storeResult)
getPhysicsLocationDp in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public Quaternion getPhysicsRotation(Quaternion storeResult)
getPhysicsRotation in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public Quatd getPhysicsRotationDp(Quatd storeResult)
getPhysicsRotationDp in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public Matrix3f getPhysicsRotationMatrix(Matrix3f storeResult)
getPhysicsRotationMatrix in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public Matrix3d getPhysicsRotationMatrixDp(Matrix3d storeResult)
getPhysicsRotationMatrixDp in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public Vector3f getScale(Vector3f storeResult)
getScale in class PhysicsCollisionObjectstoreResult - storage for the result (modified if not null)public void setGravity(Vector3f acceleration)
Invoke this method after adding the body to a space. Adding a body to a space may override its gravity.
setGravity in class PhysicsBodyacceleration - the desired acceleration vector (in physics-space
coordinates, not null, unaffected)public void setMass(float totalMass)
setMass in class PhysicsBodytotalMass - the desired total mass (>0, default=numNodes)public void setPhysicsLocation(Vector3f location)
setPhysicsLocation in class PhysicsBodylocation - the desired location (in physics-space coordinates, not
null, finite, unaffected)