Java Code Examples for de.javagl.obj.ObjData#getFaceVertexIndices()

The following examples show how to use de.javagl.obj.ObjData#getFaceVertexIndices() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjGltfAssetCreatorV1.java    From JglTF with MIT License 5 votes vote down vote up
/**
 * Create a byte buffer containing the data of the indices for the
 * given OBJ. The face vertex indices of the given OBJ will be 
 * extracted (assuming that it contains only triangles), converted
 * to the given indices component type (which is a GL constant like
 * GL_SHORT), and a byte buffer containing these indices will be returned.
 * 
 * @param obj The OBJ
 * @param indicesComponentType The indices component type
 * @return The byte buffer
 */
private static ByteBuffer createIndicesByteBuffer(
    ReadableObj obj, int indicesComponentType)
{
    int numVerticesPerFace = 3;
    IntBuffer objIndices = 
        ObjData.getFaceVertexIndices(obj, numVerticesPerFace);
    int indicesComponentSize =
        Accessors.getNumBytesForAccessorComponentType(
            indicesComponentType);
    ByteBuffer indicesByteBuffer = 
        IntBuffers.convertToByteBuffer(objIndices, indicesComponentSize);
    return indicesByteBuffer;
}
 
Example 2
Source File: ObjGltfAssetCreatorV2.java    From JglTF with MIT License 5 votes vote down vote up
/**
 * Create a byte buffer containing the data of the indices for the
 * given OBJ. The face vertex indices of the given OBJ will be 
 * extracted (assuming that it contains only triangles), converted
 * to the given indices component type (which is a GL constant like
 * GL_SHORT), and a byte buffer containing these indices will be returned.
 * 
 * @param obj The OBJ
 * @param indicesComponentType The indices component type
 * @return The byte buffer
 */
private static ByteBuffer createIndicesByteBuffer(
    ReadableObj obj, int indicesComponentType)
{
    int numVerticesPerFace = 3;
    IntBuffer objIndices = 
        ObjData.getFaceVertexIndices(obj, numVerticesPerFace);
    int indicesComponentSize =
        Accessors.getNumBytesForAccessorComponentType(
            indicesComponentType);
    ByteBuffer indicesByteBuffer = 
        IntBuffers.convertToByteBuffer(objIndices, indicesComponentSize);
    return indicesByteBuffer;
}