Package com.jme3.bullet.control
Class SoftBodyControl
java.lang.Object
com.jme3.bullet.control.AbstractPhysicsControl
com.jme3.bullet.control.SoftBodyControl
- All Implemented Interfaces:
PhysicsControl,com.jme3.export.Savable,com.jme3.scene.control.Control,com.jme3.util.clone.JmeCloneable,Cloneable
A PhysicsControl to link a PhysicsSoftBody to a Spatial.
-
Field Summary
FieldsFields inherited from class com.jme3.bullet.control.AbstractPhysicsControl
added, logger -
Constructor Summary
ConstructorsConstructorDescriptionInstantiate an enabled Control for a soft body based on a single Geometry.SoftBodyControl(boolean localPhysics, boolean updateNormals, boolean mergeVertices) Instantiate an enabled Control for a soft body based on a single Geometry.SoftBodyControl(boolean localPhysics, boolean updateNormals, boolean mergeVertices, UseTriangles useTriangles) Instantiate an enabled Control for a soft body based on a single Geometry. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd all managed physics objects to the PhysicsSpace.voidcloneFields(com.jme3.util.clone.Cloner cloner, Object original) Callback fromClonerto convert this shallow-cloned Control into a deep-cloned one, using the specified Cloner and original to resolve copied fields.protected voidcreateSpatialData(com.jme3.scene.Spatial spatial) Create spatial-dependent data.getBody()Access the soft body managed by this Control.voidread(com.jme3.export.JmeImporter importer) De-serialize this Control from the specified importer, for example when loading from a J3O file.protected voidRemove all managed physics objects from the PhysicsSpace.protected voidremoveSpatialData(com.jme3.scene.Spatial spatial) Destroy spatial-dependent data.voidsetPhysicsLocation(com.jme3.math.Vector3f location) Translate the soft body to the specified location.protected voidsetPhysicsRotation(com.jme3.math.Quaternion orientation) Rotate the soft body to the specified orientation.voidsetPhysicsSpace(PhysicsSpace newSpace) If enabled, add this control's physics object to the specified PhysicsSpace.voidupdate(float tpf) Update this Control.voidwrite(com.jme3.export.JmeExporter exporter) Serialize this Control to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.control.AbstractPhysicsControl
applyPhysicsTransform, cloneForSpatial, getPhysicsSpace, getSpatial, getSpatialRotation, getSpatialTranslation, isApplyPhysicsLocal, isEnabled, jmeClone, render, setApplyPhysicsLocal, setEnabled, setSpatial
-
Field Details
-
logger2
message logger for this class
-
-
Constructor Details
-
SoftBodyControl
public SoftBodyControl()Instantiate an enabled Control for a soft body based on a single Geometry. Merge duplicate vertices, match physics-space coordinates to world coordinates, and update mesh normals if present. -
SoftBodyControl
public SoftBodyControl(boolean localPhysics, boolean updateNormals, boolean mergeVertices) Instantiate an enabled Control for a soft body based on a single Geometry.- Parameters:
localPhysics- true → match physics-space coordinates to the spatial's local coordinates, false → match physics-space coordinates to world coordinatesupdateNormals- true→update mesh normals if present, false→never update mesh normals (default=true)mergeVertices- true→merge duplicate vertices in the soft body, false→don't merge duplicate vertices (default=true), seeNativeSoftBodyUtil.generateIndexMap(java.nio.FloatBuffer)
-
SoftBodyControl
public SoftBodyControl(boolean localPhysics, boolean updateNormals, boolean mergeVertices, UseTriangles useTriangles) Instantiate an enabled Control for a soft body based on a single Geometry.- Parameters:
localPhysics- true → match physics-space coordinates to the spatial's local coordinates, false → match physics-space coordinates to world coordinatesupdateNormals- true→update mesh normals if present, false→never update mesh normals (default=true)mergeVertices- true→merge duplicate vertices in the soft body, false→don't merge duplicate vertices (default=true), seeNativeSoftBodyUtil.generateIndexMap(java.nio.FloatBuffer)useTriangles- how to use triangle indices (not null, default=FacesOnly)
-
-
Method Details
-
getBody
Access the soft body managed by this Control.- Returns:
- the pre-existing instance, or null if the Control is not added to a Spatial
-
addPhysics
protected void addPhysics()Add all managed physics objects to the PhysicsSpace.- Specified by:
addPhysicsin classAbstractPhysicsControl
-
cloneFields
Callback fromClonerto convert this shallow-cloned Control into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFieldsin interfacecom.jme3.util.clone.JmeCloneable- Overrides:
cloneFieldsin classAbstractPhysicsControl- Parameters:
cloner- the Cloner that's cloning this Control (not null, modified)original- the instance from which this Control was shallow-cloned (not null)
-
createSpatialData
protected void createSpatialData(com.jme3.scene.Spatial spatial) Create spatial-dependent data. Invoked when this Control is added to a Spatial.- Specified by:
createSpatialDatain classAbstractPhysicsControl- Parameters:
spatial- the controlled Spatial (not null, alias created)
-
read
De-serialize this Control from the specified importer, for example when loading from a J3O file.- Specified by:
readin interfacecom.jme3.export.Savable- Overrides:
readin classAbstractPhysicsControl- Parameters:
importer- (not null)- Throws:
IOException- from the importer
-
removePhysics
protected void removePhysics()Remove all managed physics objects from the PhysicsSpace.- Specified by:
removePhysicsin classAbstractPhysicsControl
-
removeSpatialData
protected void removeSpatialData(com.jme3.scene.Spatial spatial) Destroy spatial-dependent data. Invoked when this Control is removed from its Spatial.- Specified by:
removeSpatialDatain classAbstractPhysicsControl- Parameters:
spatial- the Spatial to which this Control was added (unused)
-
setPhysicsLocation
public void setPhysicsLocation(com.jme3.math.Vector3f location) Translate the soft body to the specified location.- Specified by:
setPhysicsLocationin classAbstractPhysicsControl- Parameters:
location- the desired location (in physics-space coordinates, not null, finite, unaffected)
-
setPhysicsRotation
protected void setPhysicsRotation(com.jme3.math.Quaternion orientation) Rotate the soft body to the specified orientation.- Specified by:
setPhysicsRotationin classAbstractPhysicsControl- Parameters:
orientation- the desired orientation (in physics-space coordinates, not null, unaffected)
-
setPhysicsSpace
If enabled, add this control's physics object to the specified PhysicsSpace. If not enabled, alter where the object would be added. The object is removed from any other space it's currently in.- Specified by:
setPhysicsSpacein interfacePhysicsControl- Overrides:
setPhysicsSpacein classAbstractPhysicsControl- Parameters:
newSpace- where to add, or null to simply remove
-
update
public void update(float tpf) Update this Control. Invoked once per frame during the logical-state update, provided the Control is added to a scene. Do not invoke directly from user code.- Parameters:
tpf- the time interval between frames (in seconds, ≥0)
-
write
Serialize this Control to the specified exporter, for example when saving to a J3O file.- Specified by:
writein interfacecom.jme3.export.Savable- Overrides:
writein classAbstractPhysicsControl- Parameters:
exporter- (not null)- Throws:
IOException- from the exporter
-