public static IndexBuffer createIndexBuffer(int vertexCount,
            int indexCount) {
        IndexBuffer result;

        if (vertexCount < 128) { // TODO: could be vertexCount <= 256
            ByteBuffer buffer = BufferUtils.createByteBuffer(indexCount);
            int maxIndexValue = Math.max(0, vertexCount - 1);
            result = new IndexByteBuffer(buffer, maxIndexValue);

        } else if (vertexCount < 65536) { // TODO: could be <= 65536
            ShortBuffer buffer = BufferUtils.createShortBuffer(indexCount);
            int maxIndexValue = vertexCount - 1;
            result = new IndexShortBuffer(buffer, maxIndexValue);

        } else {
            IntBuffer buffer = BufferUtils.createIntBuffer(indexCount);
            result = new IndexIntBuffer(buffer);
        }

        return result;
    }
Create an IndexBuffer with the specified capacity.

@param vertexCount the number of vertices that will be indexed into
(determines number of bits per element)
@param indexCount the number of indices the IndexBuffer must hold
(determines number of elements in the buffer)
@return a new, appropriately sized IndexBuffer, which may be an
{@link IndexByteBuffer}, an {@link IndexShortBuffer}, or an
{@link IndexIntBuffer}
jme3-core/src/main/java/com/jme3/scene/mesh/IndexBuffer.java