Class PMVMatrix
- java.lang.Object
-
- com.jogamp.opengl.util.PMVMatrix
-
- All Implemented Interfaces:
GLMatrixFunc
public final class PMVMatrix extends Object implements GLMatrixFunc
PMVMatrix implements a subset of the fixed function pipeline regarding the projection (P), modelview (Mv) and texture (T) matrix operations, which is specified inGLMatrixFunc
.This is the second implementation of `PMVMatrix` using direct
Matrix4f
,Vec4f
andVec3f
math operations instead of `float[]` viaFloatUtil
.PMVMatrix provides the
inverse modelview matrix (Mvi)
andinverse transposed modelview matrix (Mvit)
.Frustum
is also provided bygetFrustum()
. To keep these derived values synchronized after mutable Mv operations likeglRotatef(..)
inglMatrixMode
(GL_MODELVIEW
), users have to callupdate()
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
Matrix4f
.PMVMatrix can supplement
GL2ES2
applications w/ the lack of the described matrix functionality.Matrix storage details
The
SyncBuffer
abstraction is provided, e.g.getSyncPMvMviMat()
, to synchronize the respectivematrices
with the `float[]` backing store. The latter is represents the data toGLUniformData
via itsFloatBuffer
s, seeSyncBuffer.getBuffer()
, and is pushed to the GPU eventually.SyncBuffer
'sSyncAction
is called byGLUniformData.getBuffer()
, i.e. before the data is pushed to the GPU. The providedSyncAction
ensures that thematrices data
gets copied into the `float[]` backing store. PMVMatrix provides two specializations ofSyncBuffer
,SyncMatrix4f
for singleMatrix4f
mappings andSyncMatrices4f
for multipleMatrix4f
mappings. They can be feed directly to instantiate aGLUniformData
object via e.g.GLUniformData(String, int, int, SyncBuffer)
.All matrices are backed up by a common primitive float-array for performance considerations and are a
sliced
representation of it.Note:
-
-
Field Summary
Fields Modifier and Type Field Description static int
FRUSTUM
Bit value forfrustum
and updated bygetFrustum()
.static int
INVERSE_MODELVIEW
Bit value forinverse modelview matrix (Mvi)
, updated viaupdate()
.static int
INVERSE_TRANSPOSED_MODELVIEW
Bit value forinverse transposed modelview matrix (Mvit)
, updated viaupdate()
.static int
MANUAL_BITS
Manual bits not covered byupdate()
butgetFrustum()
,FRUSTUM
,getPMvMat()
,PREMUL_PMV
,getPMviMat()
,PREMUL_PMVI
, etc.static int
MODIFIED_ALL
Bit value stating all is modifiedstatic int
MODIFIED_MODELVIEW
Bit value stating a modifiedmodelview matrix (Mv)
, since lastupdate()
call.static int
MODIFIED_PROJECTION
Bit value stating a modifiedprojection matrix (P)
, since lastupdate()
call.static int
MODIFIED_TEXTURE
Bit value stating a modifiedtexture matrix (T)
, since lastupdate()
call.static int
PREMUL_PMV
Bit value forpre-multiplied P * Mv
, updated bygetPMvMat()
.static int
PREMUL_PMVI
Bit value forpre-multiplied invert(P * Mv)
, updated bygetPMviMat()
.-
Fields inherited from interface com.jogamp.opengl.fixedfunc.GLMatrixFunc
GL_MATRIX_MODE, GL_MODELVIEW, GL_MODELVIEW_MATRIX, GL_PROJECTION, GL_PROJECTION_MATRIX, GL_TEXTURE_MATRIX
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Matrix4f
getCurrentMat()
int
getDirtyBits()
Returns the dirty bits due to mutable operations, i.e.Frustum
getFrustum()
Returns the frustum, derived from projection x modelview.Matrix4f
getMat(int matrixName)
int
getModifiedBits(boolean clear)
Returns the modified bits due to mutable operations..Matrix4f
getMviMat()
Returns the inversemodelview matrix
(Mvi) if requested.Matrix4f
getMvitMat()
Returns the inverse transposedmodelview matrix
(Mvit) if requested.Matrix4f
getMvMat()
Returns themodelview matrix
(Mv).Matrix4f
getPMat()
Returns theprojection matrix
(P).Matrix4f
getPMviMat()
Returns the pre-multiplied inverse projection x modelview, ifMatrix4f.invert(Matrix4f)
succeeded, otherwise `null`.Matrix4f
getPMvMat()
Returns the pre-multiplied projection x modelview, P x Mv.int
getReqBits()
Returns the request bit mask, which uses bit values equal to the dirty mask and may contain -INVERSE_MODELVIEW
-INVERSE_TRANSPOSED_MODELVIEW
SyncMatrix4f
getSyncMviMat()
Returns theSyncMatrix
of inversemodelview matrix
(Mvi) if requested.SyncMatrix4f
getSyncMvitMat()
Returns theSyncMatrix
of inverse transposedmodelview matrix
(Mvit) if requested.SyncMatrix4f
getSyncMvMat()
Returns theSyncMatrix
ofmodelview matrix
(Mv).SyncMatrix4f
getSyncPMat()
Returns theSyncMatrix
ofprojection matrix
(P).SyncMatrices4f
getSyncPMvMat()
SyncMatrices4f
getSyncPMvMviMat()
SyncMatrices4f
getSyncPMvMviMvitMat()
SyncMatrix4f
getSyncTMat()
Returns theSyncMatrix
oftexture matrix
(T).Matrix4f
getTMat()
Returns thetexture matrix
(T).void
glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar)
Multiply
the current matrix with the frustum matrix.void
glGetFloatv(int matrixGetName, float[] params, int params_offset)
Copy the named matrix to the given storage at offset.void
glGetFloatv(int matrixGetName, FloatBuffer params)
Copy the named matrix into the given storage.void
glGetIntegerv(int pname, int[] params, int params_offset)
void
glGetIntegerv(int pname, IntBuffer params)
glGetIntegervint
glGetMatrixMode()
void
glLoadIdentity()
Load the current matrix with the identity matrixvoid
glLoadMatrix(Quaternion quat)
Load the current matrix with the values of the givenQuaternion
's rotationmatrix representation
.void
glLoadMatrixf(float[] values, int offset)
Load the current matrix w/ the provided one.void
glLoadMatrixf(Matrix4f m)
Load the current matrix with the values of the givenMatrix4f
.void
glLoadMatrixf(FloatBuffer m)
Load the current matrix w/ the provided one.void
glMatrixMode(int matrixName)
Sets the current matrix mode.void
glMultMatrixf(float[] m, int m_offset)
Multiply the current matrix: [c] = [c] x [m]PMVMatrix
glMultMatrixf(Matrix4f m)
Multiply the current matrix: [c] = [c] x [m]void
glMultMatrixf(FloatBuffer m)
Multiply the current matrix: [c] = [c] x [m]void
glOrthof(float left, float right, float bottom, float top, float zNear, float zFar)
Multiply
the current matrix with the orthogonal matrix.void
glPopMatrix()
Pop the current matrix from it's stack.void
glPushMatrix()
Push the current matrix to it's stack, while preserving it's values.PMVMatrix
glRotate(Quaternion quat)
Rotate the current matrix with the givenQuaternion
's rotationmatrix representation
.void
glRotatef(float ang_deg, float x, float y, float z)
Rotate the current matrix.PMVMatrix
glRotatef(float ang_rad, Vec3f axis)
Rotate the current matrix by the given axis and angle in radians.void
glScalef(float x, float y, float z)
Scale the current matrix.PMVMatrix
glScalef(Vec3f s)
Scale the current matrix.void
glTranslatef(float x, float y, float z)
Translate the current matrix.PMVMatrix
glTranslatef(Vec3f t)
Translate the current matrix.void
gluLookAt(Vec3f eye, Vec3f center, Vec3f up)
void
gluPerspective(float fovy_deg, float aspect, float zNear, float zFar)
Multiply
thecurrent matrix
with the perspective/frustum matrix.void
gluPickMatrix(float x, float y, float deltaX, float deltaY, Recti viewport)
Make given matrix the pick matrix based on given parameters.boolean
gluProject(Vec3f objPos, Recti viewport, Vec3f winPos)
Map object coordinates to window coordinates.boolean
gluUnProject(float winx, float winy, float winz, Recti viewport, Vec3f objPos)
Map window coordinates to object coordinates.boolean
gluUnProject4(float winx, float winy, float winz, float clipw, Recti viewport, float near, float far, Vec4f objPos)
Map window coordinates to object coordinates.boolean
gluUnProjectRay(float winx, float winy, float winz0, float winz1, Recti viewport, Ray ray)
Map two window coordinates w/ shared X/Y and distinctive Z to aRay
.static boolean
isMatrixGetName(int matrixGetName)
static boolean
isMatrixModeName(int matrixModeName)
boolean
isReqDirty()
Returns true if the one of therequested bits
are are set dirty due to mutable operations, i.e.static int
matrixGetName2MatrixModeName(int matrixGetName)
static int
matrixModeName2MatrixGetName(int matrixModeName)
Vec3f
mulMvMatVec3f(Vec3f v_inout)
v_inout = Mv * v_inout Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.Vec3f
mulMvMatVec3f(Vec3f v_in, Vec3f v_out)
v_out = Mv * v_in Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.Vec4f
mulMvMatVec4f(Vec4f v_inout)
v_inout = Mv * v_inoutVec4f
mulMvMatVec4f(Vec4f v_in, Vec4f v_out)
v_out = Mv * v_inMatrix4f
mulMvPMat(Matrix4f result)
Vec3f
mulPMatVec3f(Vec3f v_inout)
v_inout = P * v_inout Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.Vec3f
mulPMatVec3f(Vec3f v_in, Vec3f v_out)
v_out = P * v_in Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.Vec4f
mulPMatVec4f(Vec4f v_inout)
v_inout = P * v_inoutVec4f
mulPMatVec4f(Vec4f v_in, Vec4f v_out)
v_out = P * v_inMatrix4f
mulPMvMat(Matrix4f result)
Vec3f
mulPMvMatVec3f(Vec3f v_inout)
v_inout = P * Mv * v_inout Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.Vec3f
mulPMvMatVec3f(Vec3f v_in, Vec3f v_out)
v_out = P * Mv * v_in Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.Vec4f
mulPMvMatVec4f(Vec4f v_inout)
v_inout = P * Mv * v_inoutVec4f
mulPMvMatVec4f(Vec4f v_in, Vec4f v_out)
v_out = P * Mv * v_invoid
reset()
IssuesglLoadIdentity()
on all matrices, i.e.String
toString()
StringBuilder
toString(StringBuilder sb, String f)
boolean
update()
Update the derivedinverse modelview (Mvi)
,inverse transposed modelview (Mvit)
matrices if theyare dirty
and requested via the constructorPMVMatrix(int)
.
Hence updates the following dirty bits.
-
-
-
Field Detail
-
MODIFIED_PROJECTION
public static final int MODIFIED_PROJECTION
Bit value stating a modifiedprojection matrix (P)
, since lastupdate()
call.- See Also:
- Constant Field Values
-
MODIFIED_MODELVIEW
public static final int MODIFIED_MODELVIEW
Bit value stating a modifiedmodelview matrix (Mv)
, since lastupdate()
call.- See Also:
- Constant Field Values
-
MODIFIED_TEXTURE
public static final int MODIFIED_TEXTURE
Bit value stating a modifiedtexture matrix (T)
, since lastupdate()
call.- See Also:
- Constant Field Values
-
MODIFIED_ALL
public static final int MODIFIED_ALL
Bit value stating all is modified- See Also:
- Constant Field Values
-
INVERSE_MODELVIEW
public static final int INVERSE_MODELVIEW
Bit value forinverse modelview matrix (Mvi)
, updated viaupdate()
.- See Also:
- Constant Field Values
-
INVERSE_TRANSPOSED_MODELVIEW
public static final int INVERSE_TRANSPOSED_MODELVIEW
Bit value forinverse transposed modelview matrix (Mvit)
, updated viaupdate()
.- See Also:
- Constant Field Values
-
FRUSTUM
public static final int FRUSTUM
Bit value forfrustum
and updated bygetFrustum()
.- See Also:
- Constant Field Values
-
PREMUL_PMV
public static final int PREMUL_PMV
Bit value forpre-multiplied P * Mv
, updated bygetPMvMat()
.- See Also:
- Constant Field Values
-
PREMUL_PMVI
public static final int PREMUL_PMVI
Bit value forpre-multiplied invert(P * Mv)
, updated bygetPMviMat()
.- See Also:
- Constant Field Values
-
MANUAL_BITS
public static final int MANUAL_BITS
Manual bits not covered byupdate()
butgetFrustum()
,FRUSTUM
,getPMvMat()
,PREMUL_PMV
,getPMviMat()
,PREMUL_PMVI
, etc.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PMVMatrix
public PMVMatrix()
Creates an instance of PMVMatrix.This constructor only sets up an instance w/o additional
INVERSE_MODELVIEW
orINVERSE_TRANSPOSED_MODELVIEW
.Implementation uses non-direct non-NIO Buffers with guaranteed backing array, which are synchronized to the actual Matrix4f instances. This allows faster access in Java computation.
- See Also:
PMVMatrix(int)
-
PMVMatrix
public PMVMatrix(int derivedMatrices)
Creates an instance of PMVMatrix.Additional derived matrices can be requested via `derivedMatrices`, i.e. -
INVERSE_MODELVIEW
-INVERSE_TRANSPOSED_MODELVIEW
Implementation uses non-direct non-NIO Buffers with guaranteed backing array, which are synchronized to the actual Matrix4f instances. This allows faster access in Java computation.
- Parameters:
derivedMatrices
- additional matrices can be requested by passing bitsINVERSE_MODELVIEW
andINVERSE_TRANSPOSED_MODELVIEW
.- See Also:
getReqBits()
,isReqDirty()
,getDirtyBits()
,update()
-
-
Method Detail
-
isMatrixModeName
public static final boolean isMatrixModeName(int matrixModeName)
- Parameters:
matrixModeName
- One ofGL_MODELVIEW
,GL_PROJECTION
orGL_TEXTURE
- Returns:
- true if the given matrix-mode name is valid, otherwise false.
-
matrixModeName2MatrixGetName
public static final int matrixModeName2MatrixGetName(int matrixModeName)
- Parameters:
matrixModeName
- One ofGL_MODELVIEW
,GL_PROJECTION
orGL_TEXTURE
- Returns:
- The corresponding matrix-get name, one of
GL_MODELVIEW_MATRIX
,GL_PROJECTION_MATRIX
orGL_TEXTURE_MATRIX
-
isMatrixGetName
public static final boolean isMatrixGetName(int matrixGetName)
- Parameters:
matrixGetName
- One ofGL_MODELVIEW_MATRIX
,GL_PROJECTION_MATRIX
orGL_TEXTURE_MATRIX
- Returns:
- true if the given matrix-get name is valid, otherwise false.
-
matrixGetName2MatrixModeName
public static final int matrixGetName2MatrixModeName(int matrixGetName)
- Parameters:
matrixGetName
- One ofGL_MODELVIEW_MATRIX
,GL_PROJECTION_MATRIX
orGL_TEXTURE_MATRIX
- Returns:
- The corresponding matrix-mode name, one of
GL_MODELVIEW
,GL_PROJECTION
orGL_TEXTURE
-
reset
public final void reset()
IssuesglLoadIdentity()
on all matrices, i.e.GL_MODELVIEW
,GL_PROJECTION
orGL_TEXTURE
and resets all internal states. LeavesGL_MODELVIEW
the active matrix mode.
-
glGetMatrixMode
public final int glGetMatrixMode()
-
getTMat
public final Matrix4f getTMat()
Returns thetexture matrix
(T).
-
getSyncTMat
public final SyncMatrix4f getSyncTMat()
-
getPMat
public final Matrix4f getPMat()
Returns theprojection matrix
(P).
-
getSyncPMat
public final SyncMatrix4f getSyncPMat()
-
getMvMat
public final Matrix4f getMvMat()
Returns themodelview matrix
(Mv).
-
getSyncMvMat
public final SyncMatrix4f getSyncMvMat()
-
getSyncPMvMat
public final SyncMatrices4f getSyncPMvMat()
-
getMviMat
public final Matrix4f getMviMat()
Returns the inversemodelview matrix
(Mvi) if requested.- Throws:
IllegalArgumentException
- ifINVERSE_MODELVIEW
has not been requested in ctorPMVMatrix(int)
.
-
getSyncMviMat
public final SyncMatrix4f getSyncMviMat()
- Throws:
IllegalArgumentException
- ifINVERSE_MODELVIEW
has not been requested in ctorPMVMatrix(int)
.
-
getMvitMat
public final Matrix4f getMvitMat()
Returns the inverse transposedmodelview matrix
(Mvit) if requested.- Throws:
IllegalArgumentException
- ifINVERSE_TRANSPOSED_MODELVIEW
has not been requested in ctorPMVMatrix(int)
.
-
getSyncMvitMat
public final SyncMatrix4f getSyncMvitMat()
Returns theSyncMatrix
of inverse transposedmodelview matrix
(Mvit) if requested.- Throws:
IllegalArgumentException
- ifINVERSE_TRANSPOSED_MODELVIEW
has not been requested in ctorPMVMatrix(int)
.
-
getSyncPMvMviMat
public final SyncMatrices4f getSyncPMvMviMat()
- Throws:
IllegalArgumentException
- ifINVERSE_MODELVIEW
has not been requested in ctorPMVMatrix(int)
.
-
getSyncPMvMviMvitMat
public final SyncMatrices4f getSyncPMvMviMvitMat()
- Throws:
IllegalArgumentException
- ifINVERSE_TRANSPOSED_MODELVIEW
has not been requested in ctorPMVMatrix(int)
.
-
getCurrentMat
public final Matrix4f getCurrentMat()
- Returns:
- the matrix of the current matrix-mode
-
getMat
public final Matrix4f getMat(int matrixName)
- Parameters:
matrixName
- Either a matrix-get-name, i.e.GL_MODELVIEW_MATRIX
,GL_PROJECTION_MATRIX
orGL_TEXTURE_MATRIX
, or a matrix-mode-name, i.e.GL_MODELVIEW
,GL_PROJECTION
orGL_TEXTURE
- Returns:
- the named matrix, not a copy!
-
mulPMvMat
public final Matrix4f mulPMvMat(Matrix4f result)
- Parameters:
result
- 4x4 matrix storage for result- Returns:
- given result matrix for chaining
-
mulMvPMat
public final Matrix4f mulMvPMat(Matrix4f result)
- Parameters:
result
- 4x4 matrix storage for result- Returns:
- given result matrix for chaining
-
mulMvMatVec4f
public final Vec4f mulMvMatVec4f(Vec4f v_in, Vec4f v_out)
v_out = Mv * v_in- Parameters:
v_in
- input vector, can be v_out for in-place transformationv_out
- output vector
-
mulMvMatVec4f
public final Vec4f mulMvMatVec4f(Vec4f v_inout)
v_inout = Mv * v_inout- Parameters:
v_inout
- input and output vector, i.e. in-place transformation
-
mulMvMatVec3f
public final Vec3f mulMvMatVec3f(Vec3f v_in, Vec3f v_out)
v_out = Mv * v_in Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.- Parameters:
v_in
- input vector, can be v_out for in-place transformationv_out
- output vector
-
mulMvMatVec3f
public final Vec3f mulMvMatVec3f(Vec3f v_inout)
v_inout = Mv * v_inout Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.- Parameters:
v_inout
- input and output vector, i.e. in-place transformation
-
mulPMatVec4f
public final Vec4f mulPMatVec4f(Vec4f v_in, Vec4f v_out)
v_out = P * v_in- Parameters:
v_in
- input vector, can be v_out for in-place transformationv_out
- output vector- Returns:
- given result vector for chaining
-
mulPMatVec4f
public final Vec4f mulPMatVec4f(Vec4f v_inout)
v_inout = P * v_inout- Parameters:
v_inout
- input and output vector, i.e. in-place transformation- Returns:
- given result vector for chaining
-
mulPMatVec3f
public final Vec3f mulPMatVec3f(Vec3f v_in, Vec3f v_out)
v_out = P * v_in Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.- Parameters:
v_in
- float[3] input vector, can be v_out for in-place transformationv_out
- float[3] output vector
-
mulPMatVec3f
public final Vec3f mulPMatVec3f(Vec3f v_inout)
v_inout = P * v_inout Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.- Parameters:
v_inout
- input and output vector, i.e. in-place transformation
-
mulPMvMatVec4f
public final Vec4f mulPMvMatVec4f(Vec4f v_in, Vec4f v_out)
v_out = P * Mv * v_in- Parameters:
v_in
- float[4] input vector, can be v_out for in-place transformationv_out
- float[4] output vector
-
mulPMvMatVec4f
public final Vec4f mulPMvMatVec4f(Vec4f v_inout)
v_inout = P * Mv * v_inout- Parameters:
v_inout
- input and output vector, i.e. in-place transformation
-
mulPMvMatVec3f
public final Vec3f mulPMvMatVec3f(Vec3f v_in, Vec3f v_out)
v_out = P * Mv * v_in Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.- Parameters:
v_in
- float[3] input vector, can be v_out for in-place transformationv_out
- float[3] output vector
-
mulPMvMatVec3f
public final Vec3f mulPMvMatVec3f(Vec3f v_inout)
v_inout = P * Mv * v_inout Affine 3f-vector transformation by 4x4 matrix, seeMatrix4f.mulVec3f(Vec3f, Vec3f)
.- Parameters:
v_inout
- float[3] input and output vector, i.e. in-place transformation
-
glMatrixMode
public final void glMatrixMode(int matrixName)
Description copied from interface:GLMatrixFunc
Sets the current matrix mode.- Specified by:
glMatrixMode
in interfaceGLMatrixFunc
- Parameters:
matrixName
-GLMatrixFunc.GL_MODELVIEW
,GLMatrixFunc.GL_PROJECTION
orGL_TEXTURE
.
-
glGetFloatv
public final void glGetFloatv(int matrixGetName, FloatBuffer params)
Description copied from interface:GLMatrixFunc
Copy the named matrix into the given storage.- Specified by:
glGetFloatv
in interfaceGLMatrixFunc
- Parameters:
matrixGetName
-GLMatrixFunc.GL_MODELVIEW_MATRIX
,GLMatrixFunc.GL_PROJECTION_MATRIX
orGLMatrixFunc.GL_TEXTURE_MATRIX
params
- the FloatBuffer's position remains unchanged, which is the same behavior than the native JOGL GL impl
-
glGetFloatv
public final void glGetFloatv(int matrixGetName, float[] params, int params_offset)
Description copied from interface:GLMatrixFunc
Copy the named matrix to the given storage at offset.- Specified by:
glGetFloatv
in interfaceGLMatrixFunc
- Parameters:
matrixGetName
-GLMatrixFunc.GL_MODELVIEW_MATRIX
,GLMatrixFunc.GL_PROJECTION_MATRIX
orGLMatrixFunc.GL_TEXTURE_MATRIX
params
- storageparams_offset
- storage offset
-
glGetIntegerv
public final void glGetIntegerv(int pname, IntBuffer params)
Description copied from interface:GLMatrixFunc
glGetIntegerv- Specified by:
glGetIntegerv
in interfaceGLMatrixFunc
- Parameters:
pname
-GLMatrixFunc.GL_MATRIX_MODE
to receive the current matrix modeparams
- the FloatBuffer's position remains unchanged which is the same behavior than the native JOGL GL impl
-
glGetIntegerv
public final void glGetIntegerv(int pname, int[] params, int params_offset)
- Specified by:
glGetIntegerv
in interfaceGLMatrixFunc
-
glLoadMatrixf
public final void glLoadMatrixf(float[] values, int offset)
Description copied from interface:GLMatrixFunc
Load the current matrix w/ the provided one.- Specified by:
glLoadMatrixf
in interfaceGLMatrixFunc
-
glLoadMatrixf
public final void glLoadMatrixf(FloatBuffer m)
Description copied from interface:GLMatrixFunc
Load the current matrix w/ the provided one.- Specified by:
glLoadMatrixf
in interfaceGLMatrixFunc
-
glLoadMatrixf
public final void glLoadMatrixf(Matrix4f m)
Load the current matrix with the values of the givenMatrix4f
.Extension to
GLMatrixFunc
.
-
glLoadMatrix
public final void glLoadMatrix(Quaternion quat)
Load the current matrix with the values of the givenQuaternion
's rotationmatrix representation
.Extension to
GLMatrixFunc
.
-
glPopMatrix
public final void glPopMatrix()
Description copied from interface:GLMatrixFunc
Pop the current matrix from it's stack.- Specified by:
glPopMatrix
in interfaceGLMatrixFunc
- See Also:
GLMatrixFunc.glPushMatrix()
-
glPushMatrix
public final void glPushMatrix()
Description copied from interface:GLMatrixFunc
Push the current matrix to it's stack, while preserving it's values.There exist one stack per matrix mode, i.e.
GLMatrixFunc.GL_MODELVIEW
,GLMatrixFunc.GL_PROJECTION
andGL_TEXTURE
.- Specified by:
glPushMatrix
in interfaceGLMatrixFunc
-
glLoadIdentity
public final void glLoadIdentity()
Description copied from interface:GLMatrixFunc
Load the current matrix with the identity matrix- Specified by:
glLoadIdentity
in interfaceGLMatrixFunc
-
glMultMatrixf
public final void glMultMatrixf(FloatBuffer m)
Description copied from interface:GLMatrixFunc
Multiply the current matrix: [c] = [c] x [m]- Specified by:
glMultMatrixf
in interfaceGLMatrixFunc
- Parameters:
m
- the FloatBuffer's position remains unchanged, which is the same behavior than the native JOGL GL impl
-
glMultMatrixf
public final void glMultMatrixf(float[] m, int m_offset)
Description copied from interface:GLMatrixFunc
Multiply the current matrix: [c] = [c] x [m]- Specified by:
glMultMatrixf
in interfaceGLMatrixFunc
-
glMultMatrixf
public final PMVMatrix glMultMatrixf(Matrix4f m)
Multiply the current matrix: [c] = [c] x [m]Extension to
GLMatrixFunc
.- Parameters:
m
- the right hand Matrix4f- Returns:
- this instance of chaining
-
glTranslatef
public final void glTranslatef(float x, float y, float z)
Description copied from interface:GLMatrixFunc
Translate the current matrix.- Specified by:
glTranslatef
in interfaceGLMatrixFunc
-
glTranslatef
public final PMVMatrix glTranslatef(Vec3f t)
Translate the current matrix.Extension to
GLMatrixFunc
.- Parameters:
t
- translation vec3- Returns:
- this instance of chaining
-
glScalef
public final void glScalef(float x, float y, float z)
Description copied from interface:GLMatrixFunc
Scale the current matrix.- Specified by:
glScalef
in interfaceGLMatrixFunc
-
glScalef
public final PMVMatrix glScalef(Vec3f s)
Scale the current matrix.Extension to
GLMatrixFunc
.- Parameters:
s
- scale vec4f- Returns:
- this instance of chaining
-
glRotatef
public final void glRotatef(float ang_deg, float x, float y, float z)
Description copied from interface:GLMatrixFunc
Rotate the current matrix.- Specified by:
glRotatef
in interfaceGLMatrixFunc
-
glRotatef
public final PMVMatrix glRotatef(float ang_rad, Vec3f axis)
Rotate the current matrix by the given axis and angle in radians.Consider using
glRotate(Quaternion)
Extension to
GLMatrixFunc
.- Parameters:
ang_rad
- angle in radiansaxis
- rotation axis- Returns:
- this instance of chaining
- See Also:
glRotate(Quaternion)
-
glRotate
public final PMVMatrix glRotate(Quaternion quat)
Rotate the current matrix with the givenQuaternion
's rotationmatrix representation
.Extension to
GLMatrixFunc
.- Parameters:
quat
- theQuaternion
- Returns:
- this instance of chaining
-
glOrthof
public final void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar)
Description copied from interface:GLMatrixFunc
Multiply
the current matrix with the orthogonal matrix.- Specified by:
glOrthof
in interfaceGLMatrixFunc
-
glFrustumf
public final void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) throws GLException
Multiply
the current matrix with the frustum matrix.- Specified by:
glFrustumf
in interfaceGLMatrixFunc
- Throws:
GLException
- ifzNear <= 0
orzFar <= zNear
orleft == right
, orbottom == top
.- See Also:
Matrix4f.setToFrustum(float, float, float, float, float, float)
-
gluPerspective
public final void gluPerspective(float fovy_deg, float aspect, float zNear, float zFar) throws GLException
Multiply
thecurrent matrix
with the perspective/frustum matrix.- Parameters:
fovy_deg
- fov angle in degreesaspect
- aspect ratio width / heightzNear
-zFar
-- Throws:
GLException
- ifzNear <= 0
orzFar <= zNear
- See Also:
Matrix4f.setToPerspective(float, float, float, float)
-
gluProject
public final boolean gluProject(Vec3f objPos, Recti viewport, Vec3f winPos)
Map object coordinates to window coordinates.Traditional
gluProject
implementation.- Parameters:
objPos
- 3 component object coordinateviewport
- Rect4i viewportwinPos
- 3 component window coordinate, the result- Returns:
- true if successful, otherwise false (z is 1)
-
gluUnProject
public final boolean gluUnProject(float winx, float winy, float winz, Recti viewport, Vec3f objPos)
Map window coordinates to object coordinates.Traditional
gluUnProject
implementation.- Parameters:
winx
-winy
-winz
-viewport
- Rect4i viewportobjPos
- 3 component object coordinate, the result- Returns:
- true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
-
gluUnProject4
public boolean gluUnProject4(float winx, float winy, float winz, float clipw, Recti viewport, float near, float far, Vec4f objPos)
Map window coordinates to object coordinates.Traditional
gluUnProject4
implementation.- Parameters:
winx
-winy
-winz
-clipw
-viewport
- Rect4i viewportnear
-far
-objPos
- 4 component object coordinate, the result- Returns:
- true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
-
gluUnProjectRay
public final boolean gluUnProjectRay(float winx, float winy, float winz0, float winz1, Recti viewport, Ray ray)
Map two window coordinates w/ shared X/Y and distinctive Z to aRay
. The resultingRay
maybe used for picking using abounding box
.Notes for picking winz0 and winz1:
- Parameters:
winx
-winy
-winz0
-winz1
-viewport
-ray
- storage for the resultingRay
- Returns:
- true if successful, otherwise false (failed to invert matrix, or becomes z is infinity)
-
gluPickMatrix
public final void gluPickMatrix(float x, float y, float deltaX, float deltaY, Recti viewport)
Make given matrix the pick matrix based on given parameters.Traditional
gluPickMatrix
implementation.See
for details.
- Parameters:
x
- the center x-component of a picking region in window coordinatesy
- the center y-component of a picking region in window coordinatesdeltaX
- the width of the picking region in window coordinates.deltaY
- the height of the picking region in window coordinates.viewport
- Rect4i viewport vector
-
toString
public StringBuilder toString(StringBuilder sb, String f)
-
getModifiedBits
public final int getModifiedBits(boolean clear)
Returns the modified bits due to mutable operations..A modified bit is set, if the corresponding matrix had been modified by a mutable operation since last
update()
orgetModifiedBits(true)
call.- Parameters:
clear
- if true, clears the modified bits, otherwise leaves them untouched.- See Also:
MODIFIED_PROJECTION
,MODIFIED_MODELVIEW
,MODIFIED_TEXTURE
,getDirtyBits()
,isReqDirty()
-
getDirtyBits
public final int getDirtyBits()
Returns the dirty bits due to mutable operations, i.e. -INVERSE_MODELVIEW
(if requested) -INVERSE_TRANSPOSED_MODELVIEW
(if requested) -FRUSTUM
(always, cleared viagetFrustum()
A dirty bit is set, if the corresponding matrix had been modified by a mutable operation since last
update()
call and requested in the constructorPMVMatrix(int)
.update()
clears the dirty state for the matrices andgetFrustum()
forFRUSTUM
.
-
isReqDirty
public final boolean isReqDirty()
Returns true if the one of therequested bits
are are set dirty due to mutable operations, i.e. at least one of -INVERSE_MODELVIEW
-INVERSE_TRANSPOSED_MODELVIEW
A dirty bit is set, if the corresponding matrix had been modified by a mutable operation since last
update()
call and requested in the constructorPMVMatrix(int)
.update()
clears the dirty state for the matrices andgetFrustum()
forFRUSTUM
.
-
getReqBits
public final int getReqBits()
Returns the request bit mask, which uses bit values equal to the dirty mask and may contain -INVERSE_MODELVIEW
-INVERSE_TRANSPOSED_MODELVIEW
The request bit mask is set by in the constructor
PMVMatrix(int)
.
-
getPMvMat
public final Matrix4f getPMvMat()
Returns the pre-multiplied projection x modelview, P x Mv.This
Matrix4f
instance should be re-fetched via this method and not locally stored to have it updated from a potential modification of underlying projection and/or modelview matrix.update()
has no effect on thisMatrix4f
.This pre-multipled P x Mv is considered dirty, if its corresponding
P matrix
orMv matrix
has been modified since its last update.- See Also:
update()
-
getPMviMat
public final Matrix4f getPMviMat()
Returns the pre-multiplied inverse projection x modelview, ifMatrix4f.invert(Matrix4f)
succeeded, otherwise `null`.This
Matrix4f
instance should be re-fetched via this method and not locally stored to have it updated from a potential modification of underlying projection and/or modelview matrix.update()
has no effect on thisMatrix4f
.This pre-multipled invert(P x Mv) is considered dirty, if its corresponding
P matrix
orMv matrix
has been modified since its last update.- See Also:
update()
-
getFrustum
public final Frustum getFrustum()
Returns the frustum, derived from projection x modelview.This
Frustum
instance should be re-fetched via this method and not locally stored to have it updated from a potential modification of underlying projection and/or modelview matrix.update()
has no effect on thisFrustum
.The
Frustum
is considered dirty, if its correspondingP matrix
orMv matrix
has been modified since its last update.- See Also:
update()
-
update
public final boolean update()
Update the derivedinverse modelview (Mvi)
,inverse transposed modelview (Mvit)
matrices if theyare dirty
and requested via the constructorPMVMatrix(int)
.
Hence updates the following dirty bits. -INVERSE_MODELVIEW
-INVERSE_TRANSPOSED_MODELVIEW
The
Frustum
is updated only viagetFrustum()
separately.The Mvi and Mvit matrices are considered dirty, if their corresponding
Mv matrix
has been modified since their last update.Method is automatically called by
SyncMatrix4f
andSyncMatrices4f
instancesSyncAction
as retrieved by e.g.getSyncMvitMat()
. This ensures an automatic update cycle if used withGLUniformData
.Method may be called manually in case mutable operations has been called and caller operates on already fetched references, i.e. not calling
getMviMat()
,getMvitMat()
anymore.Method clears the modified bits like
getModifiedBits(true)
, which are set by any mutable operation. The modified bits have no impact on this method, but the return value.- Returns:
- true if any matrix has been modified since last update call or if the derived matrices Mvi and Mvit 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.
- See Also:
getModifiedBits(boolean)
,isReqDirty()
,INVERSE_MODELVIEW
,INVERSE_TRANSPOSED_MODELVIEW
,PMVMatrix(int)
,getMviMat()
,getMvitMat()
,getSyncPMvMviMat()
,getSyncPMvMviMvitMat()
-
-