Class MatrixUtils

java.lang.Object
rosequartz.gfx.MatrixUtils

public final class MatrixUtils extends Object
Class used by ModelInstance to rotate, scale and translate the model.
See Also:
ModelInstance
  • Method Summary

    Modifier and Type
    Method
    Description
    static Mat4
    rotate​(Mat4 mat, float x, float y, float z)
    Configures the matrix to rotate by the given radians around each axis and returns it.
    static Mat4
    scale​(Mat4 mat, float x, float y, float z)
    Configures the matrix to scale by the given factors on each axis and returns it.
    static Mat4
    setLookAt​(Mat4 mat, float eyeX, float eyeY, float eyeZ, float atX, float atY, float atZ, float upX, float upY, float upZ)
    Sets the matrix to be a view matrix.
    static Mat4
    setOrtho​(Mat4 mat, float left, float right, float bottom, float top, float nearPlane, float farPlane)
    Sets the matrix to represent an orthogonal projection.
    static Mat4
    setPerspective​(Mat4 mat, float fov, float aspectRatio, float nearPlane, float farPlane)
    Sets the matrix to represent a perspective projection.
    static Mat4
    translate​(Mat4 mat, float x, float y, float z)
    Configures the matrix to translate by the given distance on each axis and returns it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • scale

      public static Mat4 scale(Mat4 mat, float x, float y, float z)
      Configures the matrix to scale by the given factors on each axis and returns it.
      Parameters:
      mat - matrix to scale
      x - scale factor on x-axis
      y - scale factor on y-axis
      z - scale factor on z-axis
      Returns:
      given matrix
    • rotate

      public static Mat4 rotate(Mat4 mat, float x, float y, float z)
      Configures the matrix to rotate by the given radians around each axis and returns it.
      Parameters:
      mat - matrix to rotate
      x - radians angle around x-axis
      y - radians angle around y-axis
      z - radians angle around z-axis
      Returns:
      given matrix
    • translate

      public static Mat4 translate(Mat4 mat, float x, float y, float z)
      Configures the matrix to translate by the given distance on each axis and returns it.
      Parameters:
      mat - matrix to translate
      x - translation on x-axis
      y - translation on y-axis
      z - translation on z-axis
      Returns:
      given matrix
    • setOrtho

      public static Mat4 setOrtho(Mat4 mat, float left, float right, float bottom, float top, float nearPlane, float farPlane)
      Sets the matrix to represent an orthogonal projection.
      Parameters:
      mat - matrix to configure
      left - left border value
      right - right border value
      bottom - bottom border value
      top - top border value
      nearPlane - near plane
      farPlane - far plane
      Returns:
      given matrix
    • setPerspective

      public static Mat4 setPerspective(Mat4 mat, float fov, float aspectRatio, float nearPlane, float farPlane)
      Sets the matrix to represent a perspective projection.
      Parameters:
      mat - matrix to configure
      fov - field of view
      aspectRatio - aspect ratio
      nearPlane - near plane
      farPlane - far plane
      Returns:
      given matrix
    • setLookAt

      public static Mat4 setLookAt(Mat4 mat, float eyeX, float eyeY, float eyeZ, float atX, float atY, float atZ, float upX, float upY, float upZ)
      Sets the matrix to be a view matrix.
      Parameters:
      mat - matrix to configure
      eyeX - position of eye on x-axis
      eyeY - position of eye on y-axis
      eyeZ - position of eye on z-axis
      atX - a point the eye is looking at on the x-axis
      atY - a point the eye is looking at on the y-axis
      atZ - a point the eye is looking at on the z-axis
      upX - direction pointing 'up' relative to the eye on the x-axis
      upY - direction pointing 'up' relative to the eye on the y-axis
      upZ - direction pointing 'up' relative to the eye on the z-axis
      Returns:
      given matrix