Class IndexBuffer

java.lang.Object
com.jme3.scene.mesh.IndexBuffer
Direct Known Subclasses:
IndexByteBuffer, IndexIntBuffer, IndexShortBuffer, VirtualIndexBuffer

public abstract class IndexBuffer extends Object
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 Details

    • IndexBuffer

      public IndexBuffer()
  • Method Details

    • wrapIndexBuffer

      public static IndexBuffer wrapIndexBuffer(Buffer buf)
    • createIndexBuffer

      public static IndexBuffer createIndexBuffer(int vertexCount, int indexCount)
      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, an IndexShortBuffer, or an IndexIntBuffer
    • 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

      public abstract IndexBuffer put(int i, int value)
      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 index
      value - The vertex index
      Returns:
      This buffer
    • put

      public abstract IndexBuffer put(int value)
      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

      public abstract Buffer getBuffer()
      Returns the underlying data-type specific Buffer. Implementations may return null if there's no underlying buffer.
      Returns:
      the underlying Buffer.
    • getFormat

      public abstract VertexBuffer.Format getFormat()
      Returns the format of the data stored in this buffer.

      This method can be used to set an IndexBuffer to a Mesh:

       mesh.setBuffer(Type.Index, 3, 
           indexBuffer.getFormat(), indexBuffer);
       
      Returns:
      an enum value