public class ObjData extends Object
ReadableObjs as plain arrays
or buffers| Modifier and Type | Method and Description |
|---|---|
static ShortBuffer |
convertToShortBuffer(IntBuffer intBuffer)
Convert the given IntBuffer to a (direct) ShortBuffer, by casting all
elements to
short. |
static IntBuffer |
getFaceNormalIndices(ReadableObj obj)
Returns the normal indices from the faces of the given
ReadableObj as a direct IntBuffer. |
static IntBuffer |
getFaceNormalIndices(ReadableObj obj,
int numVerticesPerFace)
Returns the normal indices from the faces of the given
ReadableObj as a direct IntBuffer. |
static void |
getFaceNormalIndices(ReadableObj obj,
IntBuffer target)
Stores the normal indices of the faces of the given
ReadableObj in the given buffer. |
static int[] |
getFaceNormalIndicesArray(ReadableObj obj)
Returns the normal indices from the faces of the given
ReadableObj as an array. |
static int[] |
getFaceNormalIndicesArray(ReadableObj obj,
int numVerticesPerFace)
Returns the normal indices from the faces of the given
ReadableObj as an array. |
static IntBuffer |
getFaceTexCoordIndices(ReadableObj obj)
Returns the texCoord indices from the faces of the given
ReadableObj as a direct IntBuffer. |
static IntBuffer |
getFaceTexCoordIndices(ReadableObj obj,
int numVerticesPerFace)
Returns the texCoord indices from the faces of the given
ReadableObj as a direct IntBuffer. |
static void |
getFaceTexCoordIndices(ReadableObj obj,
IntBuffer target)
Stores the texCoord indices of the faces of the given
ReadableObj in the given buffer. |
static int[] |
getFaceTexCoordIndicesArray(ReadableObj obj)
Returns the texCoord indices from the faces of the given
ReadableObj as an array. |
static int[] |
getFaceTexCoordIndicesArray(ReadableObj obj,
int numVerticesPerFace)
Returns the texCoord indices from the faces of the given
ReadableObj as an array. |
static IntBuffer |
getFaceVertexIndices(ReadableObj obj)
Returns the vertex indices from the faces of the given
ReadableObj as direct IntBuffer. |
static IntBuffer |
getFaceVertexIndices(ReadableObj obj,
int numVerticesPerFace)
Returns the vertex indices from the faces of the given
ReadableObj as direct IntBuffer. |
static void |
getFaceVertexIndices(ReadableObj obj,
IntBuffer target)
Stores the vertex indices of the faces of the given
ReadableObj in the given buffer. |
static int[] |
getFaceVertexIndicesArray(ReadableObj obj)
Returns the vertex indices from the faces of the given
ReadableObj as an array. |
static int[] |
getFaceVertexIndicesArray(ReadableObj obj,
int numVerticesPerFace)
Returns the vertex indices from the faces of the given
ReadableObj as an array. |
static FloatBuffer |
getNormals(ReadableObj obj)
Returns all normals of the given
ReadableObj as an array. |
static void |
getNormals(ReadableObj obj,
FloatBuffer target)
Stores the normals of the given
ReadableObj in the given
buffer. |
static float[] |
getNormalsArray(ReadableObj obj)
Returns all normals of the given
ReadableObj as an array. |
static void |
getTexCoords(ReadableObj obj,
FloatBuffer target,
int dimensions)
Stores the texture coordinates of the given
ReadableObj
in the given buffer. |
static void |
getTexCoords(ReadableObj obj,
FloatBuffer target,
int dimensions,
boolean flipY)
Stores the texture coordinates of the given
ReadableObj
in the given buffer. |
static FloatBuffer |
getTexCoords(ReadableObj obj,
int dimensions)
Returns all texture coordinates of the given
ReadableObj as direct FloatBuffer. |
static FloatBuffer |
getTexCoords(ReadableObj obj,
int dimensions,
boolean flipY)
Returns all texture coordinates of the given
ReadableObj as direct FloatBuffer. |
static float[] |
getTexCoordsArray(ReadableObj obj,
int dimensions)
Returns all texture coordinates of the given
ReadableObj as an array. |
static float[] |
getTexCoordsArray(ReadableObj obj,
int dimensions,
boolean flipY)
Returns all texture coordinates of the given
ReadableObj as an array. |
static int |
getTotalNumFaceVertices(ReadableObj obj)
Returns the sum of all numbers of vertices of all faces in the given
ReadableObj. |
static FloatBuffer |
getVertices(ReadableObj obj)
Returns all vertices of the given
ReadableObj as a direct
FloatBuffer. |
static void |
getVertices(ReadableObj obj,
FloatBuffer target)
Stores the vertices of the given
ReadableObj in the given
buffer. |
static float[] |
getVerticesArray(ReadableObj obj)
Returns all vertices of the given
ReadableObj as an array. |
public static int getTotalNumFaceVertices(ReadableObj obj)
ReadableObj. If the given ReadableObj only contains
triangles, this will be the same as obj.getNumFaces() * 3.obj - The ReadableObjpublic static int[] getFaceVertexIndicesArray(ReadableObj obj)
ReadableObj as an array. number of face vertex
indices and return an array with this size. If the number of vertices
per face is known and equal for all faces,
getFaceVertexIndices(ReadableObj,int) may be used instead.obj - The objpublic static IntBuffer getFaceVertexIndices(ReadableObj obj)
ReadableObj as direct IntBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.number of face vertex
indices and return a buffer with this size. If the number of vertices
per face is known and equal for all faces,
getFaceVertexIndices(ReadableObj,int) may be used instead.obj - The objpublic static int[] getFaceVertexIndicesArray(ReadableObj obj, int numVerticesPerFace)
ReadableObj as an array. obj - The ReadableObjnumVerticesPerFace - The number of vertices per facepublic static IntBuffer getFaceVertexIndices(ReadableObj obj, int numVerticesPerFace)
ReadableObj as direct IntBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.obj - The ReadableObjnumVerticesPerFace - The number of vertices per facepublic static void getFaceVertexIndices(ReadableObj obj, IntBuffer target)
ReadableObj in the given buffer. The position
of the given buffer will be advanced accordingly.getTotalNumFaceVertices(ReadableObj), or, if the number
of vertices per face is known and equal for all faces, with
n = obj.getNumFaces() * numVerticesPerFaceobj - The ReadableObjtarget - The buffer that will store the resultBufferOverflowException - If the buffer can not store the resultpublic static int[] getFaceTexCoordIndicesArray(ReadableObj obj)
ReadableObj as an array. number of face vertices
and return an array with this size. If the number of vertices per
face is known and equal for all faces,
getFaceTexCoordIndices(ReadableObj,int) may be used instead.obj - The objpublic static IntBuffer getFaceTexCoordIndices(ReadableObj obj)
ReadableObj as a direct IntBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.number of face vertices
and return a buffer with this size. If the number of vertices per
face is known and equal for all faces,
getFaceTexCoordIndices(ReadableObj,int) may be used instead.obj - The objpublic static int[] getFaceTexCoordIndicesArray(ReadableObj obj, int numVerticesPerFace)
ReadableObj as an array. obj - The ReadableObjnumVerticesPerFace - The number of vertices per facepublic static IntBuffer getFaceTexCoordIndices(ReadableObj obj, int numVerticesPerFace)
ReadableObj as a direct IntBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.obj - The ReadableObjnumVerticesPerFace - The number of vertices per facepublic static void getFaceTexCoordIndices(ReadableObj obj, IntBuffer target)
ReadableObj in the given buffer. The position
of the given buffer will be advanced accordingly.getTotalNumFaceVertices(ReadableObj), or, if the number of
vertices per face is known and equal for all faces, with
n = obj.getNumFaces() * numVerticesPerFace.obj - The ReadableObjtarget - The buffer that will store the resultBufferOverflowException - If the buffer can not store the resultpublic static int[] getFaceNormalIndicesArray(ReadableObj obj)
ReadableObj as an array. number of face vertices
and return an array with this size. If the number of vertices per
face is known and equal for all faces,
getFaceNormalIndices(ReadableObj,int) may be used instead.obj - The ReadableObjpublic static IntBuffer getFaceNormalIndices(ReadableObj obj)
ReadableObj as a direct IntBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.number of face vertices
and return a buffer with this size. If the number of vertices per
face is known and equal for all faces,
getFaceNormalIndices(ReadableObj,int) may be used instead.obj - The ReadableObjpublic static int[] getFaceNormalIndicesArray(ReadableObj obj, int numVerticesPerFace)
ReadableObj as an array. obj - The ReadableObjnumVerticesPerFace - The number of vertices per facepublic static IntBuffer getFaceNormalIndices(ReadableObj obj, int numVerticesPerFace)
ReadableObj as a direct IntBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.obj - The ReadableObjnumVerticesPerFace - The number of vertices per facepublic static void getFaceNormalIndices(ReadableObj obj, IntBuffer target)
ReadableObj in the given buffer. The position
of the given buffer will be advanced accordingly.getTotalNumFaceVertices(ReadableObj), or, if the number of
vertices per face is known and equal for all faces, with
n = obj.getNumFaces() * numVerticesPerFace.obj - The ReadableObjtarget - The buffer that will store the resultBufferOverflowException - If the buffer can not store the resultpublic static float[] getVerticesArray(ReadableObj obj)
ReadableObj as an array.
Three consecutive entries in the resulting array are the
x,y,z coordinates of one vertexobj - The ReadableObjpublic static FloatBuffer getVertices(ReadableObj obj)
ReadableObj as a direct
FloatBuffer.
Three consecutive entries in the resulting buffer are the
x,y,z coordinates of one vertex. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.obj - The ReadableObjpublic static void getVertices(ReadableObj obj, FloatBuffer target)
ReadableObj in the given
buffer. The position of the target will be increased by
obj.getNumVertices() * 3. The position
of the given buffer will be advanced accordingly.obj - The objtarget - The target that will store the resultBufferOverflowException - If the target can not store the resultpublic static float[] getTexCoordsArray(ReadableObj obj, int dimensions)
ReadableObj as an array.obj - The ReadableObjdimensions - The dimensions that are assumed for the coordinatespublic static float[] getTexCoordsArray(ReadableObj obj, int dimensions, boolean flipY)
ReadableObj as an array.obj - The ReadableObjdimensions - The dimensions that are assumed for the coordinatesflipY - Whether the texture coordinates should be flipped
vertically. This means that the y-coordinates (at dimension index 1)
will be replaced with 1.0f - y. Most image loaders provide
image data with the first pixel being the upper left pixel of
the image. But OpenGL glTexImage2D calls expect the first
pixel to be the lower left. Flipping the texture coordinates
by passing flipY=true to this method allows to compensate
for this mismatch.public static FloatBuffer getTexCoords(ReadableObj obj, int dimensions)
ReadableObj as direct FloatBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.obj - The ReadableObjdimensions - The dimensions that are assumed for the coordinatespublic static FloatBuffer getTexCoords(ReadableObj obj, int dimensions, boolean flipY)
ReadableObj as direct FloatBuffer. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.obj - The ReadableObjdimensions - The dimensions that are assumed for the coordinatesflipY - Whether the texture coordinates should be flipped
vertically. This means that the y-coordinates (at dimension index 1)
will be replaced with 1.0f - y. Most image loaders provide
image data with the first pixel being the upper left pixel of
the image. But OpenGL glTexImage2D calls expect the first
pixel to be the lower left. Flipping the texture coordinates
by passing flipY=true to this method allows to compensate
for this mismatch.public static void getTexCoords(ReadableObj obj, FloatBuffer target, int dimensions)
ReadableObj
in the given buffer. The position of the target will be increased by
obj.getNumTexCoords() * dimensions. The position
of the given buffer will be advanced accordingly.obj - The ReadableObjtarget - The target that will store the resultdimensions - The dimensions that are assumed for the coordinatesBufferOverflowException - If the target can not store the resultpublic static void getTexCoords(ReadableObj obj, FloatBuffer target, int dimensions, boolean flipY)
ReadableObj
in the given buffer. The position of the target will be increased by
obj.getNumTexCoords() * dimensions. The position
of the given buffer will be advanced accordingly.obj - The ReadableObjtarget - The target that will store the resultdimensions - The dimensions that are assumed for the coordinatesflipY - Whether the texture coordinates should be flipped
vertically. This means that the y-coordinates (at dimension index 1)
will be replaced with 1.0f - y. Most image loaders provide
image data with the first pixel being the upper left pixel of
the image. But OpenGL glTexImage2D calls expect the first
pixel to be the lower left. Flipping the texture coordinates
by passing flipY=true to this method allows to compensate
for this mismatch.BufferOverflowException - If the target can not store the resultpublic static float[] getNormalsArray(ReadableObj obj)
ReadableObj as an array.
Three consecutive entries in the resulting array are the
x,y,z coordinates of one normal.obj - The ReadableObjpublic static FloatBuffer getNormals(ReadableObj obj)
ReadableObj as an array.
Three consecutive entries in the resulting buffer are the
x,y,z coordinates of one normal. The position
of the returned buffer will be 0, and its limit and
capacity will match the stored data.obj - The ReadableObjpublic static void getNormals(ReadableObj obj, FloatBuffer target)
ReadableObj in the given
buffer. The position of the target will be increased by
obj.getNumNormals() * 3. The position
of the given buffer will be advanced accordingly.obj - The ReadableObjtarget - The buffer that will store the resultBufferOverflowException - If the target can not store the resultpublic static ShortBuffer convertToShortBuffer(IntBuffer intBuffer)
short. short can represent, then the
short value will become negative. The resulting buffer
will then still be valid for passing the it to OpenGL when the index
mode is GL_UNSIGNED_SHORT, because the bitwise
representation is the same. When one of the integer values is larger
than the value that can be represented with an unsigned
short, then the resulting indices will be invalid
and cause rendering artifacts.intBuffer - The IntBufferCopyright © 2018. All rights reserved.