Top Description Fields Constructors Methods
com.jogamp.opengl.util

public final Class PMVMatrix

extends Object
implements GLMatrixFunc
Class Inheritance
All Implemented Interfaces
com.jogamp.opengl.fixedfunc.GLMatrixFunc
Imports
java.nio.FloatBuffer, .IntBuffer, com.jogamp.opengl.GL, .GLException, com.jogamp.opengl.fixedfunc.GLMatrixFunc, jogamp.common.os.PlatformPropsImpl, com.jogamp.common.nio.Buffers, com.jogamp.common.util.FloatStack, com.jogamp.opengl.math.FloatUtil, .Quaternion, .Ray, com.jogamp.opengl.math.geom.AABBox, .Frustum

PMVMatrix implements a subset of the fixed function pipeline regarding the projection (P), modelview (Mv) matrix operation which is specified in GLMatrixFunc.

Further more, PMVMatrix provides the inverse modelview matrix (Mvi) and inverse transposed modelview matrix (Mvit). Frustum is also provided by glGetFrustum(). To keep these derived values synchronized after mutable Mv operations like glRotatef(..) in glMatrixMode(GL_MODELVIEW), users have to call update() before using Mvi and Mvit.

All matrices are provided in column-major order, as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. See FloatUtil.

PMVMatrix can supplement GL2ES2 applications w/ the lack of the described matrix functionality.

Matrix storage details

All matrices are backed up by a common primitive float-array for performance considerations and are a sliced representation of it.

Note:

Field Summary

Modifier and TypeField and Description
public static final int
DIRTY_ALL

Bit value stating all is dirty

public static final int
DIRTY_FRUSTUM

Bit value stating a dirty frustum.

public static final int
public static final int
private int
private Frustum
private final float[]
private final float[]
private final float[]
private final float[]
private int
private final FloatBuffer
private final FloatBuffer
private final FloatBuffer
private final FloatStack
private final FloatBuffer
private final FloatBuffer
private final FloatBuffer
private final FloatBuffer
private final FloatStack
private final FloatBuffer
private final FloatStack
private final float[]
private final int
public static final int
MODIFIED_ALL

Bit value stating all is modified

public static final int
MODIFIED_MODELVIEW

Bit value stating a modified modelview matrix (Mv), since last update() call.

public static final int
MODIFIED_PROJECTION

Bit value stating a modified projection matrix (P), since last update() call.

public static final int
MODIFIED_TEXTURE

Bit value stating a modified texture matrix (T), since last update() call.

private int
private final int
private static final String
private final int
private int

Constructor Summary

AccessConstructor and Description
public
PMVMatrix()

Creates an instance of PMVMatrix.

Method Summary

Modifier and TypeMethod and Description
public final void
clearAllUpdateRequests()

Clears all update() requests of the Mvi and Mvit matrix and Frustum after it has been enabled by one of the Mvi get, Mvit get or Frustum get methods.

public final int
getDirtyBits()

Deprecated Function is exposed for debugging purposes only.
Returns the dirty bits due to mutable operations.
public final int
getModifiedBits(final boolean
if true, clears the modified bits, otherwise leaves them untouched.
clear
)

Returns the modified bits due to mutable operations..

public final int
getRequestMask()

Deprecated Function is exposed for debugging purposes only.
Returns the request bit mask, which uses bit values equal to the dirty mask.
public final void
glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glFrustumf.

Multiply the current matrix with the frustum matrix.
public final void
glGetFloatv(final int matrixGetName, final FloatBuffer
the FloatBuffer's position remains unchanged, which is the same behavior than the native JOGL GL impl
params
)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glGetFloatv.

Copy the named matrix into the given storage.
public final void
glGetFloatv(final int matrixGetName, final float[]
storage
params
,
final int
storage offset
params_offset
)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glGetFloatv.

Copy the named matrix to the given storage at offset.
public final Frustum
glGetFrustum()

Returns the frustum, derived from projection * modelview

public final void
glGetIntegerv(final int
GL_MATRIX_MODE to receive the current matrix mode
pname
,
final IntBuffer
the FloatBuffer's position remains unchanged which is the same behavior than the native JOGL GL impl
params
)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glGetIntegerv.

glGetIntegerv
public final void
glGetIntegerv(final int pname, final int[] params, final int params_offset)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glGetIntegerv.

public final FloatBuffer
public final FloatBuffer

Returns:

the named matrix, not a copy!
glGetMatrixf
(final int
Either a matrix-get-name, i.e. GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX or GL_TEXTURE_MATRIX, or a matrix-mode-name, i.e. GL_MODELVIEW, GL_PROJECTION or GL_TEXTURE
matrixName
)

public final int
glGetMatrixMode()

Returns the current matrix-mode, one of GL_MODELVIEW, GL_PROJECTION or GL_TEXTURE.

public final FloatBuffer
glGetMviMatrixf()

Returns the inverse modelview matrix (Mvi).

public final FloatBuffer
glGetMvitMatrixf()

Returns the inverse transposed modelview matrix (Mvit).

public final FloatBuffer
glGetMvMatrixf()

Returns the modelview matrix (Mv).

public final FloatBuffer
glGetPMatrixf()

Returns the projection matrix (P).

public final FloatBuffer
glGetPMvMatrixf()

Returns 2 matrices within one FloatBuffer: P and Mv.

public final FloatBuffer
glGetPMvMviMatrixf()

Returns 3 matrices within one FloatBuffer: P, Mv and Mvi.

public final FloatBuffer
glGetPMvMvitMatrixf()

Returns 4 matrices within one FloatBuffer: P, Mv, Mvi and Mvit.

public final FloatBuffer
glGetTMatrixf()

Returns the texture matrix (T).

public final void
glLoadIdentity()

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glLoadIdentity.

Load the current matrix with the identity matrix
public final void
glLoadMatrix(final Quaternion quat)

Load the current matrix with the values of the given Quaternion's rotation matrix representation.

public final void
glLoadMatrixf(final float[] values, final int offset)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glLoadMatrixf.

Load the current matrix w/ the provided one.
public final void
glLoadMatrixf(final FloatBuffer
the FloatBuffer's position remains unchanged, which is the same behavior than the native JOGL GL impl
m
)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glLoadMatrixf.

Load the current matrix w/ the provided one.
public final void
glMatrixMode(final int matrixName)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glMatrixMode.

Sets the current matrix mode.
public final void
glMultMatrixf(final FloatBuffer
the FloatBuffer's position remains unchanged, which is the same behavior than the native JOGL GL impl
m
)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glMultMatrixf.

Multiply the current matrix: [c] = [c] x [m]
public final void
glMultMatrixf(final float[] m, final int m_offset)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glMultMatrixf.

Multiply the current matrix: [c] = [c] x [m]
public final void
glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glOrthof.

Multiply the current matrix with the orthogonal matrix.
public final void
glPopMatrix()

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glPopMatrix.

Pop the current matrix from it's stack.
public final void
glPushMatrix()

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glPushMatrix.

Push the current matrix to it's stack, while preserving it's values.
public final void
glRotate(final Quaternion quat)

Rotate the current matrix with the given Quaternion's rotation matrix representation.

public final void
glRotatef(final float ang_deg, final float x, final float y, final float z)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glRotatef.

Rotate the current matrix.
public final void
glScalef(final float x, final float y, final float z)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glScalef.

Scale the current matrix.
public final void
glTranslatef(final float x, final float y, final float z)

Implements com.jogamp.opengl.fixedfunc.GLMatrixFunc.glTranslatef.

Translate the current matrix.
public final void
gluLookAt(final float eyex, final float eyey, final float eyez, final float centerx, final float centery, final float centerz, final float upx, final float upy, final float upz)

Multiply and translate the current matrix with the eye, object and orientation.

public final void
gluPerspective(final float
fov angle in degrees
fovy_deg
,
final float
aspect ratio width / height
aspect
,
final float zNear, final float zFar)

Multiply the current matrix with the perspective/frustum matrix.

public final void
gluPickMatrix(final float
the center x-component of a picking region in window coordinates
x
,
final float
the center y-component of a picking region in window coordinates
y
,
final float
the width of the picking region in window coordinates.
deltaX
,
final float
the height of the picking region in window coordinates.
deltaY
,
final int[]
4 component viewport vector
viewport
,
final int viewport_offset)

Make given matrix the pick matrix based on given parameters.

public final boolean

Returns:

true if successful, otherwise false (z is 1)
gluProject
(final float objx, final float objy, final float objz, final int[]
4 component viewport vector
viewport
,
final int viewport_offset, final float[]
3 component window coordinate, the result
win_pos
,
final int win_pos_offset)

Map object coordinates to window coordinates.

public final boolean

Returns:

true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
gluUnProject
(final float winx, final float winy, final float winz, final int[]
4 component viewport vector
viewport
,
final int viewport_offset, final float[]
3 component object coordinate, the result
obj_pos
,
final int obj_pos_offset)

Map window coordinates to object coordinates.

public boolean

Returns:

true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
gluUnProject4
(final float winx, final float winy, final float winz, final float clipw, final int[]
4 component viewport vector
viewport
,
final int viewport_offset, final float near, final float far, final float[]
4 component object coordinate, the result
obj_pos
,
final int obj_pos_offset)

Map window coordinates to object coordinates.

public final boolean

Returns:

true if successful, otherwise false (failed to invert matrix, or becomes z is infinity)
gluUnProjectRay
(final float winx, final float winy, final float winz0, final float winz1, final int[] viewport, final int viewport_offset, final Ray
storage for the resulting Ray
ray
)

Map two window coordinates w/ shared X/Y and distinctive Z to a Ray.

public static final boolean

Returns:

true if the given matrix-get name is valid, otherwise false.
isMatrixGetName
(final int matrixGetName)

public static final boolean

Returns:

true if the given matrix-mode name is valid, otherwise false.
isMatrixModeName
(final int matrixModeName)

public static final int

Returns:

The corresponding matrix-mode name, one of GL_MODELVIEW, GL_PROJECTION or GL_TEXTURE
matrixGetName2MatrixModeName
(final int matrixGetName)

public static final int

Returns:

The corresponding matrix-get name, one of GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX or GL_TEXTURE_MATRIX
matrixModeName2MatrixGetName
(final int matrixModeName)

public static StringBuilder

Returns:

matrix string representation
matrixToString
(final StringBuilder
optional passed StringBuilder instance to be used
sb
,
final String
the format string of one floating point, i.e. "%10.5f", see java.util.Formatter
f
,
final FloatBuffer
4x4 matrix in column major order (OpenGL)
a
)

public static StringBuilder

Returns:

side by side representation
matrixToString
(final StringBuilder
optional passed StringBuilder instance to be used
sb
,
final String
the format string of one floating point, i.e. "%10.5f", see java.util.Formatter
f
,
final FloatBuffer
4x4 matrix in column major order (OpenGL)
a
,
final FloatBuffer
4x4 matrix in column major order (OpenGL)
b
)

public final float[]

Returns:

given matrix for chaining
multMvPMatrixf
(final float[]
4x4 matrix storage for result
mat4MvP
,
final int mat4MvP_offset)

Multiplies the Mv and P matrix, i.e.

   mat4MvP = Mv x P
public final float[]

Returns:

given matrix for chaining
multPMvMatrixf
(final float[]
4x4 matrix storage for result
mat4PMv
,
final int mat4PMv_offset)

Multiplies the P and Mv matrix, i.e.

   mat4PMv = P x Mv
public final void
reset()

Issues glLoadIdentity() on all matrices, i.e. GL_MODELVIEW, GL_PROJECTION or GL_TEXTURE and resets all internal states.

private final boolean
public StringBuilder
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public final boolean

Returns:

true if any matrix has been modified since last update call or if the derived matrices Mvi and Mvit or Frustum were updated, otherwise false. In other words, method returns true if any matrix used by the caller must be updated, e.g. uniforms in a shader program.
update
()

Update the derived inverse modelview (Mvi), inverse transposed modelview (Mvit) matrices and Frustum if they are dirty and they were requested by one of the Mvi get, Mvit get or Frustum get methods.

private final boolean
updateImpl(final boolean clearModBits)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait