Class GlMatrices

java.lang.Object
dev.cammiescorner.velvet.api.util.GlMatrices

public final class GlMatrices extends Object
This class consists of static methods that operate on matrices.
  • Constructor Details

    • GlMatrices

      public GlMatrices()
  • Method Details

    • getTmpBuffer

      @API(status=MAINTAINED) public static FloatBuffer 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

      @API(status=MAINTAINED) public static FloatBuffer getProjectionMatrix(FloatBuffer outMat)
      Parameters:
      outMat - the buffer in which to store the output
      Returns:
      outMat
    • getProjectionMatrixInverse

      @API(status=MAINTAINED) public static FloatBuffer getProjectionMatrixInverse(FloatBuffer outMat)
      Parameters:
      outMat - the buffer in which to store the output
      Returns:
      outMat
    • getModelViewMatrix

      @API(status=MAINTAINED) public static FloatBuffer getModelViewMatrix(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 object
      Parameters:
      outMat - the buffer in which to store the output
      Returns:
      outMat
    • getModelViewMatrixInverse

      @API(status=MAINTAINED) public static FloatBuffer getModelViewMatrixInverse(FloatBuffer outMat)
      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 into projectionMatrix
      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 array

      It 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 in
      m - 16 values array storing the matrix to invert
    • invertMat4FB

      @API(status=MAINTAINED) public static void invertMat4FB(FloatBuffer fbInvOut, FloatBuffer fbMatIn)
      Inverts a matrix stored in a FloatBuffer

      It 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 stored
      fbMatIn - 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 in
      left - 16 values array storing the left operand of the matrix product
      right - 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 in
      fbMatLeft - 16 values array storing the left operand of the matrix product
      fbMatRight - 16 values array storing the right operand of the matrix product