com.jme3.util
クラス BufferUtils

java.lang.Object
  上位を拡張 com.jme3.util.BufferUtils

public final class BufferUtils
extends java.lang.Object

BufferUtils is a helper class for generating nio buffers from jME data classes such as Vectors and ColorRGBA.


コンストラクタの概要
BufferUtils()
           
 
メソッドの概要
static void addInBuffer(Vector2f toAdd, java.nio.FloatBuffer buf, int index)
          Add to a Vector2f in-buffer.
static void addInBuffer(Vector3f toAdd, java.nio.FloatBuffer buf, int index)
          Add to a Vector3f in-buffer.
static java.nio.Buffer clone(java.nio.Buffer buf)
          Creates a clone of the given buffer.
static java.nio.ByteBuffer clone(java.nio.ByteBuffer buf)
          Creates a new ByteBuffer with the same contents as the given ByteBuffer.
static java.nio.DoubleBuffer clone(java.nio.DoubleBuffer buf)
          Creates a new DoubleBuffer with the same contents as the given DoubleBuffer.
static java.nio.FloatBuffer clone(java.nio.FloatBuffer buf)
          Creates a new FloatBuffer with the same contents as the given FloatBuffer.
static java.nio.IntBuffer clone(java.nio.IntBuffer buf)
          Creates a new IntBuffer with the same contents as the given IntBuffer.
static java.nio.ShortBuffer clone(java.nio.ShortBuffer buf)
          Creates a new ShortBuffer with the same contents as the given ShortBuffer.
static void copyInternal(java.nio.FloatBuffer buf, int fromPos, int toPos, int length)
          Copies floats from one position in the buffer to another.
static void copyInternalVector2(java.nio.FloatBuffer buf, int fromPos, int toPos)
          Copies a Vector2f from one position in the buffer to another.
static void copyInternalVector3(java.nio.FloatBuffer buf, int fromPos, int toPos)
          Copies a Vector3f from one position in the buffer to another.
static java.nio.ByteBuffer createByteBuffer(byte... data)
           
static java.nio.ByteBuffer createByteBuffer(java.nio.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 java.nio.ByteBuffer createByteBuffer(int size)
          Create a new ByteBuffer of the specified size.
static java.nio.ByteBuffer createByteBuffer(java.lang.String data)
           
static java.nio.DoubleBuffer createDoubleBuffer(java.nio.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 java.nio.DoubleBuffer createDoubleBuffer(int size)
          Create a new DoubleBuffer of the specified size.
static java.nio.FloatBuffer createFloatBuffer(float... data)
          Generate a new FloatBuffer using the given array of float primitives.
static java.nio.FloatBuffer createFloatBuffer(int size)
          Create a new FloatBuffer of the specified size.
static java.nio.FloatBuffer createFloatBuffer(Quaternion... data)
          Generate a new FloatBuffer using the given array of Quaternion objects.
static java.nio.FloatBuffer createFloatBuffer(Vector2f... data)
          Generate a new FloatBuffer using the given array of Vector2f objects.
static java.nio.FloatBuffer createFloatBuffer(Vector3f... data)
          Generate a new FloatBuffer using the given array of Vector3f objects.
static java.nio.IntBuffer createIntBuffer(int... data)
          Generate a new IntBuffer using the given array of ints.
static java.nio.IntBuffer createIntBuffer(int size)
          Create a new IntBuffer of the specified size.
static java.nio.IntBuffer createIntBuffer(java.nio.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 java.nio.ShortBuffer createShortBuffer(int size)
          Create a new ShortBuffer of the specified size.
static java.nio.ShortBuffer createShortBuffer(short... data)
           
static java.nio.ShortBuffer createShortBuffer(java.nio.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 java.nio.FloatBuffer createVector2Buffer(java.nio.FloatBuffer buf, int vertices)
          Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2f object data only if the given buffer if not already the right size.
static java.nio.FloatBuffer createVector2Buffer(int vertices)
          Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2f object data.
static java.nio.FloatBuffer createVector3Buffer(java.nio.FloatBuffer buf, int vertices)
          Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3f object data only if the given buffer if not already the right size.
static java.nio.FloatBuffer createVector3Buffer(int vertices)
          Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3f object data.
static java.nio.ByteBuffer ensureLargeEnough(java.nio.ByteBuffer buffer, int required)
           
static java.nio.FloatBuffer ensureLargeEnough(java.nio.FloatBuffer buffer, int required)
          Ensures there is at least the required number of entries left after the current position of the buffer.
static java.nio.ShortBuffer ensureLargeEnough(java.nio.ShortBuffer buffer, int required)
           
static boolean equals(Vector2f check, java.nio.FloatBuffer buf, int index)
          Checks to see if the given Vector2f is equals to the data stored in the buffer at the given data index.
static boolean equals(Vector3f check, java.nio.FloatBuffer buf, int index)
          Checks to see if the given Vector3f is equals to the data stored in the buffer at the given data index.
static float[] getFloatArray(java.nio.FloatBuffer buff)
          Create a new float[] array and populate it with the given FloatBuffer's contents.
static int[] getIntArray(java.nio.IntBuffer buff)
          Create a new int[] array and populate it with the given IntBuffer's contents.
static Vector2f[] getVector2Array(java.nio.FloatBuffer buff)
          Generates a Vector2f array from the given FloatBuffer.
static Vector3f[] getVector3Array(java.nio.FloatBuffer buff)
          Generates a Vector3f array from the given FloatBuffer.
static void multInBuffer(Vector2f toMult, java.nio.FloatBuffer buf, int index)
          Multiply and store a Vector2f in-buffer.
static void multInBuffer(Vector3f toMult, java.nio.FloatBuffer buf, int index)
          Multiply and store a Vector3f in-buffer.
static void normalizeVector2(java.nio.FloatBuffer buf, int index)
          Normalize a Vector2f in-buffer.
static void normalizeVector3(java.nio.FloatBuffer buf, int index)
          Normalize a Vector3f in-buffer.
static void populateFromBuffer(Vector2f vector, java.nio.FloatBuffer buf, int index)
          Updates the values of the given vector from the specified buffer at the index provided.
static void populateFromBuffer(Vector3f vector, java.nio.FloatBuffer buf, int index)
          Updates the values of the given vector from the specified buffer at the index provided.
static void printCurrentDirectMemory(java.lang.StringBuilder store)
           
static void setInBuffer(ColorRGBA color, java.nio.FloatBuffer buf, int index)
          Sets the data contained in the given color into the FloatBuffer at the specified index.
static void setInBuffer(Quaternion quat, java.nio.FloatBuffer buf, int index)
          Sets the data contained in the given quaternion into the FloatBuffer at the specified index.
static void setInBuffer(Vector2f vector, java.nio.FloatBuffer buf, int index)
          Sets the data contained in the given Vector2F into the FloatBuffer at the specified index.
static void setInBuffer(Vector3f vector, java.nio.FloatBuffer buf, int index)
          Sets the data contained in the given Vector3F into the FloatBuffer at the specified index.
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

BufferUtils

public BufferUtils()
メソッドの詳細

clone

public static java.nio.Buffer clone(java.nio.Buffer buf)
Creates a clone of the given buffer. The clone's capacity is equal to the given buffer's limit.

パラメータ:
buf - The buffer to clone
戻り値:
The cloned buffer

createFloatBuffer

public static java.nio.FloatBuffer createFloatBuffer(Vector3f... data)
Generate a new FloatBuffer using the given array of Vector3f 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.

パラメータ:
data - array of Vector3f objects to place into a new FloatBuffer

createFloatBuffer

public static java.nio.FloatBuffer createFloatBuffer(Quaternion... data)
Generate a new FloatBuffer using the given array of Quaternion objects. The FloatBuffer will be 4 * data.length long and contain the vector data.

パラメータ:
data - array of Quaternion objects to place into a new FloatBuffer

createFloatBuffer

public static java.nio.FloatBuffer createFloatBuffer(float... data)
Generate a new FloatBuffer using the given array of float primitives.

パラメータ:
data - array of float primitives to place into a new FloatBuffer

createVector3Buffer

public static java.nio.FloatBuffer createVector3Buffer(int vertices)
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3f object data.

パラメータ:
vertices - number of vertices that need to be held by the newly created buffer
戻り値:
the requested new FloatBuffer

createVector3Buffer

public static java.nio.FloatBuffer createVector3Buffer(java.nio.FloatBuffer buf,
                                                       int vertices)
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector3f object data only if the given buffer if not already the right size.

パラメータ:
buf - the buffer to first check and rewind
vertices - number of vertices that need to be held by the newly created buffer
戻り値:
the requested new FloatBuffer

setInBuffer

public static void setInBuffer(ColorRGBA color,
                               java.nio.FloatBuffer buf,
                               int index)
Sets the data contained in the given color into the FloatBuffer at the specified index.

パラメータ:
color - the data to insert
buf - the buffer to insert into
index - the postion to place the data; in terms of colors not floats

setInBuffer

public static void setInBuffer(Quaternion quat,
                               java.nio.FloatBuffer buf,
                               int index)
Sets the data contained in the given quaternion into the FloatBuffer at the specified index.

パラメータ:
color - the data to insert
buf - the buffer to insert into
index - the postion to place the data; in terms of quaternions not floats

setInBuffer

public static void setInBuffer(Vector3f vector,
                               java.nio.FloatBuffer buf,
                               int index)
Sets the data contained in the given Vector3F into the FloatBuffer at the specified index.

パラメータ:
vector - the data to insert
buf - the buffer to insert into
index - the postion to place the data; in terms of vectors not floats

populateFromBuffer

public static void populateFromBuffer(Vector3f vector,
                                      java.nio.FloatBuffer buf,
                                      int index)
Updates the values of the given vector from the specified buffer at the index provided.

パラメータ:
vector - the vector to set data on
buf - the buffer to read from
index - the position (in terms of vectors, not floats) to read from the buf

getVector3Array

public static Vector3f[] getVector3Array(java.nio.FloatBuffer buff)
Generates a Vector3f array from the given FloatBuffer.

パラメータ:
buff - the FloatBuffer to read from
戻り値:
a newly generated array of Vector3f objects

copyInternalVector3

public static void copyInternalVector3(java.nio.FloatBuffer buf,
                                       int fromPos,
                                       int toPos)
Copies a Vector3f from one position in the buffer to another. The index values are in terms of vector number (eg, vector number 0 is postions 0-2 in the FloatBuffer.)

パラメータ:
buf - the buffer to copy from/to
fromPos - the index of the vector to copy
toPos - the index to copy the vector to

normalizeVector3

public static void normalizeVector3(java.nio.FloatBuffer buf,
                                    int index)
Normalize a Vector3f in-buffer.

パラメータ:
buf - the buffer to find the Vector3f within
index - the position (in terms of vectors, not floats) of the vector to normalize

addInBuffer

public static void addInBuffer(Vector3f toAdd,
                               java.nio.FloatBuffer buf,
                               int index)
Add to a Vector3f in-buffer.

パラメータ:
toAdd - the vector to add from
buf - the buffer to find the Vector3f within
index - the position (in terms of vectors, not floats) of the vector to add to

multInBuffer

public static void multInBuffer(Vector3f toMult,
                                java.nio.FloatBuffer buf,
                                int index)
Multiply and store a Vector3f in-buffer.

パラメータ:
toMult - the vector to multiply against
buf - the buffer to find the Vector3f within
index - the position (in terms of vectors, not floats) of the vector to multiply

equals

public static boolean equals(Vector3f check,
                             java.nio.FloatBuffer buf,
                             int index)
Checks to see if the given Vector3f is equals to the data stored in the buffer at the given data index.

パラメータ:
check - the vector to check against - null will return false.
buf - the buffer to compare data with
index - the position (in terms of vectors, not floats) of the vector in the buffer to check against
戻り値:

createFloatBuffer

public static java.nio.FloatBuffer createFloatBuffer(Vector2f... data)
Generate a new FloatBuffer using the given array of Vector2f 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.

パラメータ:
data - array of Vector2f objects to place into a new FloatBuffer

createVector2Buffer

public static java.nio.FloatBuffer createVector2Buffer(int vertices)
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2f object data.

パラメータ:
vertices - number of vertices that need to be held by the newly created buffer
戻り値:
the requested new FloatBuffer

createVector2Buffer

public static java.nio.FloatBuffer createVector2Buffer(java.nio.FloatBuffer buf,
                                                       int vertices)
Create a new FloatBuffer of an appropriate size to hold the specified number of Vector2f object data only if the given buffer if not already the right size.

パラメータ:
buf - the buffer to first check and rewind
vertices - number of vertices that need to be held by the newly created buffer
戻り値:
the requested new FloatBuffer

setInBuffer

public static void setInBuffer(Vector2f vector,
                               java.nio.FloatBuffer buf,
                               int index)
Sets the data contained in the given Vector2F into the FloatBuffer at the specified index.

パラメータ:
vector - the data to insert
buf - the buffer to insert into
index - the postion to place the data; in terms of vectors not floats

populateFromBuffer

public static void populateFromBuffer(Vector2f vector,
                                      java.nio.FloatBuffer buf,
                                      int index)
Updates the values of the given vector from the specified buffer at the index provided.

パラメータ:
vector - the vector to set data on
buf - the buffer to read from
index - the position (in terms of vectors, not floats) to read from the buf

getVector2Array

public static Vector2f[] getVector2Array(java.nio.FloatBuffer buff)
Generates a Vector2f array from the given FloatBuffer.

パラメータ:
buff - the FloatBuffer to read from
戻り値:
a newly generated array of Vector2f objects

copyInternalVector2

public static void copyInternalVector2(java.nio.FloatBuffer buf,
                                       int fromPos,
                                       int toPos)
Copies a Vector2f from one position in the buffer to another. The index values are in terms of vector number (eg, vector number 0 is postions 0-1 in the FloatBuffer.)

パラメータ:
buf - the buffer to copy from/to
fromPos - the index of the vector to copy
toPos - the index to copy the vector to

normalizeVector2

public static void normalizeVector2(java.nio.FloatBuffer buf,
                                    int index)
Normalize a Vector2f in-buffer.

パラメータ:
buf - the buffer to find the Vector2f within
index - the position (in terms of vectors, not floats) of the vector to normalize

addInBuffer

public static void addInBuffer(Vector2f toAdd,
                               java.nio.FloatBuffer buf,
                               int index)
Add to a Vector2f in-buffer.

パラメータ:
toAdd - the vector to add from
buf - the buffer to find the Vector2f within
index - the position (in terms of vectors, not floats) of the vector to add to

multInBuffer

public static void multInBuffer(Vector2f toMult,
                                java.nio.FloatBuffer buf,
                                int index)
Multiply and store a Vector2f in-buffer.

パラメータ:
toMult - the vector to multiply against
buf - the buffer to find the Vector2f within
index - the position (in terms of vectors, not floats) of the vector to multiply

equals

public static boolean equals(Vector2f check,
                             java.nio.FloatBuffer buf,
                             int index)
Checks to see if the given Vector2f is equals to the data stored in the buffer at the given data index.

パラメータ:
check - the vector to check against - null will return false.
buf - the buffer to compare data with
index - the position (in terms of vectors, not floats) of the vector in the buffer to check against
戻り値:

createIntBuffer

public static java.nio.IntBuffer createIntBuffer(int... data)
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.

パラメータ:
data - array of ints to place into a new IntBuffer

getIntArray

public static int[] getIntArray(java.nio.IntBuffer buff)
Create a new int[] array and populate it with the given IntBuffer's contents.

パラメータ:
buff - the IntBuffer to read from
戻り値:
a new int array populated from the IntBuffer

getFloatArray

public static float[] getFloatArray(java.nio.FloatBuffer buff)
Create a new float[] array and populate it with the given FloatBuffer's contents.

パラメータ:
buff - the FloatBuffer to read from
戻り値:
a new float array populated from the FloatBuffer

createDoubleBuffer

public static java.nio.DoubleBuffer createDoubleBuffer(int size)
Create a new DoubleBuffer of the specified size.

パラメータ:
size - required number of double to store.
戻り値:
the new DoubleBuffer

createDoubleBuffer

public static java.nio.DoubleBuffer createDoubleBuffer(java.nio.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.

パラメータ:
buf - the buffer to first check and rewind
size - number of doubles that need to be held by the newly created buffer
戻り値:
the requested new DoubleBuffer

clone

public static java.nio.DoubleBuffer clone(java.nio.DoubleBuffer buf)
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().

パラメータ:
buf - the DoubleBuffer to copy
戻り値:
the copy

createFloatBuffer

public static java.nio.FloatBuffer createFloatBuffer(int size)
Create a new FloatBuffer of the specified size.

パラメータ:
size - required number of floats to store.
戻り値:
the new FloatBuffer

copyInternal

public static void copyInternal(java.nio.FloatBuffer buf,
                                int fromPos,
                                int toPos,
                                int length)
Copies floats from one position in the buffer to another.

パラメータ:
buf - the buffer to copy from/to
fromPos - the starting point to copy from
toPos - the starting point to copy to
length - the number of floats to copy

clone

public static java.nio.FloatBuffer clone(java.nio.FloatBuffer buf)
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().

パラメータ:
buf - the FloatBuffer to copy
戻り値:
the copy

createIntBuffer

public static java.nio.IntBuffer createIntBuffer(int size)
Create a new IntBuffer of the specified size.

パラメータ:
size - required number of ints to store.
戻り値:
the new IntBuffer

createIntBuffer

public static java.nio.IntBuffer createIntBuffer(java.nio.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.

パラメータ:
buf - the buffer to first check and rewind
size - number of ints that need to be held by the newly created buffer
戻り値:
the requested new IntBuffer

clone

public static java.nio.IntBuffer clone(java.nio.IntBuffer buf)
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().

パラメータ:
buf - the IntBuffer to copy
戻り値:
the copy

createByteBuffer

public static java.nio.ByteBuffer createByteBuffer(int size)
Create a new ByteBuffer of the specified size.

パラメータ:
size - required number of ints to store.
戻り値:
the new IntBuffer

createByteBuffer

public static java.nio.ByteBuffer createByteBuffer(java.nio.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.

パラメータ:
buf - the buffer to first check and rewind
size - number of bytes that need to be held by the newly created buffer
戻り値:
the requested new IntBuffer

createByteBuffer

public static java.nio.ByteBuffer createByteBuffer(byte... data)

createByteBuffer

public static java.nio.ByteBuffer createByteBuffer(java.lang.String data)

clone

public static java.nio.ByteBuffer clone(java.nio.ByteBuffer buf)
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().

パラメータ:
buf - the ByteBuffer to copy
戻り値:
the copy

createShortBuffer

public static java.nio.ShortBuffer createShortBuffer(int size)
Create a new ShortBuffer of the specified size.

パラメータ:
size - required number of shorts to store.
戻り値:
the new ShortBuffer

createShortBuffer

public static java.nio.ShortBuffer createShortBuffer(java.nio.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.

パラメータ:
buf - the buffer to first check and rewind
size - number of shorts that need to be held by the newly created buffer
戻り値:
the requested new ShortBuffer

createShortBuffer

public static java.nio.ShortBuffer createShortBuffer(short... data)

clone

public static java.nio.ShortBuffer clone(java.nio.ShortBuffer buf)
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().

パラメータ:
buf - the ShortBuffer to copy
戻り値:
the copy

ensureLargeEnough

public static java.nio.FloatBuffer ensureLargeEnough(java.nio.FloatBuffer buffer,
                                                     int required)
Ensures there is at least the required 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.

パラメータ:
buffer - buffer that should be checked/copied (may be null)
required - minimum number of elements that should be remaining in the returned buffer
戻り値:
a buffer large enough to receive at least the required number of entries, same position as the input buffer, not null

ensureLargeEnough

public static java.nio.ShortBuffer ensureLargeEnough(java.nio.ShortBuffer buffer,
                                                     int required)

ensureLargeEnough

public static java.nio.ByteBuffer ensureLargeEnough(java.nio.ByteBuffer buffer,
                                                    int required)

printCurrentDirectMemory

public static void printCurrentDirectMemory(java.lang.StringBuilder store)