Package com.jme3.scene.mesh
Class IndexBuffer
java.lang.Object
com.jme3.scene.mesh.IndexBuffer
- Direct Known Subclasses:
IndexByteBuffer
,IndexIntBuffer
,IndexShortBuffer
,VirtualIndexBuffer
IndexBuffer
is an abstraction for integer index buffers,
it is used to retrieve indices without knowing in which format they
are stored (ushort or uint).-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic IndexBuffer
createIndexBuffer
(int vertexCount, int indexCount) Create an IndexBuffer with the specified capacity.abstract int
get()
Returns the vertex index for the current position.abstract int
get
(int i) Returns the vertex index for the given index in the index buffer.abstract Buffer
Returns the underlying data-type specificBuffer
.abstract VertexBuffer.Format
Returns the format of the data stored in this buffer.abstract IndexBuffer
put
(int value) Relative put method.abstract IndexBuffer
put
(int i, int value) Absolute put method.int
void
rewind()
abstract int
size()
Returns the size of the index buffer.static IndexBuffer
wrapIndexBuffer
(Buffer buf)
-
Constructor Details
-
IndexBuffer
public IndexBuffer()
-
-
Method Details
-
wrapIndexBuffer
-
createIndexBuffer
Create an IndexBuffer with the specified capacity.- Parameters:
vertexCount
- the number of vertices that will be indexed into (determines number of bits per element)indexCount
- the number of indices the IndexBuffer must hold (determines number of elements in the buffer)- Returns:
- a new, appropriately sized IndexBuffer, which may be an
IndexByteBuffer
, anIndexShortBuffer
, or anIndexIntBuffer
-
rewind
public void rewind()- See Also:
-
remaining
public int remaining()- Returns:
- the count (≥0)
- See Also:
-
get
public abstract int get()Returns the vertex index for the current position.- Returns:
- the index
-
get
public abstract int get(int i) Returns the vertex index for the given index in the index buffer.- Parameters:
i
- The index inside the index buffer- Returns:
- the index
-
put
Absolute put method.Puts the vertex index at the index buffer's index. Implementations may throw an
UnsupportedOperationException
if modifying the IndexBuffer is not supported (e.g. virtual index buffers).- Parameters:
i
- The buffer indexvalue
- The vertex index- Returns:
- This buffer
-
put
Relative put method.Puts the vertex index at the current position, then increments the position. Implementations may throw an
UnsupportedOperationException
if modifying the IndexBuffer is not supported (e.g. virtual index buffers).- Parameters:
value
- The vertex index- Returns:
- This buffer
-
size
public abstract int size()Returns the size of the index buffer.- Returns:
- the size of the index buffer.
-
getBuffer
Returns the underlying data-type specificBuffer
. Implementations may return null if there's no underlying buffer.- Returns:
- the underlying
Buffer
.
-
getFormat
Returns the format of the data stored in this buffer.This method can be used to set an
IndexBuffer
to aMesh
:mesh.setBuffer(Type.Index, 3, indexBuffer.getFormat(), indexBuffer);
- Returns:
- an enum value
-