Class MatrixStack
java.lang.Object
com.blackrook.gloop.opengl.math.MatrixStack
A matrix stack for the core implementations.
- Author:
- Matthew Tropiano
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaspectOrtho(float targetAspect, float left, float right, float bottom, float top, float near, float far) Multiplies the current matrix by an aspect-adjusted orthographic projection matrix using the canvas dimensions.frustum(float left, float right, float bottom, float top, float near, float far) Multiplies the current matrix by a frustum projection matrix.identity()Sets the topmost matrix to the identity matrix.lookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) Multiplies a "look at" matrix to the current matrix.multiply(float[] values) Multiplies the topmost matrix with another matrix.Multiplies the topmost matrix with another matrix.ortho(float left, float right, float bottom, float top, float near, float far) Multiplies the current matrix by an orthographic projection matrix.peek()perspective(float fov, float aspect, float near, float far) Multiplies the current matrix by a symmetric perspective projection matrix.pop()Pops the topmost matrix off the stack.push()Pushes a copy of the topmost matrix onto the stack.rotateX(float degrees) Rotates the current matrix by an amount of DEGREES around the X-Axis.rotateY(float degrees) Rotates the current matrix by an amount of DEGREES around the Y-Axis.rotateZ(float degrees) Rotates the current matrix by an amount of DEGREES around the Z-Axis.scale(float x, float y, float z) Scales the current matrix by a set of scalars that correspond to each axis.set(float[] values) Sets the topmost matrix to another matrix.Sets the topmost matrix to another matrix.translate(float x, float y, float z) Translates the current matrix by a set of units.
-
Constructor Details
-
MatrixStack
public MatrixStack(int depth) Creates a new matrix stack. The topmost matrix is initialized with the identity matrix.- Parameters:
depth- the matrix stack depth in matrices.
-
-
Method Details
-
push
Pushes a copy of the topmost matrix onto the stack.- Returns:
- the topmost matrix.
- Throws:
ArrayIndexOutOfBoundsException- if there's no more room to push a new matrix.
-
pop
Pops the topmost matrix off the stack.- Returns:
- the topmost matrix.
- Throws:
ArrayIndexOutOfBoundsException- if there's no matrices left to pop.
-
peek
- Returns:
- the topmost matrix.
-
set
Sets the topmost matrix to another matrix.- Parameters:
values- the column-major values for the matrix.- Returns:
- the topmost matrix.
-
set
-
identity
Sets the topmost matrix to the identity matrix.- Returns:
- the topmost matrix.
-
multiply
Multiplies the topmost matrix with another matrix.- Parameters:
values- the column-major values for the matrix.- Returns:
- the topmost matrix.
-
multiply
-
translate
Translates the current matrix by a set of units. This is applied via multiplication with the current matrix.- Parameters:
x- the x-axis translation.y- the y-axis translation.z- the z-axis translation.- Returns:
- the topmost matrix.
-
rotateX
Rotates the current matrix by an amount of DEGREES around the X-Axis. This is applied via multiplication with the current matrix.- Parameters:
degrees- the amount of degrees.- Returns:
- the topmost matrix.
-
rotateY
Rotates the current matrix by an amount of DEGREES around the Y-Axis. This is applied via multiplication with the current matrix.- Parameters:
degrees- the amount of degrees.- Returns:
- the topmost matrix.
-
rotateZ
Rotates the current matrix by an amount of DEGREES around the Z-Axis. This is applied via multiplication with the current matrix.- Parameters:
degrees- the amount of degrees.- Returns:
- the topmost matrix.
-
scale
Scales the current matrix by a set of scalars that correspond to each axis. This is applied via multiplication with the current matrix.- Parameters:
x- the x-axis scalar.y- the y-axis scalar.z- the z-axis scalar.- Returns:
- the topmost matrix.
-
perspective
Multiplies the current matrix by a symmetric perspective projection matrix.- Parameters:
fov- front of view angle in degrees.aspect- the aspect ratio, usually view width over view height.near- the near clipping plane on the Z-Axis.far- the far clipping plane on the Z-Axis.- Returns:
- the topmost matrix.
- Throws:
ArithmeticException- iffov == 0 || aspect == 0 || near == far.
-
frustum
Multiplies the current matrix by a frustum projection matrix.- Parameters:
left- the left clipping plane on the X-Axis.right- the right clipping plane on the X-Axis.bottom- the bottom clipping plane on the Y-Axis.top- the upper clipping plane on the Y-Axis.near- the near clipping plane on the Z-Axis.far- the far clipping plane on the Z-Axis.- Returns:
- the topmost matrix.
- Throws:
ArithmeticException- ifleft == right || bottom == top || near == far.
-
ortho
Multiplies the current matrix by an orthographic projection matrix.- Parameters:
left- the left clipping plane on the X-Axis.right- the right clipping plane on the X-Axis.bottom- the bottom clipping plane on the Y-Axis.top- the upper clipping plane on the Y-Axis.near- the near clipping plane on the Z-Axis.far- the far clipping plane on the Z-Axis.- Returns:
- the topmost matrix.
- Throws:
ArithmeticException- ifleft == right || bottom == top || near == far.
-
aspectOrtho
public Matrix4F aspectOrtho(float targetAspect, float left, float right, float bottom, float top, float near, float far) Multiplies the current matrix by an aspect-adjusted orthographic projection matrix using the canvas dimensions.- Parameters:
targetAspect- the target orthographicleft- the left clipping plane on the X-Axis.right- the right clipping plane on the X-Axis.bottom- the bottom clipping plane on the Y-Axis.top- the upper clipping plane on the Y-Axis.near- the near clipping plane on the Z-Axis.far- the far clipping plane on the Z-Axis.- Returns:
- the topmost matrix.
- Throws:
ArithmeticException- ifleft == right || bottom == top || near == far.
-
lookAt
public Matrix4F lookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) Multiplies a "look at" matrix to the current matrix. This sets up the matrix to look at a place in the world (if modelview).- Parameters:
eyeX- the point to look at, X-coordinate.eyeY- the point to look at, Y-coordinate.eyeZ- the point to look at, Z-coordinate.centerX- the reference point to look from, X-coordinate.centerY- the reference point to look from, Y-coordinate.centerZ- the reference point to look from, Z-coordinate.upX- the up vector of the viewpoint, X-coordinate.upY- the up vector of the viewpoint, Y-coordinate.upZ- the up vector of the viewpoint, Z-coordinate.- Returns:
- the topmost matrix.
-