Package com.ardor3d.util.geom
Class BufferUtils
java.lang.Object
com.ardor3d.util.geom.BufferUtils
BufferUtils
is a helper class for generating nio buffers from ardor3d data classes such as Vectors and
ColorRGBA.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addInBuffer
(ReadOnlyVector2 toAdd, FloatBuffer buf, int index) Add to a Vector2 in-buffer.static void
addInBuffer
(ReadOnlyVector3 toAdd, FloatBuffer buf, int index) Add to a Vector3 in-buffer.static void
addInBuffer
(ReadOnlyVector4 toAdd, FloatBuffer buf, int index) Add to a Vector4 in-buffer.static IndexBufferData
<?> clone
(IndexBufferData<?> buf) Creates a new IndexBufferData with the same contents as the given IndexBufferData.static ByteBuffer
clone
(ByteBuffer buf) Creates a new ByteBuffer with the same contents as the given ByteBuffer.static DoubleBuffer
clone
(DoubleBuffer buf) Creates a new DoubleBuffer with the same contents as the given DoubleBuffer.static FloatBuffer
clone
(FloatBuffer buf) Creates a new FloatBuffer with the same contents as the given FloatBuffer.static IntBuffer
Creates a new IntBuffer with the same contents as the given IntBuffer.static ShortBuffer
clone
(ShortBuffer buf) Creates a new ShortBuffer with the same contents as the given ShortBuffer.static ByteBuffer
cloneOnHeap
(ByteBuffer buf) Creates a new ByteBuffer with the same contents as the given ByteBuffer.static void
copy
(FloatBuffer source, int fromPos, FloatBuffer destination, int toPos, int length) Copies floats from one buffer to another.static void
copyInternal
(FloatBuffer buf, int fromPos, int toPos, int length) Copies floats from one position in the buffer to another.static void
copyInternalColor
(FloatBuffer buf, int fromPos, int toPos) Copies a ColorRGBA from one position in the buffer to another.static void
copyInternalVector2
(FloatBuffer buf, int fromPos, int toPos) Copies a Vector2 from one position in the buffer to another.static void
copyInternalVector3
(FloatBuffer buf, int fromPos, int toPos) Copies a Vector3 from one position in the buffer to another.static void
copyInternalVector4
(FloatBuffer buf, int fromPos, int toPos) Copies a Vector3 from one position in the buffer to another.static ByteBuffer
createByteBuffer
(int size) Create a new ByteBuffer of the specified size.static ByteBuffer
createByteBuffer
(ByteBuffer buf, int size) Create a new ByteBuffer of an appropriate size to hold the specified number of ints only if the given buffer if not already the right size.static ByteBuffer
createByteBufferOnHeap
(int size) Create a new ByteBuffer of the specified size.static ByteBuffer
createByteBufferOnHeap
(ByteBuffer buf, int size) Create a new ByteBuffer of an appropriate size to hold the specified number of ints only if the given buffer if not already the right size.static FloatBuffer
createColorBuffer
(int colors) Create a new FloatBuffer of an appropriate size to hold the specified number of ColorRGBA object data.static DoubleBuffer
createDoubleBuffer
(int size) Create a new DoubleBuffer of the specified size.static DoubleBuffer
createDoubleBuffer
(DoubleBuffer buf, int size) Create a new DoubleBuffer of an appropriate size to hold the specified number of doubles only if the given buffer if not already the right size.static DoubleBuffer
createDoubleBufferOnHeap
(int size) Create a new DoubleBuffer of the specified size.static FloatBuffer
createFloatBuffer
(float... data) Generate a new FloatBuffer using the given array of float primitives.static FloatBuffer
createFloatBuffer
(int size) Create a new FloatBuffer of the specified size.static FloatBuffer
createFloatBuffer
(int offset, int length, ReadOnlyColorRGBA... data) Generate a new FloatBuffer using the given array of ColorRGBA objects.static FloatBuffer
createFloatBuffer
(int offset, int length, ReadOnlyVector2... data) Generate a new FloatBuffer using the given array of Vector2 objects.static FloatBuffer
createFloatBuffer
(int offset, int length, ReadOnlyVector3... data) Generate a new FloatBuffer using the given array of Vector3 objects.static FloatBuffer
createFloatBuffer
(int offset, int length, ReadOnlyVector4... data) Generate a new FloatBuffer using the given array of Vector4 objects.static FloatBuffer
createFloatBuffer
(ReadOnlyColorRGBA... data) Generate a new FloatBuffer using the given array of ColorRGBA objects.static FloatBuffer
createFloatBuffer
(ReadOnlyVector2... data) Generate a new FloatBuffer using the given array of Vector2 objects.static FloatBuffer
createFloatBuffer
(ReadOnlyVector3... data) Generate a new FloatBuffer using the given array of Vector3 objects.static FloatBuffer
createFloatBuffer
(ReadOnlyVector4... data) Generate a new FloatBuffer using the given array of Vector4 objects.static FloatBuffer
createFloatBuffer
(FloatBuffer reuseStore, float... data) Generate a new FloatBuffer using the given array of float primitives.static FloatBuffer
createFloatBufferOnHeap
(int size) Create a new FloatBuffer of the specified size.static FloatBuffer
createFloatBufferOnHeap
(int offset, int length, ReadOnlyColorRGBA... data) Generate a new FloatBuffer using the given array of ColorRGBA objects.static FloatBuffer
createFloatBufferOnHeap
(int offset, int length, ReadOnlyVector2... data) Generate a new FloatBuffer using the given array of Vector2 objects.static FloatBuffer
createFloatBufferOnHeap
(int offset, int length, ReadOnlyVector3... data) Generate a new FloatBuffer using the given array of Vector3 objects.static IndexBufferData
<?> createIndexBufferData
(int[] contents, int maxValue) Create a new IndexBufferData large enough to fit the contents of the given array.static IndexBufferData
<?> createIndexBufferData
(int size, int maxValue) Create a new IndexBufferData of the specified size.static IndexBufferData
<?> createIndexBufferData
(int size, Class<? extends IndexBufferData<?>> clazz) Create a new IndexBufferData of the specified size and class.static IndexBufferData
<?> createIndexBufferDataOnHeap
(int size, int maxValue) Create a new IndexBufferData of the specified size.static IntBuffer
createIntBuffer
(int size) Create a new IntBuffer of the specified size.static IntBuffer
createIntBuffer
(int... data) Generate a new IntBuffer using the given array of ints.static IntBuffer
createIntBuffer
(IntBuffer buf, int size) Create a new IntBuffer of an appropriate size to hold the specified number of ints only if the given buffer if not already the right size.static IntBuffer
createIntBuffer
(IntBuffer reuseStore, int... data) static IntBuffer
createIntBufferOnHeap
(int size) Create a new IntBuffer of the specified size.static ShortBuffer
createShortBuffer
(int size) Create a new ShortBuffer of the specified size.static ShortBuffer
createShortBuffer
(short... data) Generate a new ShortBuffer using the given array of short primitives.static ShortBuffer
createShortBuffer
(ShortBuffer buf, int size) Create a new ShortBuffer of an appropriate size to hold the specified number of shorts only if the given buffer if not already the right size.static ShortBuffer
createShortBufferOnHeap
(int size) Create a new ShortBuffer of the specified size.static FloatBuffer
createVector2Buffer
(int vertices) Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2 object data.static FloatBuffer
createVector2Buffer
(FloatBuffer buf, int vertices) Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2 object data only if the given buffer if not already the right size.static FloatBuffer
createVector3Buffer
(int vertices) Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3 object data.static FloatBuffer
createVector3Buffer
(FloatBuffer buf, int vertices) Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3 object data only if the given buffer is not already the right size.static FloatBuffer
createVector4Buffer
(int vertices) Create a new FloatBuffer of an appropriate size to hold the specified number of Vector4 object data.static FloatBuffer
createVector4Buffer
(FloatBuffer buf, int vertices) Create a new FloatBuffer of an appropriate size to hold the specified number of Vector4 object data only if the given buffer if not already the right size.static FloatBuffer
ensureLargeEnough
(FloatBuffer buffer, int required) Ensures there is at least therequired
number of entries left after the current position of the buffer.static boolean
equals
(ReadOnlyColorRGBA check, FloatBuffer buf, int index) Checks to see if the given ColorRGBA is equal to the data stored in the buffer at the given data index.static boolean
equals
(ReadOnlyVector2 check, FloatBuffer buf, int index) Checks to see if the given Vector2 is equals to the data stored in the buffer at the given data index.static boolean
equals
(ReadOnlyVector3 check, FloatBuffer buf, int index) Checks to see if the given Vector3 is equals to the data stored in the buffer at the given data index.static boolean
equals
(ReadOnlyVector4 check, FloatBuffer buf, int index) Checks to see if the given Vector3 is equals to the data stored in the buffer at the given data index.static ColorRGBA[]
getColorArray
(FloatBufferData data, ReadOnlyColorRGBA defaults) Generates a ColorRGBA array from the given FloatBufferData.static ColorRGBA[]
getColorArray
(FloatBuffer buff) Generates a ColorRGBA array from the given FloatBuffer.static float[]
getFloatArray
(FloatBuffer buff) Create a new float[] array and populate it with the given FloatBuffer's contents.static int[]
getIntArray
(IndexBufferData<?> buff) Create a new int[] array and populate it with the given IndexBufferData's contents.static int[]
getIntArray
(IntBuffer buff) Create a new int[] array and populate it with the given IntBuffer's contents.static Vector2[]
getVector2Array
(FloatBufferData data, ReadOnlyVector2 defaults) Generates a Vector2 array from the given FloatBufferData.static Vector2[]
getVector2Array
(FloatBuffer buff) Generates a Vector2 array from the given FloatBuffer.static Vector3[]
getVector3Array
(FloatBufferData data, ReadOnlyVector3 defaults) Generates a Vector3 array from the given FloatBufferData.static Vector3[]
getVector3Array
(FloatBuffer buff) Generates a Vector3 array from the given FloatBuffer.static Vector4[]
getVector4Array
(FloatBufferData data, ReadOnlyVector4 defaults) Generates a Vector4 array from the given FloatBufferData.static Vector4[]
getVector4Array
(FloatBuffer buff) Generates a Vector4 array from the given FloatBuffer.static void
multInBuffer
(ReadOnlyVector2 toMult, FloatBuffer buf, int index) Multiply and store a Vector2 in-buffer.static void
multInBuffer
(ReadOnlyVector3 toMult, FloatBuffer buf, int index) Multiply and store a Vector3 in-buffer.static void
multInBuffer
(ReadOnlyVector4 toMult, FloatBuffer buf, int index) Multiply and store a Vector3 in-buffer.static void
normalizeVector2
(FloatBuffer buf, int index) Normalize a Vector2 in-buffer.static void
normalizeVector3
(FloatBuffer buf, int index) Normalize a Vector3 in-buffer.static void
normalizeVector4
(FloatBuffer buf, int index) Normalize a Vector4 in-buffer.static void
populateFromBuffer
(ColorRGBA store, FloatBuffer buf, int index) Updates the values of the given color from the specified buffer at the index provided.static void
populateFromBuffer
(Vector2 vector, FloatBuffer buf, int index) Updates the values of the given vector from the specified buffer at the index provided.static void
populateFromBuffer
(Vector3 vector, FloatBuffer buf, int index) Updates the values of the given vector from the specified buffer at the index provided.static void
populateFromBuffer
(Vector4 vector, FloatBuffer buf, int index) Updates the values of the given vector from the specified buffer at the index provided.static void
static void
setInBuffer
(ReadOnlyColorRGBA color, FloatBuffer buf, int index) Sets the data contained in the given color into the FloatBuffer at the specified index.static void
setInBuffer
(ReadOnlyVector2 vector, FloatBuffer buf, int index) Sets the data contained in the given Vector2 into the FloatBuffer at the specified index.static void
setInBuffer
(ReadOnlyVector3 vector, FloatBuffer buf, int index) Sets the data contained in the given Vector3 into the FloatBuffer at the specified index.static void
setInBuffer
(ReadOnlyVector4 vector, FloatBuffer buf, int index) Sets the data contained in the given Vector4 into the FloatBuffer at the specified index.
-
Constructor Details
-
BufferUtils
public BufferUtils()
-
-
Method Details
-
createFloatBuffer
Generate a new FloatBuffer using the given array of ColorRGBA objects. The FloatBuffer will be 4 * data.length long and contain the color data as data[0].r, data[0].g, data[0].b, data[0].a, data[1].r... etc.- Parameters:
data
- array of ColorRGBA objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createFloatBuffer
Generate a new FloatBuffer using the given array of ColorRGBA objects. The FloatBuffer will be 4 * data.length long and contain the color data as data[0].r, data[0].g, data[0].b, data[0].a, data[1].r... etc.- Parameters:
offset
- the starting index to read from in our data arraylength
- the number of colors to readdata
- array of ColorRGBA objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createColorBuffer
Create a new FloatBuffer of an appropriate size to hold the specified number of ColorRGBA object data.- Parameters:
colors
- number of colors that need to be held by the newly created buffer- Returns:
- the requested new FloatBuffer
-
setInBuffer
Sets the data contained in the given color into the FloatBuffer at the specified index.- Parameters:
color
- the data to insertbuf
- the buffer to insert intoindex
- the position to place the data; in terms of colors not floats
-
populateFromBuffer
Updates the values of the given color from the specified buffer at the index provided.- Parameters:
store
- the color to set data onbuf
- the buffer to read fromindex
- the position (in terms of colors, not floats) to read from the buf
-
getColorArray
Generates a ColorRGBA array from the given FloatBuffer.- Parameters:
buff
- the FloatBuffer to read from- Returns:
- a newly generated array of ColorRGBA objects
-
getColorArray
Generates a ColorRGBA array from the given FloatBufferData.- Parameters:
data
- the FloatBufferData to read fromdefaults
- a default value to set each color to, used when the tuple size of the givenFloatBufferData
is smaller than 4.- Returns:
- a newly generated array of ColorRGBA objects
-
copyInternalColor
Copies a ColorRGBA from one position in the buffer to another. The index values are in terms of color number (eg, color number 0 is positions 0-3 in the FloatBuffer.)- Parameters:
buf
- the buffer to copy from/tofromPos
- the index of the color to copytoPos
- the index to copy the color to
-
equals
Checks to see if the given ColorRGBA is equal to the data stored in the buffer at the given data index.- Parameters:
check
- the color to check against - null will return false.buf
- the buffer to compare data withindex
- the position (in terms of colors, not floats) of the color in the buffer to check against- Returns:
true
if the given ColorRGBA is equal to the data stored in the buffer at the given data index
-
createFloatBuffer
Generate a new FloatBuffer using the given array of Vector4 objects. The FloatBuffer will be 4 * data.length long and contain the vector data as data[0].x, data[0].y, data[0].z, data[0].w, data[1].x... etc.- Parameters:
data
- array of Vector4 objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createFloatBuffer
Generate a new FloatBuffer using the given array of Vector4 objects. The FloatBuffer will be 4 * data.length long and contain the vector data as data[0].x, data[0].y, data[0].z, data[0].w, data[1].x... etc.- Parameters:
offset
- the starting index to read from in our data arraylength
- the number of vectors to readdata
- array of Vector4 objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createVector4Buffer
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector4 object data.- Parameters:
vertices
- number of vertices that need to be held by the newly created buffer- Returns:
- the requested new FloatBuffer
-
createVector4Buffer
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector4 object data only if the given buffer if not already the right size.- Parameters:
buf
- the buffer to first check and rewindvertices
- number of vertices that need to be held by the newly created buffer- Returns:
- the requested new FloatBuffer
-
setInBuffer
Sets the data contained in the given Vector4 into the FloatBuffer at the specified index.- Parameters:
vector
- the data to insertbuf
- the buffer to insert intoindex
- the position to place the data; in terms of vectors not floats
-
populateFromBuffer
Updates the values of the given vector from the specified buffer at the index provided.- Parameters:
vector
- the vector to set data onbuf
- the buffer to read fromindex
- the position (in terms of vectors, not floats) to read from the buffer
-
getVector4Array
Generates a Vector4 array from the given FloatBuffer.- Parameters:
buff
- the FloatBuffer to read from- Returns:
- a newly generated array of Vector3 objects
-
getVector4Array
Generates a Vector4 array from the given FloatBufferData.- Parameters:
data
- the FloatBufferData to read fromdefaults
- a default value to set each color to, used when the tuple size of the givenFloatBufferData
is smaller than 4.- Returns:
- a newly generated array of Vector4 objects
-
copyInternalVector4
Copies a Vector3 from one position in the buffer to another. The index values are in terms of vector number (eg, vector number 0 is positions 0-2 in the FloatBuffer.)- Parameters:
buf
- the buffer to copy from/tofromPos
- the index of the vector to copytoPos
- the index to copy the vector to
-
normalizeVector4
Normalize a Vector4 in-buffer.- Parameters:
buf
- the buffer to find the Vector4 withinindex
- the position (in terms of vectors, not floats) of the vector to normalize
-
addInBuffer
Add to a Vector4 in-buffer.- Parameters:
toAdd
- the vector to add frombuf
- the buffer to find the Vector4 withinindex
- the position (in terms of vectors, not floats) of the vector to add to
-
multInBuffer
Multiply and store a Vector3 in-buffer.- Parameters:
toMult
- the vector to multiply againstbuf
- the buffer to find the Vector3 withinindex
- the position (in terms of vectors, not floats) of the vector to multiply
-
equals
Checks to see if the given Vector3 is equals to the data stored in the buffer at the given data index.- Parameters:
check
- the vector to check against - null will return false.buf
- the buffer to compare data withindex
- the position (in terms of vectors, not floats) of the vector in the buffer to check against- Returns:
true
if the given Vector3 is equals to the data stored in the buffer at the given data index
-
createFloatBuffer
Generate a new FloatBuffer using the given array of Vector3 objects. The FloatBuffer will be 3 * data.length long and contain the vector data as data[0].x, data[0].y, data[0].z, data[1].x... etc.- Parameters:
data
- array of Vector3 objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createFloatBuffer
Generate a new FloatBuffer using the given array of Vector3 objects. The FloatBuffer will be 3 * data.length long and contain the vector data as data[0].x, data[0].y, data[0].z, data[1].x... etc.- Parameters:
offset
- the starting index to read from in our data arraylength
- the number of vectors to readdata
- array of Vector3 objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createVector3Buffer
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3 object data.- Parameters:
vertices
- number of vertices that need to be held by the newly created buffer- Returns:
- the requested new FloatBuffer
-
createVector3Buffer
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3 object data only if the given buffer is not already the right size.- Parameters:
buf
- the buffer to first check and rewindvertices
- number of vertices that need to be held by the newly created buffer- Returns:
- the requested new FloatBuffer
-
setInBuffer
Sets the data contained in the given Vector3 into the FloatBuffer at the specified index.- Parameters:
vector
- the data to insertbuf
- the buffer to insert intoindex
- the position to place the data; in terms of vectors not floats
-
populateFromBuffer
Updates the values of the given vector from the specified buffer at the index provided.- Parameters:
vector
- the vector to set data onbuf
- the buffer to read fromindex
- the position (in terms of vectors, not floats) to read from the buf
-
getVector3Array
Generates a Vector3 array from the given FloatBuffer.- Parameters:
buff
- the FloatBuffer to read from- Returns:
- a newly generated array of Vector3 objects
-
getVector3Array
Generates a Vector3 array from the given FloatBufferData.- Parameters:
data
- the FloatBufferData to read fromdefaults
- a default value to set each color to, used when the tuple size of the givenFloatBufferData
is smaller than 3.- Returns:
- a newly generated array of Vector3 objects
-
copyInternalVector3
Copies a Vector3 from one position in the buffer to another. The index values are in terms of vector number (eg, vector number 0 is positions 0-2 in the FloatBuffer.)- Parameters:
buf
- the buffer to copy from/tofromPos
- the index of the vector to copytoPos
- the index to copy the vector to
-
normalizeVector3
Normalize a Vector3 in-buffer.- Parameters:
buf
- the buffer to find the Vector3 withinindex
- the position (in terms of vectors, not floats) of the vector to normalize
-
addInBuffer
Add to a Vector3 in-buffer.- Parameters:
toAdd
- the vector to add frombuf
- the buffer to find the Vector3 withinindex
- the position (in terms of vectors, not floats) of the vector to add to
-
multInBuffer
Multiply and store a Vector3 in-buffer.- Parameters:
toMult
- the vector to multiply againstbuf
- the buffer to find the Vector3 withinindex
- the position (in terms of vectors, not floats) of the vector to multiply
-
equals
Checks to see if the given Vector3 is equals to the data stored in the buffer at the given data index.- Parameters:
check
- the vector to check against - null will return false.buf
- the buffer to compare data withindex
- the position (in terms of vectors, not floats) of the vector in the buffer to check against- Returns:
true
if the given Vector3 is equals to the data stored in the buffer at the given data index
-
createFloatBuffer
Generate a new FloatBuffer using the given array of Vector2 objects. The FloatBuffer will be 2 * data.length long and contain the vector data as data[0].x, data[0].y, data[1].x... etc.- Parameters:
data
- array of Vector2 objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createFloatBuffer
Generate a new FloatBuffer using the given array of Vector2 objects. The FloatBuffer will be 2 * data.length long and contain the vector data as data[0].x, data[0].y, data[1].x... etc.- Parameters:
offset
- the starting index to read from in our data arraylength
- the number of vectors to readdata
- array of Vector2 objects to place into a new FloatBuffer- Returns:
- the requested new FloatBuffer
-
createVector2Buffer
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2 object data.- Parameters:
vertices
- number of vertices that need to be held by the newly created buffer- Returns:
- the requested new FloatBuffer
-
createVector2Buffer
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2 object data only if the given buffer if not already the right size.- Parameters:
buf
- the buffer to first check and rewindvertices
- number of vertices that need to be held by the newly created buffer- Returns:
- the requested new FloatBuffer
-
setInBuffer
Sets the data contained in the given Vector2 into the FloatBuffer at the specified index.- Parameters:
vector
- the data to insertbuf
- the buffer to insert intoindex
- the position to place the data; in terms of vectors not floats
-
populateFromBuffer
Updates the values of the given vector from the specified buffer at the index provided.- Parameters:
vector
- the vector to set data onbuf
- the buffer to read fromindex
- the position (in terms of vectors, not floats) to read from the buf
-
getVector2Array
Generates a Vector2 array from the given FloatBuffer.- Parameters:
buff
- the FloatBuffer to read from- Returns:
- a newly generated array of Vector2 objects
-
getVector2Array
Generates a Vector2 array from the given FloatBufferData.- Parameters:
data
- the FloatBufferData to read fromdefaults
- a default value to set each color to, used when the tuple size of the givenFloatBufferData
is smaller than 2.- Returns:
- a newly generated array of Vector2 objects
-
copyInternalVector2
Copies a Vector2 from one position in the buffer to another. The index values are in terms of vector number (eg, vector number 0 is positions 0-1 in the FloatBuffer.)- Parameters:
buf
- the buffer to copy from/tofromPos
- the index of the vector to copytoPos
- the index to copy the vector to
-
normalizeVector2
Normalize a Vector2 in-buffer.- Parameters:
buf
- the buffer to find the Vector2 withinindex
- the position (in terms of vectors, not floats) of the vector to normalize
-
addInBuffer
Add to a Vector2 in-buffer.- Parameters:
toAdd
- the vector to add frombuf
- the buffer to find the Vector2 withinindex
- the position (in terms of vectors, not floats) of the vector to add to
-
multInBuffer
Multiply and store a Vector2 in-buffer.- Parameters:
toMult
- the vector to multiply againstbuf
- the buffer to find the Vector2 withinindex
- the position (in terms of vectors, not floats) of the vector to multiply
-
equals
Checks to see if the given Vector2 is equals to the data stored in the buffer at the given data index.- Parameters:
check
- the vector to check against - null will return false.buf
- the buffer to compare data withindex
- the position (in terms of vectors, not floats) of the vector in the buffer to check against- Returns:
true
if the given Vector2 is equals to the data stored in the buffer at the given data index
-
createIntBuffer
Generate a new IntBuffer using the given array of ints. The IntBuffer will be data.length long and contain the int data as data[0], data[1]... etc.- Parameters:
data
- array of ints to place into a new IntBuffer- Returns:
- the requested new IntBuffer
-
getIntArray
Create a new int[] array and populate it with the given IntBuffer's contents.- Parameters:
buff
- the IntBuffer to read from- Returns:
- a new int array populated from the IntBuffer
-
getIntArray
Create a new int[] array and populate it with the given IndexBufferData's contents.- Parameters:
buff
- the IndexBufferData to read from- Returns:
- a new int array populated from the IndexBufferData
-
getFloatArray
Create a new float[] array and populate it with the given FloatBuffer's contents.- Parameters:
buff
- the FloatBuffer to read from- Returns:
- a new float array populated from the FloatBuffer
-
createDoubleBufferOnHeap
Create a new DoubleBuffer of the specified size.- Parameters:
size
- required number of double to store.- Returns:
- the new DoubleBuffer
-
createDoubleBuffer
Create a new DoubleBuffer of the specified size.- Parameters:
size
- required number of double to store.- Returns:
- the new DoubleBuffer
-
createDoubleBuffer
Create a new DoubleBuffer of an appropriate size to hold the specified number of doubles only if the given buffer if not already the right size.- Parameters:
buf
- the buffer to first check and rewindsize
- number of doubles that need to be held by the newly created buffer- Returns:
- the requested new DoubleBuffer
-
clone
Creates a new DoubleBuffer with the same contents as the given DoubleBuffer. The new DoubleBuffer is seperate from the old one and changes are not reflected across. If you want to reflect changes, consider using Buffer.duplicate().- Parameters:
buf
- the DoubleBuffer to copy- Returns:
- the copy
-
createFloatBuffer
Create a new FloatBuffer of the specified size.- Parameters:
size
- required number of floats to store.- Returns:
- the new FloatBuffer
-
createFloatBufferOnHeap
Create a new FloatBuffer of the specified size.- Parameters:
size
- required number of floats to store.- Returns:
- the new FloatBuffer
-
createFloatBuffer
Generate a new FloatBuffer using the given array of float primitives.- Parameters:
data
- array of float primitives to place into a new FloatBuffer- Returns:
- the new FloatBuffer
-
createFloatBuffer
Generate a new FloatBuffer using the given array of float primitives.- Parameters:
reuseStore
- the store reused if non null and big enough to contain the float primitivesdata
- array of float primitives to place into a new FloatBuffer- Returns:
- the new FloatBuffer
-
createFloatBufferOnHeap
Generate a new FloatBuffer using the given array of Vector2 objects. The FloatBuffer will be 2 * data.length long and contain the vector data as data[0].x, data[0].y, data[1].x... etc.- Parameters:
offset
- the starting index to read from in our data arraylength
- the number of vectors to readdata
- array of Vector2 objects to place into a new FloatBuffer- Returns:
- the new FloatBuffer created on the heap
-
createFloatBufferOnHeap
Generate a new FloatBuffer using the given array of Vector3 objects. The FloatBuffer will be 3 * data.length long and contain the vector data as data[0].x, data[0].y, data[0].z, data[1].x... etc.- Parameters:
offset
- the starting index to read from in our data arraylength
- the number of vectors to readdata
- array of Vector3 objects to place into a new FloatBuffer- Returns:
- the new FloatBuffer created on the heap
-
createFloatBufferOnHeap
public static FloatBuffer createFloatBufferOnHeap(int offset, int length, ReadOnlyColorRGBA... data) Generate a new FloatBuffer using the given array of ColorRGBA objects. The FloatBuffer will be 4 * data.length long and contain the color data as data[0].r, data[0].g, data[0].b, data[0].a, data[1].r... etc.- Parameters:
offset
- the starting index to read from in our data arraylength
- the number of colors to readdata
- array of ColorRGBA objects to place into a new FloatBuffer- Returns:
- the new FloatBuffer created on the heap
-
createIntBuffer
-
copy
public static void copy(FloatBuffer source, int fromPos, FloatBuffer destination, int toPos, int length) Copies floats from one buffer to another.- Parameters:
source
- the buffer to copy fromfromPos
- the starting point to copy fromdestination
- the buffer to copy totoPos
- the starting point to copy tolength
- the number of floats to copy
-
copyInternal
Copies floats from one position in the buffer to another.- Parameters:
buf
- the buffer to copy from/tofromPos
- the starting point to copy fromtoPos
- the starting point to copy tolength
- the number of floats to copy
-
clone
Creates a new FloatBuffer with the same contents as the given FloatBuffer. The new FloatBuffer is seperate from the old one and changes are not reflected across. If you want to reflect changes, consider using Buffer.duplicate().- Parameters:
buf
- the FloatBuffer to copy- Returns:
- the copy
-
createIntBufferOnHeap
Create a new IntBuffer of the specified size.- Parameters:
size
- required number of ints to store.- Returns:
- the new IntBuffer
-
createIntBuffer
Create a new IntBuffer of the specified size.- Parameters:
size
- required number of ints to store.- Returns:
- the new IntBuffer
-
createIntBuffer
Create a new IntBuffer of an appropriate size to hold the specified number of ints only if the given buffer if not already the right size.- Parameters:
buf
- the buffer to first check and rewindsize
- number of ints that need to be held by the newly created buffer- Returns:
- the requested new IntBuffer
-
clone
Creates a new IntBuffer with the same contents as the given IntBuffer. The new IntBuffer is seperate from the old one and changes are not reflected across. If you want to reflect changes, consider using Buffer.duplicate().- Parameters:
buf
- the IntBuffer to copy- Returns:
- the copy
-
createByteBuffer
Create a new ByteBuffer of the specified size.- Parameters:
size
- required number of ints to store.- Returns:
- the new IntBuffer
-
createByteBuffer
Create a new ByteBuffer of an appropriate size to hold the specified number of ints only if the given buffer if not already the right size.- Parameters:
buf
- the buffer to first check and rewindsize
- number of bytes that need to be held by the newly created buffer- Returns:
- the requested new IntBuffer
-
clone
Creates a new ByteBuffer with the same contents as the given ByteBuffer. The new ByteBuffer is seperate from the old one and changes are not reflected across. If you want to reflect changes, consider using Buffer.duplicate().- Parameters:
buf
- the ByteBuffer to copy- Returns:
- the copy
-
createShortBufferOnHeap
Create a new ShortBuffer of the specified size.- Parameters:
size
- required number of shorts to store.- Returns:
- the new ShortBuffer
-
createShortBuffer
Create a new ShortBuffer of the specified size.- Parameters:
size
- required number of shorts to store.- Returns:
- the new ShortBuffer
-
createShortBuffer
Generate a new ShortBuffer using the given array of short primitives.- Parameters:
data
- array of short primitives to place into a new ShortBuffer- Returns:
- the new ShortBuffer
-
createShortBuffer
Create a new ShortBuffer of an appropriate size to hold the specified number of shorts only if the given buffer if not already the right size.- Parameters:
buf
- the buffer to first check and rewindsize
- number of shorts that need to be held by the newly created buffer- Returns:
- the requested new ShortBuffer
-
clone
Creates a new ShortBuffer with the same contents as the given ShortBuffer. The new ShortBuffer is seperate from the old one and changes are not reflected across. If you want to reflect changes, consider using Buffer.duplicate().- Parameters:
buf
- the ShortBuffer to copy- Returns:
- the copy
-
ensureLargeEnough
Ensures there is at least therequired
number of entries left after the current position of the buffer. If the buffer is too small a larger one is created and the old one copied to the new buffer.- Parameters:
buffer
- buffer that should be checked/copied (may be null)required
- minimum number of elements that should be remaining in the returned buffer- Returns:
- a buffer large enough to receive at least the
required
number of entries, same position as the input buffer, not null
-
createIndexBufferData
Create a new IndexBufferData of the specified size. The specific implementation will be chosen based on the max value you need to store in your buffer. If that value is less than 2^8, a ByteBufferData is used. If it is less than 2^16, a ShortBufferData is used. Otherwise an IntBufferData is used.- Parameters:
size
- required number of values to store.maxValue
- the largest value you will need to store in your buffer. Often this is equal to ("size of vertex buffer" - 1).- Returns:
- the new IndexBufferData
-
createIndexBufferDataOnHeap
Create a new IndexBufferData of the specified size. The specific implementation will be chosen based on the max value you need to store in your buffer. If that value is less than 2^8, a ByteBufferData is used. If it is less than 2^16, a ShortBufferData is used. Otherwise an IntBufferData is used.- Parameters:
size
- required number of values to store.maxValue
- the largest value you will need to store in your buffer. Often this is equal to ("size of vertex buffer" - 1).- Returns:
- the new IndexBufferData
-
createIndexBufferData
Create a new IndexBufferData large enough to fit the contents of the given array. The specific implementation will be chosen based on the max value you need to store in your buffer. If that value is less than 2^8, a ByteBufferData is used. If it is less than 2^16, a ShortBufferData is used. Otherwise an IntBufferData is used.- Parameters:
contents
- an array of index values to store in your newly created IndexBufferData.maxValue
- the largest value you will need to store in your buffer. Often this is equal to ("size of vertex buffer" - 1).- Returns:
- the new IndexBufferData
-
createIndexBufferData
public static IndexBufferData<?> createIndexBufferData(int size, Class<? extends IndexBufferData<?>> clazz) Create a new IndexBufferData of the specified size and class.- Parameters:
size
- required number of values to store.clazz
- The class type to instantiate.- Returns:
- the new IndexBufferData
-
clone
Creates a new IndexBufferData with the same contents as the given IndexBufferData. The new IndexBufferData is separate from the old one and changes are not reflected across.- Parameters:
buf
- the IndexBufferData to copy- Returns:
- the copy
-
createByteBufferOnHeap
Create a new ByteBuffer of the specified size.- Parameters:
size
- required number of ints to store.- Returns:
- the new IntBuffer
-
createByteBufferOnHeap
Create a new ByteBuffer of an appropriate size to hold the specified number of ints only if the given buffer if not already the right size.- Parameters:
buf
- the buffer to first check and rewindsize
- number of bytes that need to be held by the newly created buffer- Returns:
- the requested new IntBuffer
-
cloneOnHeap
Creates a new ByteBuffer with the same contents as the given ByteBuffer. The new ByteBuffer is seperate from the old one and changes are not reflected across. If you want to reflect changes, consider using Buffer.duplicate().- Parameters:
buf
- the ByteBuffer to copy- Returns:
- the copy
-
printCurrentDirectMemory
-