Class IndexedMesh
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.infos.IndexedMesh
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
public class IndexedMesh
extends NativePhysicsObject
implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
An indexed triangle mesh based on Bullet's
btIndexedMesh
. Immutable
except for read(com.jme3.export.JmeImporter)
.-
Field Summary
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.IndexedMesh
(CollisionShape shape, int meshResolution) Instantiate a IndexedMesh to visualize the specified collision shape.IndexedMesh
(CollisionShape shape, int resolution, boolean dedup) Instantiate an IndexedMesh from the debug mesh of the specified CollisionShape.IndexedMesh
(com.jme3.math.Vector3f[] positionArray, int[] indexArray) Instantiate an IndexedMesh based on the specified positions and indices.IndexedMesh
(com.jme3.scene.Mesh jmeMesh) Instantiate an IndexedMesh based on the specified JME mesh, without transforming coordinates.IndexedMesh
(com.jme3.scene.Mesh jmeMesh, com.jme3.math.Transform transform) Instantiate an IndexedMesh based on the specified JME mesh and coordinate transform.IndexedMesh
(FloatBuffer buffer) Instantiate an IndexedMesh based on the specified vertex positions.IndexedMesh
(FloatBuffer positionBuffer, IntBuffer indexBuffer) Instantiate an IndexedMesh based on the specified positions and indices. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Copy the triangle indices.void
copyTriangle
(int triangleIndex, com.jme3.math.Triangle destination) Copy the vertex positions of the specified triangle.Copy the unindexed triangle vertices to a new buffer.Copy the vertex positions to a new buffer.int
Count how many triangles are in this mesh.int
Count how many vertices are in this mesh.jme3utilities.math.VectorSet
Return the set of distinct vertices.com.jme3.math.Vector3f[]
footprint
(com.jme3.math.Transform meshToWorld) Estimate the footprint of the mesh.jmeClone()
Create a shallow clone for the JME cloner.float
maxDistance
(com.jme3.math.Transform meshToWorld) Calculate how far the mesh extends from some origin.void
maxMin
(com.jme3.math.Vector3f storeMaxima, com.jme3.math.Vector3f storeMinima) Find the maximum and minimum coordinates for each axis among the 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.split
(com.jme3.math.Plane splittingPlane) Attempt to divide this mesh into 2 meshes.float
Calculate the (one-sided) surface area of the mesh.float
Calculate volume of the mesh, assuming it's both closed and convex.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
-
IndexedMesh
protected IndexedMesh()No-argument constructor needed by SavableClassUtil. -
IndexedMesh
Instantiate an IndexedMesh from the debug mesh of the specified CollisionShape.- Parameters:
shape
- the input shape (not null, unaffected)resolution
- 0→low, 1→high for convex shapes, 2→high for all shapesdedup
- true→deduplicate vertices, false→don't deduplicate
-
IndexedMesh
public IndexedMesh(com.jme3.scene.Mesh jmeMesh) Instantiate an IndexedMesh based on the specified JME mesh, without transforming coordinates.- Parameters:
jmeMesh
- the input JME mesh (not null, unaffected, mode=Triangles/TriangleFan/TriangleStrip)
-
IndexedMesh
public IndexedMesh(com.jme3.scene.Mesh jmeMesh, com.jme3.math.Transform transform) Instantiate an IndexedMesh based on the specified JME mesh and coordinate transform.- Parameters:
jmeMesh
- the input JME mesh (not null, unaffected, mode=Triangles/TriangleFan/TriangleStrip)transform
- the Transform to apply to vertex positions (unaffected) or null to use untransformed vertex positions
-
IndexedMesh
public IndexedMesh(com.jme3.math.Vector3f[] positionArray, int[] indexArray) Instantiate an IndexedMesh based on the specified positions and indices.- Parameters:
positionArray
- (not null, unaffected)indexArray
- (not null, unaffected, length a multiple of 3)
-
IndexedMesh
Instantiate an IndexedMesh based on the specified vertex positions. An index will be assigned to each distinct position.- Parameters:
buffer
- the vertex positions of a non-indexed triangle mesh (not null, flipped, limit a multiple of 9, unaffected)
-
IndexedMesh
Instantiate an IndexedMesh based on the specified positions and indices.- Parameters:
positionBuffer
- (not null, not flipped, length a multiple of 3, alias created)indexBuffer
- (not null, not flipped, length a multiple of 3, alias created)
-
IndexedMesh
Instantiate a IndexedMesh to visualize the specified collision shape.- Parameters:
shape
- shape to visualize (not null, not compound, unaffected)meshResolution
- 0→low, 1→high for convex shapes, 2→high for all shapes
-
-
Method Details
-
copyIndices
Copy the triangle indices.- Returns:
- a new, direct, unflipped buffer
-
copyTriangle
public void copyTriangle(int triangleIndex, com.jme3.math.Triangle destination) Copy the vertex positions of the specified triangle.- Parameters:
triangleIndex
- the index of the source triangle (≥0)destination
- storage for the result (not null, modified)
-
copyTriangles
Copy the unindexed triangle vertices to a new buffer.- Returns:
- a new, direct, unflipped buffer
-
copyVertexPositions
Copy the vertex positions to a new buffer.- Returns:
- a new, direct, unflipped buffer
-
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)
-
distinctVertices
public jme3utilities.math.VectorSet distinctVertices()Return the set of distinct vertices.- Returns:
- a new instance of
VectorSet
-
footprint
public com.jme3.math.Vector3f[] footprint(com.jme3.math.Transform meshToWorld) Estimate the footprint of the mesh.- Parameters:
meshToWorld
- the world transform to use (not null, unaffected)- Returns:
- a new array of corner locations (in world coordinates)
-
maxDistance
public float maxDistance(com.jme3.math.Transform meshToWorld) Calculate how far the mesh extends from some origin.- Parameters:
meshToWorld
- the transform to apply to vertex locations (not null, unaffected)- Returns:
- the maximum length of the transformed vectors (≥0)
-
maxMin
public void maxMin(com.jme3.math.Vector3f storeMaxima, com.jme3.math.Vector3f storeMinima) Find the maximum and minimum coordinates for each axis among the vertices in this mesh.- Parameters:
storeMaxima
- storage for the maxima (not null, modified)storeMinima
- storage for the minima (not null, modified)
-
split
Attempt to divide this mesh into 2 meshes.- Parameters:
splittingPlane
- the splitting plane (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
-
surfaceArea
public float surfaceArea()Calculate the (one-sided) surface area of the mesh.- Returns:
- the area (in square mesh units, ≥0)
-
volumeConvex
public float volumeConvex()Calculate volume of the mesh, assuming it's both closed and convex.- Returns:
- the volume (in cubic mesh units, ≥0)
-
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
-