Class IndexBuffer

java.lang.Object
jme3utilities.lbj.IndexBuffer

public class IndexBuffer extends Object
Wrapper class for the index buffer of a mesh.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    IndexBuffer(int maxVertices, int capacity)
    Instantiate an IndexBuffer with a new direct, writable data buffer.
    protected
    IndexBuffer(Buffer dataBuffer)
    Instantiate an IndexBuffer by wrapping the specified data buffer.
  • Method Summary

    Modifier and Type
    Method
    Description
    Copy all the indices to a new direct buffer.
    createIndexBuffer(int maxVertices, int capacity)
    Create a mutable IndexBuffer with a new direct data buffer.
    protected int
    get()
    Read an index from the current read/write position, then increment the position.
    int
    get(int position)
    Read an index from the specified buffer position.
    protected Buffer
    Access the buffer data.
    boolean
    Test whether the buffer is direct.
    limit(int newLimit)
    Alter the limit.
    protected IndexBuffer
    Make the buffer immutable.
    protected IndexBuffer
    put(int index)
    Write the specified index at the current read/write position, then increment the position.
    put(int position, int index)
    Write the specified index at the specified buffer position.
    int
    Return the buffer's limit.
    protected void
    Verify that the buffer is still mutable.
    wrapIndexBuffer(Buffer dataBuffer)
    Create a mutable IndexBuffer by wrapping the specified data buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IndexBuffer

      protected IndexBuffer(Buffer dataBuffer)
      Instantiate an IndexBuffer by wrapping the specified data buffer.
      Parameters:
      dataBuffer - the data buffer to wrap (a ByteBuffer or ShortBuffer or IntBuffer, alias created)
    • IndexBuffer

      protected IndexBuffer(int maxVertices, int capacity)
      Instantiate an IndexBuffer with a new direct, writable data buffer.
      Parameters:
      maxVertices - one more than the highest index value (≥1)
      capacity - number of indices (≥0)
  • Method Details

    • copyBuffer

      public Buffer copyBuffer()
      Copy all the indices to a new direct buffer. The new buffer's position will be 0, its limit will be its capacity, its mark will be undefined.
      Returns:
      a new direct buffer
    • createIndexBuffer

      public static IndexBuffer createIndexBuffer(int maxVertices, int capacity)
      Create a mutable IndexBuffer with a new direct data buffer.
      Parameters:
      maxVertices - one more than the highest index value (≥1)
      capacity - number of indices (≥0)
      Returns:
      a new instance
    • get

      public int get(int position)
      Read an index from the specified buffer position. Does not alter the buffer's read/write position.
      Parameters:
      position - the position from which to read (≥0, <limit)
      Returns:
      the index that was read (≥0, <numVertices)
    • isDirect

      public boolean isDirect()
      Test whether the buffer is direct.
      Returns:
      true if direct, otherwise false
    • limit

      public IndexBuffer limit(int newLimit)
      Alter the limit. If the read/write position is past the new limit then it is set to the new limit.
      Parameters:
      newLimit - the desired limit position (≥0, ≤capacity);
      Returns:
      the (modified) current instance (for chaining)
    • put

      public IndexBuffer put(int position, int index)
      Write the specified index at the specified buffer position. Does not alter the buffer's read/write position.
      Parameters:
      position - the position to write to (≥0, <limit)
      index - the index to be written (≥0, <numVertices)
      Returns:
      the (modified) current instance (for chaining)
    • size

      public int size()
      Return the buffer's limit.
      Returns:
      the element count (≥0)
    • wrapIndexBuffer

      public static IndexBuffer wrapIndexBuffer(Buffer dataBuffer)
      Create a mutable IndexBuffer by wrapping the specified data buffer.
      Parameters:
      dataBuffer - the data buffer to wrap (not null, a ByteBuffer or ShortBuffer or IntBuffer, alias created)
      Returns:
      a new instance
    • get

      protected int get()
      Read an index from the current read/write position, then increment the position.
      Returns:
      the index that was read (≥0, <numVertices)
    • getBuffer

      protected Buffer getBuffer()
      Access the buffer data.
      Returns:
      the pre-existing buffer
    • makeImmutable

      protected IndexBuffer makeImmutable()
      Make the buffer immutable.
      Returns:
      the (modified) current instance (for chaining)
    • put

      protected IndexBuffer put(int index)
      Write the specified index at the current read/write position, then increment the position.
      Parameters:
      index - the index to be written (≥0, <numVertices)
      Returns:
      the (modified) current instance (for chaining)
    • verifyMutable

      protected void verifyMutable()
      Verify that the buffer is still mutable.