Skip to content

Commit

Permalink
Additional (but preliminary) AccessorModels functions
Browse files Browse the repository at this point in the history
There are too many of them. This may be refactored soon.
  • Loading branch information
javagl committed Feb 1, 2022
1 parent 5d35af7 commit 78233c5
Showing 1 changed file with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ public static DefaultAccessorModel createUnsignedIntScalar(IntBuffer data)
Buffers.createByteBufferFrom(data));
}

/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_INT</code> and the type <code>"SCALAR"</code>.
*
* @param data The actual data
* @return The {@link AccessorModel}
* @throws IllegalArgumentException If the capacity of the given buffer
* (in bytes!) is not divisible by the element size that is implied by
* the type and component type
*/
public static DefaultAccessorModel createIntScalar(IntBuffer data)
{
return create(
GltfConstants.GL_INT, "SCALAR", false,
Buffers.createByteBufferFrom(data));
}

/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_UNSIGNED_BYTE</code> and the type <code>"SCALAR"</code>.<br>
Expand Down Expand Up @@ -104,6 +121,42 @@ public static DefaultAccessorModel createUnsignedByteScalar(
GltfConstants.GL_UNSIGNED_BYTE, "SCALAR", false, data);
}

/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_BYTE</code> and the type <code>"SCALAR"</code>.<br>
* <br>
* The elements of the given buffer will be cast to <code>byte</code>.
*
* @param data The actual data
* @return The {@link AccessorModel}
* @throws IllegalArgumentException If the capacity of the given buffer
* (in bytes!) is not divisible by the element size that is implied by
* the type and component type
*/
public static DefaultAccessorModel createByteScalar(IntBuffer data)
{
return create(
GltfConstants.GL_BYTE, "SCALAR", false,
Buffers.castToByteBuffer(data));
}

/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_BYTE</code> and the type <code>"SCALAR"</code>.
*
* @param data The actual data
* @return The {@link AccessorModel}
* @throws IllegalArgumentException If the capacity of the given buffer
* (in bytes!) is not divisible by the element size that is implied by
* the type and component type
*/
public static DefaultAccessorModel createByteScalar(
ByteBuffer data)
{
return create(
GltfConstants.GL_BYTE, "SCALAR", false, data);
}

/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_UNSIGNED_SHORT</code> and the type <code>"SCALAR"</code>.<br>
Expand Down Expand Up @@ -141,6 +194,44 @@ public static DefaultAccessorModel createUnsignedShortScalar(
Buffers.createByteBufferFrom(data));
}

/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_SHORT</code> and the type <code>"SCALAR"</code>.<br>
* <br>
* The elements of the given buffer will be cast to <code>short</code>.
*
* @param data The actual data
* @return The {@link AccessorModel}
* @throws IllegalArgumentException If the capacity of the given buffer
* (in bytes!) is not divisible by the element size that is implied by
* the type and component type
*/
public static DefaultAccessorModel createShortScalar(IntBuffer data)
{
return create(
GltfConstants.GL_SHORT, "SCALAR", false,
Buffers.castToShortByteBuffer(data));
}

/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_SHORT</code> and the type <code>"SCALAR"</code>.
*
* @param data The actual data
* @return The {@link AccessorModel}
* @throws IllegalArgumentException If the capacity of the given buffer
* (in bytes!) is not divisible by the element size that is implied by
* the type and component type
*/
public static DefaultAccessorModel createShortScalar(
ShortBuffer data)
{
return create(
GltfConstants.GL_SHORT, "SCALAR", false,
Buffers.createByteBufferFrom(data));
}


/**
* Creates a new {@link AccessorModel} with the component type
* <code>GL_FLOAT</code> and the type <code>"VEC2"</code>.
Expand Down

0 comments on commit 78233c5

Please sign in to comment.