Class CompoundMesh
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.infos.CompoundMesh
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
public class CompoundMesh
extends NativePhysicsObject
implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
A scalable mesh that combines multiple indexed meshes. Based on Bullet's
btTriangleIndexVertexArray
.-
Field Summary
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ConstructorDescriptionInstantiate an empty mesh.CompoundMesh
(CompoundMesh original) Copy an existing mesh.CompoundMesh
(CompoundMesh base, com.jme3.math.Vector3f offset) Instantiate a mesh by applying an offset to an existing mesh.CompoundMesh
(com.jme3.scene.Mesh... jmeMeshes) Instantiate a mesh based on the specified JME mesh(es). -
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(IndexedMesh submesh) Add a submesh to this mesh.void
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned mesh into a deep-cloned one, using the specified Cloner and original to resolve copied fields.int
Count how many submeshes are in this mesh.int
Count how many triangles are in this mesh.int
Count how many vertices are in this mesh.com.jme3.math.Vector3f
getScale
(com.jme3.math.Vector3f storeResult) Copy the scale factors.getSubmesh
(int index) Access the specified submesh.jmeClone()
Create a shallow clone for the JME cloner.void
maxMin
(com.jme3.math.Vector3f storeMaxima, com.jme3.math.Vector3f storeMinima) Find the maximum and minimum coordinates for each local axis among the scaled vertices in this mesh.void
read
(com.jme3.export.JmeImporter importer) De-serialize this mesh from the specified importer, for example when loading from a J3O file.void
setScale
(com.jme3.math.Vector3f scale) Alter the scale factors.split
(com.jme3.math.Triangle scaledTriangle) Attempt to divide this mesh into 2 meshes.void
write
(com.jme3.export.JmeExporter exporter) Serialize this mesh to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, toString, unassignNativeObject
-
Field Details
-
logger
message logger for this class
-
-
Constructor Details
-
CompoundMesh
public CompoundMesh()Instantiate an empty mesh. -
CompoundMesh
Copy an existing mesh.- Parameters:
original
- the mesh to copy (not null, unaffected)
-
CompoundMesh
Instantiate a mesh by applying an offset to an existing mesh.- Parameters:
base
- the mesh to use as a base (not null, unaffected)offset
- the offset to add to the scaled vertex positions (not null, unaffected)
-
CompoundMesh
public CompoundMesh(com.jme3.scene.Mesh... jmeMeshes) Instantiate a mesh based on the specified JME mesh(es).- Parameters:
jmeMeshes
- the JME mesh(es) (all non-null, modes=Triangles/TriangleStrip/TriangleFan, unaffected)
-
-
Method Details
-
add
Add a submesh to this mesh.- Parameters:
submesh
- (not null, alias created)
-
countSubmeshes
public int countSubmeshes()Count how many submeshes are in this mesh.- Returns:
- the count (≥0)
-
countTriangles
public int countTriangles()Count how many triangles are in this mesh.- Returns:
- the count (≥0)
-
countVertices
public int countVertices()Count how many vertices are in this mesh.- Returns:
- the count (≥0)
-
getScale
public com.jme3.math.Vector3f getScale(com.jme3.math.Vector3f storeResult) Copy the scale factors.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the scale factor for each local axis (either storeResult or a new vector, not null)
-
getSubmesh
Access the specified submesh.- Parameters:
index
- the index of the desired submesh (in the order the submeshes were added, ≥0)- Returns:
- the pre-existing instance (not null)
-
maxMin
public void maxMin(com.jme3.math.Vector3f storeMaxima, com.jme3.math.Vector3f storeMinima) Find the maximum and minimum coordinates for each local axis among the scaled vertices in this mesh.- Parameters:
storeMaxima
- storage for the maxima (not null, modified)storeMinima
- storage for the minima (not null, modified)
-
setScale
public void setScale(com.jme3.math.Vector3f scale) Alter the scale factors.- Parameters:
scale
- the desired scale factor for each local axis (not null, no negative component, unaffected, default=(1,1,1))
-
split
Attempt to divide this mesh into 2 meshes.- Parameters:
scaledTriangle
- to define the splitting plane (in scaled coordinates, not null, unaffected)- Returns:
- a pair of meshes, the first mesh generated by the plane's minus side and the 2nd mesh generated by its plus side; either mesh may be null, indicating an empty mesh
-
cloneFields
Callback fromCloner
to convert this shallow-cloned mesh into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Parameters:
cloner
- the Cloner that's cloning this mesh (not null)original
- the instance from which this mesh was shallow-cloned (not null, unaffected)
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClone
in interfacecom.jme3.util.clone.JmeCloneable
- Returns:
- a new instance
-
read
De-serialize this mesh from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
write
Serialize this mesh to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-