Package org.oscim.renderer
Class GLMatrix
- java.lang.Object
-
- org.oscim.renderer.GLMatrix
-
public class GLMatrix extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static intM00static intM01static intM02static intM03static intM10static intM11static intM12static intM13static intM20static intM21static intM22static intM23static intM30static intM31static intM32static intM33float[]tmpfloat[]val
-
Constructor Summary
Constructors Constructor Description GLMatrix()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDepthOffset(int delta)add some offset (similar to glDepthOffset)voidcopy(GLMatrix m)Copy values from matstatic voidfrustumM(float[] m, int offset, float left, float right, float bottom, float top, float near, float far)Define a projection matrix in terms of six clip planesvoidget(float[] m)Get the Matrix as float arraystatic booleaninvertM(float[] mInv, int mInvOffset, float[] m, int mOffset)Inverts a 4 x 4 matrix.static voidlookAt(float[] m, int offset, float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz)voidmultiplyLhs(GLMatrix lhs)Use this matrix as rhs, multiply it on lhs and store result.voidmultiplyMM(GLMatrix lhs, GLMatrix rhs)Multiply rhs onto lhs and store result in Matrix.voidmultiplyRhs(GLMatrix rhs)Multiply rhs onto Matrix.static voidorthoM(float[] m, int offset, float left, float right, float bottom, float top, float near, float far)voidprj(float[] vec3)Project Vector with Matrixvoidprj2D(float[] src, int src_offset, float[] dst, int dst_offset, int length)Project Vectors with Matrixvoidprj2D(float[] vec, int offset, int cnt)voidprj3D(float[] vec, int offset, int cnt)voidset(float[] values)Sets the matrix to the given matrix as a float array.voidsetAsUniform(int location)Set Matrix with glUniformMatrixvoidsetIdentity()Set identity matrixvoidsetRotation(float a, float x, float y, float z)Set rotationvoidsetScale(float x, float y, float z)Set scale factorvoidsetTranslation(float x, float y, float z)Set translationvoidsetTransScale(float tx, float ty, float scale)Set translation and x,y scalevoidsetValue(int pos, float value)Set single valuevoidtransposeM(GLMatrix mat)Transpose mat and store result in Matrix
-
-
-
Field Detail
-
M00
public static final int M00
- See Also:
- Constant Field Values
-
M01
public static final int M01
- See Also:
- Constant Field Values
-
M02
public static final int M02
- See Also:
- Constant Field Values
-
M03
public static final int M03
- See Also:
- Constant Field Values
-
M10
public static final int M10
- See Also:
- Constant Field Values
-
M11
public static final int M11
- See Also:
- Constant Field Values
-
M12
public static final int M12
- See Also:
- Constant Field Values
-
M13
public static final int M13
- See Also:
- Constant Field Values
-
M20
public static final int M20
- See Also:
- Constant Field Values
-
M21
public static final int M21
- See Also:
- Constant Field Values
-
M22
public static final int M22
- See Also:
- Constant Field Values
-
M23
public static final int M23
- See Also:
- Constant Field Values
-
M30
public static final int M30
- See Also:
- Constant Field Values
-
M31
public static final int M31
- See Also:
- Constant Field Values
-
M32
public static final int M32
- See Also:
- Constant Field Values
-
M33
public static final int M33
- See Also:
- Constant Field Values
-
tmp
public final float[] tmp
-
val
public final float[] val
-
-
Method Detail
-
set
public void set(float[] values)
Sets the matrix to the given matrix as a float array. The float array must have at least 16 elements; the first 16 will be copied.- Parameters:
values- The matrix, in float form, that is to be copied. Remember that this matrix is in column major order.
-
get
public void get(float[] m)
Get the Matrix as float array- Parameters:
m- float array to store Matrix
-
copy
public void copy(GLMatrix m)
Copy values from mat- Parameters:
mat- Matrix to copy
-
prj
public void prj(float[] vec3)
Project Vector with Matrix- Parameters:
vec3- Vector to project
-
prj3D
public void prj3D(float[] vec, int offset, int cnt)
-
prj2D
public void prj2D(float[] vec, int offset, int cnt)
-
prj2D
public void prj2D(float[] src, int src_offset, float[] dst, int dst_offset, int length)Project Vectors with Matrix- Parameters:
vec2- Vector to project
-
multiplyRhs
public void multiplyRhs(GLMatrix rhs)
Multiply rhs onto Matrix.- Parameters:
rhs- right hand side
-
multiplyLhs
public void multiplyLhs(GLMatrix lhs)
Use this matrix as rhs, multiply it on lhs and store result.- Parameters:
lhs- right hand side
-
multiplyMM
public void multiplyMM(GLMatrix lhs, GLMatrix rhs)
Multiply rhs onto lhs and store result in Matrix. This matrix MUST be different from lhs and rhs! As you know, when combining matrices for vector projection this has the same effect first as applying rhs then lhs.- Parameters:
lhs- left hand siderhs- right hand side
-
transposeM
public void transposeM(GLMatrix mat)
Transpose mat and store result in Matrix- Parameters:
mat- to transpose
-
setRotation
public void setRotation(float a, float x, float y, float z)Set rotation- Parameters:
a- angle in degreex- around x-axisy- around y-axisz- around z-axis
-
setTranslation
public void setTranslation(float x, float y, float z)Set translation- Parameters:
x- along x-axisy- along y-axisz- along z-axis
-
setScale
public void setScale(float x, float y, float z)Set scale factor- Parameters:
x- axisy- axisz- axis
-
setTransScale
public void setTransScale(float tx, float ty, float scale)Set translation and x,y scale- Parameters:
tx- translate xty- translate yscale- factor x,y
-
setAsUniform
public void setAsUniform(int location)
Set Matrix with glUniformMatrix- Parameters:
location- GL location id
-
setValue
public void setValue(int pos, float value)Set single value- Parameters:
pos- at positionvalue- value to set
-
addDepthOffset
public void addDepthOffset(int delta)
add some offset (similar to glDepthOffset)- Parameters:
delta- offset
-
setIdentity
public void setIdentity()
Set identity matrix
-
frustumM
public static void frustumM(float[] m, int offset, float left, float right, float bottom, float top, float near, float far)Define a projection matrix in terms of six clip planes- Parameters:
m- the float array that holds the perspective matrixoffset- the offset into float array m where the perspective matrix data is written
-
invertM
public static boolean invertM(float[] mInv, int mInvOffset, float[] m, int mOffset)Inverts a 4 x 4 matrix.- Parameters:
mInv- the array that holds the output inverted matrixmInvOffset- an offset into mInv where the inverted matrix is stored.m- the input arraymOffset- an offset into m where the matrix is stored.- Returns:
- true if the matrix could be inverted, false if it could not.
-
lookAt
public static void lookAt(float[] m, int offset, float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz)
-
orthoM
public static void orthoM(float[] m, int offset, float left, float right, float bottom, float top, float near, float far)
-
-