Package rosequartz.gfx
Class MatrixUtils
java.lang.Object
rosequartz.gfx.MatrixUtils
Class used by ModelInstance to rotate, scale and translate the model.
- See Also:
ModelInstance
-
Method Summary
Modifier and TypeMethodDescriptionstatic Mat4Configures the matrix to rotate by the given radians around each axis and returns it.static Mat4Configures the matrix to scale by the given factors on each axis and returns it.static Mat4setLookAt(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 Mat4setOrtho(Mat4 mat, float left, float right, float bottom, float top, float nearPlane, float farPlane)Sets the matrix to represent an orthogonal projection.static Mat4setPerspective(Mat4 mat, float fov, float aspectRatio, float nearPlane, float farPlane)Sets the matrix to represent a perspective projection.static Mat4Configures the matrix to translate by the given distance on each axis and returns it.
-
Method Details
-
scale
Configures the matrix to scale by the given factors on each axis and returns it.- Parameters:
mat- matrix to scalex- scale factor on x-axisy- scale factor on y-axisz- scale factor on z-axis- Returns:
- given matrix
-
rotate
Configures the matrix to rotate by the given radians around each axis and returns it.- Parameters:
mat- matrix to rotatex- radians angle around x-axisy- radians angle around y-axisz- radians angle around z-axis- Returns:
- given matrix
-
translate
Configures the matrix to translate by the given distance on each axis and returns it.- Parameters:
mat- matrix to translatex- translation on x-axisy- translation on y-axisz- 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 configureleft- left border valueright- right border valuebottom- bottom border valuetop- top border valuenearPlane- near planefarPlane- 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 configurefov- field of viewaspectRatio- aspect rationearPlane- near planefarPlane- 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 configureeyeX- position of eye on x-axiseyeY- position of eye on y-axiseyeZ- position of eye on z-axisatX- a point the eye is looking at on the x-axisatY- a point the eye is looking at on the y-axisatZ- a point the eye is looking at on the z-axisupX- direction pointing 'up' relative to the eye on the x-axisupY- direction pointing 'up' relative to the eye on the y-axisupZ- direction pointing 'up' relative to the eye on the z-axis- Returns:
- given matrix
-