public class MeshCollisionShape extends CollisionShape
Modifier and Type | Field and Description |
---|---|
protected long |
meshId
Unique identifier of the Bullet mesh.
|
protected long |
nativeBVHBuffer |
protected int |
numTriangles |
protected int |
numVertices |
protected java.nio.ByteBuffer |
triangleIndexBase |
protected int |
triangleIndexStride |
protected java.nio.ByteBuffer |
vertexBase |
protected int |
vertexStride |
margin, objectId, scale
Modifier | Constructor and Description |
---|---|
protected |
MeshCollisionShape()
No-argument constructor needed by SavableClassUtil.
|
|
MeshCollisionShape(java.nio.ByteBuffer indices,
java.nio.ByteBuffer vertices,
boolean memoryOptimized)
An advanced constructor.
|
|
MeshCollisionShape(Mesh mesh)
Instantiate a collision shape based on the specified JME mesh, optimized
for memory usage.
|
|
MeshCollisionShape(Mesh mesh,
boolean memoryOptimized)
Instantiate a collision shape based on the specified JME mesh.
|
Modifier and Type | Method and Description |
---|---|
void |
finalize()
Finalize this shape just before it is destroyed.
|
void |
read(JmeImporter im)
De-serialize this shape, for example when loading from a J3O file.
|
void |
write(JmeExporter ex)
Serialize this shape, for example when saving to a J3O file.
|
getDefaultMargin, getMargin, getObjectId, getScale, isNonMoving, setDefaultMargin, setMargin, setObjectId, setScale
protected int numVertices
protected int numTriangles
protected int vertexStride
protected int triangleIndexStride
protected java.nio.ByteBuffer triangleIndexBase
protected java.nio.ByteBuffer vertexBase
protected long meshId
protected long nativeBVHBuffer
protected MeshCollisionShape()
public MeshCollisionShape(Mesh mesh)
mesh
- the mesh on which to base the shape (not null)public MeshCollisionShape(Mesh mesh, boolean memoryOptimized)
memoryOptimized
determines if optimized instead of quantized
BVH will be used. Internally, memoryOptimized
BVH is slower
to calculate (~4x) but also smaller (~0.5x). It is preferable to use the
memory optimized version and then serialize the resulting
MeshCollisionshape as this will also save the generated BVH. An exception
can be procedurally / generated collision shapes, where the generation
time is more of a concern
mesh
- the mesh on which to base the shape (not null)memoryOptimized
- true to generate a memory-optimized BVH, false to
generate quantized BVHpublic MeshCollisionShape(java.nio.ByteBuffer indices, java.nio.ByteBuffer vertices, boolean memoryOptimized)
This constructor bypasses all copy logic normally used, this allows for faster Bullet shape generation when using procedurally generated Meshes.
indices
- the raw index buffervertices
- the raw vertex buffermemoryOptimized
- use quantized BVH, uses less memory, but slowerpublic void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
write
in class CollisionShape
ex
- exporter (not null)java.io.IOException
- from exporterpublic void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
read
in class CollisionShape
im
- importer (not null)java.io.IOException
- from importerpublic void finalize() throws java.lang.Throwable
finalize
in class CollisionShape
java.lang.Throwable
- ignored by the garbage collector