Package jme3utilities.lbj
Class IndexBuffer
java.lang.Object
jme3utilities.lbj.IndexBuffer
Wrapper class for the index buffer of a mesh.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedIndexBuffer(int maxVertices, int capacity) Instantiate an IndexBuffer with a new direct, writable data buffer.protectedIndexBuffer(Buffer dataBuffer) Instantiate an IndexBuffer by wrapping the specified data buffer. -
Method Summary
Modifier and TypeMethodDescriptionCopy all the indices to a new direct buffer.static IndexBuffercreateIndexBuffer(int maxVertices, int capacity) Create a mutable IndexBuffer with a new direct data buffer.protected intget()Read an index from the current read/write position, then increment the position.intget(int position) Read an index from the specified buffer position.protected BufferAccess the buffer data.booleanisDirect()Test whether the buffer is direct.limit(int newLimit) Alter the limit.protected IndexBufferMake the buffer immutable.protected IndexBufferput(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.intsize()Return the buffer's limit.protected voidVerify that the buffer is still mutable.static IndexBufferwrapIndexBuffer(Buffer dataBuffer) Create a mutable IndexBuffer by wrapping the specified data buffer.
-
Constructor Details
-
IndexBuffer
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
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
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:
trueif direct, otherwise false
-
limit
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
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
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
Access the buffer data.- Returns:
- the pre-existing buffer
-
makeImmutable
Make the buffer immutable.- Returns:
- the (modified) current instance (for chaining)
-
put
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.
-