Class GlMatrices
java.lang.Object
dev.cammiescorner.velvet.api.util.GlMatrices
This class consists of static methods that operate on matrices.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull org.joml.Matrix4fgetInverseTransformMatrix(org.joml.Matrix4f outMat) Computes the matrix allowing computation of eye space coordinates from window space and put the result intoprojectionMatrixstatic FloatBuffergetModelViewMatrix(FloatBuffer outMat) Call this once before doing any transform to get the view matrix, then load identity and call this again after doing any rendering transform to get the model matrix for the rendered objectstatic FloatBuffergetModelViewMatrixInverse(FloatBuffer outMat) static FloatBuffergetProjectionMatrix(FloatBuffer outMat) static FloatBufferstatic FloatBufferA 16-sized float buffer that can be used to send data to shaders.static voidinvertMat4(float[] matOut, float[] m) Inverts a 4x4 matrix stored in a float arraystatic voidinvertMat4FB(FloatBuffer fbInvOut, FloatBuffer fbMatIn) Inverts a matrix stored in aFloatBufferstatic float[]multiplyMat4(float[] dest, float[] left, float[] right) Multiplies together two 4x4 matrices stored in float arrays.static voidmultiplyMat4FB(FloatBuffer fbInvOut, FloatBuffer fbMatLeft, FloatBuffer fbMatRight) Multiplies together two 4x4 matrices stored in float buffers.
-
Constructor Details
-
GlMatrices
public GlMatrices()
-
-
Method Details
-
getTmpBuffer
A 16-sized float buffer that can be used to send data to shaders.Do NOT use this buffer for long term data storage, it can be cleared at any time.
-
getProjectionMatrix
- Parameters:
outMat- the buffer in which to store the output- Returns:
outMat
-
getProjectionMatrixInverse
- Parameters:
outMat- the buffer in which to store the output- Returns:
outMat
-
getModelViewMatrix
Call this once before doing any transform to get the view matrix, then load identity and call this again after doing any rendering transform to get the model matrix for the rendered object- Parameters:
outMat- the buffer in which to store the output- Returns:
outMat
-
getModelViewMatrixInverse
- Parameters:
outMat- the buffer in which to store the output- Returns:
outMat
-
getInverseTransformMatrix
@NotNull @API(status=MAINTAINED) public static @NotNull org.joml.Matrix4f getInverseTransformMatrix(org.joml.Matrix4f outMat) Computes the matrix allowing computation of eye space coordinates from window space and put the result intoprojectionMatrix- Parameters:
outMat- a matrix to put the result in- Returns:
projectionMatrix
-
invertMat4
@API(status=MAINTAINED) public static void invertMat4(float[] matOut, float[] m) Inverts a 4x4 matrix stored in a float arrayIt is safe for the destination array to be the same as the input, as the result is stored in intermediate variables.
- Parameters:
matOut- 16 capacity array to store the output inm- 16 values array storing the matrix to invert
-
invertMat4FB
Inverts a matrix stored in aFloatBufferIt is safe for the destination buffer to be the same as the input, as the result is stored in intermediate variables.
- Parameters:
fbInvOut- an output buffer in which the result will be storedfbMatIn- an input buffer storing the matrix to invert
-
multiplyMat4
@API(status=MAINTAINED) public static float[] multiplyMat4(float[] dest, float[] left, float[] right) Multiplies together two 4x4 matrices stored in float arrays.It is safe for the destination array to be one of the operands, as the result is stored in intermediate variables.
- Parameters:
dest- 16 capacity array to store the output inleft- 16 values array storing the left operand of the matrix productright- 16 values array storing the right operand of the matrix product
-
multiplyMat4FB
@API(status=MAINTAINED) public static void multiplyMat4FB(FloatBuffer fbInvOut, FloatBuffer fbMatLeft, FloatBuffer fbMatRight) Multiplies together two 4x4 matrices stored in float buffers.It is safe for the destination buffer to be one of the operands, as the result is stored in intermediate variables.
- Parameters:
fbInvOut- 16 capacity array to store the output infbMatLeft- 16 values array storing the left operand of the matrix productfbMatRight- 16 values array storing the right operand of the matrix product
-