org.lwjgl.util.vector.Matrix4f Java Examples
The following examples show how to use
org.lwjgl.util.vector.Matrix4f.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MatrixUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void testLookAtMatrix(Vector3f eye, Vector3f center, Vector3f up) { // Make a lookat matrix in opengl and pull it out into a Matrix4f GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GLU.gluLookAt(eye.x, eye.y, eye.z, center.x, center.y, center.z, up.x, up.y, up.z); FloatBuffer fromGlBuffer = BufferUtils.createFloatBuffer(16); GL11.glGetFloat(GL11.GL_MODELVIEW, fromGlBuffer); Matrix4f fromGl = new Matrix4f(); fromGl.load(fromGlBuffer); Matrix4f manual = createLookAt(eye, center, up); compare(fromGl, manual); }
Example #2
Source File: GUIRoot.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
protected final void displayChangedNotify(int width, int height) { //Reset The Current Viewport And Perspective Transformation setDim(width, height); if (width != 0) { float scale = getUnitsPerPixel(Globals.GUI_Z); Matrix4f m1 = new Matrix4f(); m1.setIdentity(); Matrix4f m2 = new Matrix4f(); m2.setIdentity(); Matrix4f m3 = new Matrix4f(); m1.scale(new Vector3f(scale, scale, scale)); m2.translate(new Vector3f(0f, 0f, -Globals.GUI_Z)); Matrix4f.mul(m2, m1, m3); m2.load(m3); m3.setIdentity(); m3.translate(new Vector3f(-width/2f, -height/2f, 0f)); Matrix4f.mul(m2, m3, m1); m1.store(matrix_buf); matrix_buf.rewind(); } for (int i = 0; i < delegate_stack.size(); i++) { ((CameraDelegate)delegate_stack.get(i)).displayChanged(width, height); } }
Example #3
Source File: MatrixUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static Matrix4f createOrthoMatrix(final float left, final float right, final float bottom, final float top, final float near, final float far) { Matrix4f ortho = new Matrix4f(); ortho.setZero(); // First the scale part ortho.m00 = 2.0f / (right - left); ortho.m11 = 2.0f / (top - bottom); ortho.m22 = (-2.0f) / (far - near); ortho.m33 = 1.0f; // Then the translation part ortho.m30 = -( (right+left) / (right-left) ); ortho.m31 = -( (top+bottom) / (top-bottom) ); ortho.m32 = -( (far+near) / (far-near) ); return ortho; }
Example #4
Source File: Manipulator.java From ldparteditor with MIT License | 6 votes |
public void resetTranslation() { accurateResult = View.ACCURATE_ID; accurateScale = View.ACCURATE_ID; accurateRotationX = 0.0; accurateRotationY = 0.0; accurateRotationZ = 0.0; Matrix4f.setIdentity(result); Matrix4f.setIdentity(scale); x_Translate = false; y_Translate = false; z_Translate = false; x_Rotate = false; y_Rotate = false; z_Rotate = false; x_Scale = false; y_Scale = false; z_Scale = false; x_rotatingForwards = false; x_rotatingBackwards = false; y_rotatingForwards = false; y_rotatingBackwards = false; z_rotatingForwards = false; z_rotatingBackwards = false; modified = false; }
Example #5
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example #6
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example #7
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, brg blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example #8
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example #9
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, bvq blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example #10
Source File: KeyStateManager.java From ldparteditor with MIT License | 5 votes |
private static void translateView(Composite3D c3d, float dx, float dy) { PerspectiveCalculator perspective = c3d.getPerspectiveCalculator(); Matrix4f viewport_rotation = c3d.getRotation(); Matrix4f viewport_translation = c3d.getTranslation(); Matrix4f old_viewport_translation = new Matrix4f(); Matrix4f.load(c3d.getTranslation(), old_viewport_translation); Vector4f xAxis4f_translation = new Vector4f(dx, 0, 0, 1.0f); Vector4f yAxis4f_translation = new Vector4f(0, dy, 0, 1.0f); Matrix4f ovr_inverse2 = Matrix4f.invert(viewport_rotation, null); Matrix4f.transform(ovr_inverse2, xAxis4f_translation, xAxis4f_translation); Matrix4f.transform(ovr_inverse2, yAxis4f_translation, yAxis4f_translation); Vector3f xAxis3 = new Vector3f(xAxis4f_translation.x, xAxis4f_translation.y, xAxis4f_translation.z); Vector3f yAxis3 = new Vector3f(yAxis4f_translation.x, yAxis4f_translation.y, yAxis4f_translation.z); Matrix4f.load(old_viewport_translation, viewport_translation); Matrix4f.translate(xAxis3, old_viewport_translation, viewport_translation); Matrix4f.translate(yAxis3, viewport_translation, viewport_translation); perspective.calculateOriginData(); c3d.getVertexManager().getResetTimer().set(true); if (c3d.isSyncTranslation()) { float tx = c3d.getTranslation().m30; float ty = c3d.getTranslation().m31; float tz = c3d.getTranslation().m32; for (OpenGLRenderer renderer : Editor3DWindow.getRenders()) { Composite3D c3d2 = renderer.getC3D(); if (!c3d2.isDisposed() && c3d != c3d2 && c3d.getLockableDatFileReference().equals(c3d2.getLockableDatFileReference())) { c3d2.getTranslation().m30 = tx; c3d2.getTranslation().m31 = ty; c3d2.getTranslation().m32 = tz; ((ScalableComposite) c3d2.getParent()).redrawScales(); c3d2.getPerspectiveCalculator().initializeViewportPerspective(); } } } }
Example #11
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glTranslatef(float x, float y, float z) { Matrix4f.translate(new Vector3f(x, y, z), currentMatrix, currentMatrix); final FloatBuffer buf = BufferUtils.createFloatBuffer(16); currentMatrix.store(buf); buf.position(0); int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, buf); }
Example #12
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, boi blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example #13
Source File: SubMesh.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void pushTo(Mesh mesh, final float xOffset, final float yOffset, final float zOffset, Rotation horizRotation, final float horizAngleDeg, Rotation vertRotation, final float vertAngleDeg) { Matrix4f transform = createTransform(horizRotation, horizAngleDeg, vertRotation, vertAngleDeg); for (int i=0; i<positions.size(); i++) { Vector3f pos = new Vector3f( positions.get(i) ); Vector2f tex = texCoords.get(i); Vector4f col = colours.get(i); if (transform != null) { Vector4f dest = new Vector4f(); Matrix4f.transform(transform, new Vector4f(pos.x, pos.y, pos.z, 1.0f), dest); pos.x = dest.x / dest.w; pos.y = dest.y / dest.w; pos.z = dest.z / dest.w; } pos.x += xOffset; pos.y += yOffset; pos.z += zOffset; mesh.addVertex(pos, col, tex.x, tex.y); } }
Example #14
Source File: BoundingBox.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final void transformBounds(Matrix4f matrix) { temp_vec.set(bmin_x, bmin_y, bmin_z, 1f); Matrix4f.transform(matrix, temp_vec, temp_vec2); bmin_x = temp_vec2.x; bmin_y = temp_vec2.y; bmin_z = temp_vec2.z; temp_vec.set(bmax_x, bmax_y, bmax_z, 1f); Matrix4f.transform(matrix, temp_vec, temp_vec2); bmax_x = temp_vec2.x; bmax_y = temp_vec2.y; bmax_z = temp_vec2.z; computeCenter(); }
Example #15
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example #16
Source File: Composite3DModifier.java From ldparteditor with MIT License | 5 votes |
public void zoomToFit() { final PerspectiveCalculator pc = c3d.getPerspectiveCalculator(); float max_x = 0f; float max_y = 0f; for (Vertex v : c3d.getLockableDatFileReference().getVertexManager().getVertices()) { float ax = Math.abs(v.x); float ay = Math.abs(v.y); if (ax > max_x) max_x = ax; if (ay > max_y) max_y = ay; } Matrix4f id = new Matrix4f(); Matrix4f.setIdentity(id); c3d.getTranslation().load(id); Rectangle b = c3d.getBounds(); if (max_x > max_y) { c3d.setZoom(b.width / (max_x * 4f * View.PIXEL_PER_LDU)); } else { c3d.setZoom(b.height / (max_y * 4f * View.PIXEL_PER_LDU)); } pc.setZoom_exponent((float) (Math.log10(c3d.getZoom()) + 3f) * 10f); if (Float.isInfinite(c3d.getZoom()) || Float.isInfinite(pc.getZoom_exponent()) || Float.isNaN(c3d.getZoom()) || Float.isNaN(pc.getZoom_exponent())) { pc.setZoom_exponent(-20f); c3d.setZoom((float) Math.pow(10.0d, -20f / 10 - 3)); } c3d.setViewportPixelPerLDU(c3d.getZoom() * View.PIXEL_PER_LDU); GuiStatusManager.updateStatus(c3d); ((ScalableComposite) c3d.getParent()).redrawScales(); pc.initializeViewportPerspective(); syncZoom(); }
Example #17
Source File: MatrixUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Matrix4f createLookAt(Vector3f eye, Vector3f lookAt, Vector3f up) { Matrix4f matrix = new Matrix4f(); matrix.setIdentity(); // Create the basis vectors Vector3f forwards = Vector3f.sub(eye, lookAt, null); forwards.normalise(); Vector3f right = Vector3f.cross(up, forwards, null); right.normalise(); Vector3f actualUp = Vector3f.cross(forwards, right, null); actualUp.normalise(); // Right vector across the top matrix.m00 = right.x; matrix.m10 = right.y; matrix.m20 = right.z; // Up vector across the middle row matrix.m01 = actualUp.x; matrix.m11 = actualUp.y; matrix.m21 = actualUp.z; // Forwards vector across the bottom row matrix.m02 = forwards.x; matrix.m12 = forwards.y; matrix.m22 = forwards.z; // Negative translation in the last column Matrix4f translation = new Matrix4f(); translation.setIdentity(); translation.translate(new Vector3f(-eye.x, -eye.y, -eye.z)); return Matrix4f.mul(matrix, translation, null); }
Example #18
Source File: WorldToScreen.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
public static Vector4f multiply(Vector4f vec, Matrix4f mat) { return new Vector4f( vec.x * mat.m00 + vec.y * mat.m10 + vec.z * mat.m20 + vec.w * mat.m30, vec.x * mat.m01 + vec.y * mat.m11 + vec.z * mat.m21 + vec.w * mat.m31, vec.x * mat.m02 + vec.y * mat.m12 + vec.z * mat.m22 + vec.w * mat.m32, vec.x * mat.m03 + vec.y * mat.m13 + vec.z * mat.m23 + vec.w * mat.m33 ); }
Example #19
Source File: CSGCube.java From ldparteditor with MIT License | 5 votes |
@Override public List<Polygon> toPolygons(DatFile df, GColour colour) { int[][][] a = { // position // normal { { 0, 4, 6, 2 }, { -1, 0, 0 } }, { { 1, 3, 7, 5 }, { +1, 0, 0 } }, { { 0, 1, 5, 4 }, { 0, -1, 0 } }, { { 2, 6, 7, 3 }, { 0, +1, 0 } }, { { 0, 2, 3, 1 }, { 0, 0, -1 } }, { { 4, 5, 7, 6 }, { 0, 0, +1 } } }; List<Polygon> polygons = new ArrayList<Polygon>(); for (int[][] info : a) { List<VectorCSGd> vertices = new ArrayList<VectorCSGd>(); for (int i : info[0]) { VectorCSGd pos = new VectorCSGd(center.x + dimensions.x * (1 * Math.min(1, i & 1) - 0.5), center.y + dimensions.y * (1 * Math.min(1, i & 2) - 0.5), center.z + dimensions.z * (1 * Math.min(1, i & 4) - 0.5)); vertices.add(pos); } polygons.add(new Polygon(df, vertices, new GColourIndex(colour, ID))); } if (!centered) { Transform centerTransform = Transform.unity().apply( Matrix4f.setIdentity(new Matrix4f()).translate(new Vector3f((float) dimensions.x / 2f, (float) dimensions.y / 2f, (float) dimensions.z / 2f))); for (Polygon p : polygons) { p.transform(centerTransform); } } return polygons; }
Example #20
Source File: PerspectiveCalculator.java From ldparteditor with MIT License | 5 votes |
/** * Calculates the origin and grid for the actual viewport perspective */ public void calculateOriginData() { Matrix4f realViewport = getRealViewport(); calculateOrigin(realViewport); calculateGrid(realViewport); c3d.setNegDeterminant(realViewport.determinant() < 0f); calculateViewGenerator(); }
Example #21
Source File: LwjglRasteriser.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCameraMatrix(Matrix4f matrix, Vector3f lookAt, Vector3f eye, Vector3f up) { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); FloatBuffer buffer = BufferUtils.createFloatBuffer(16); matrix.store(buffer); buffer.flip(); GL11.glLoadMatrix(buffer); }
Example #22
Source File: CSG.java From ldparteditor with MIT License | 5 votes |
public GData1 compile() { Matrix4f id = new Matrix4f(); Matrix4f.setIdentity(id); GColour col = View.getLDConfigColour(16); GData1 g1 = new GData1(-1, col.getR(), col.getG(), col.getB(), 1f, id, View.ACCURATE_ID, new ArrayList<String>(), null, null, 1, false, id, View.ACCURATE_ID, null, View.DUMMY_REFERENCE, true, false, new HashSet<String>(), View.DUMMY_REFERENCE); this.result = toLDrawTriangles(g1); return g1; }
Example #23
Source File: Camera.java From LowPolyWater with The Unlicense | 5 votes |
@Override public Matrix4f getProjectionViewMatrix() { if(reflected){ return Matrix4f.mul(projectionMatrix, reflectedMatrix, null); }else{ return Matrix4f.mul(projectionMatrix, viewMatrix, null); } }
Example #24
Source File: MatrixUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void testOrthoMatrix(final int left, final int right, final int bottom, final int top, final int near, final int far) { // Make an ortho matrix in opengl and pull it out into a Matrix4f GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(left, right, bottom, top, near, far); FloatBuffer fromGlBuffer = BufferUtils.createFloatBuffer(16); GL11.glGetFloat(GL11.GL_MODELVIEW, fromGlBuffer); Matrix4f fromGl = new Matrix4f(); fromGl.load(fromGlBuffer); Matrix4f manual = createOrthoMatrix(left, right, bottom, top, near, far); compare(fromGl, manual); }
Example #25
Source File: MathUtils.java From OpenModsLib with MIT License | 5 votes |
public static Matrix4f createEntityRotateMatrix(Entity entity) { double yaw = Math.toRadians(entity.rotationYaw - 180); double pitch = Math.toRadians(entity.rotationPitch); Matrix4f initial = new Matrix4f(); initial.rotate((float)pitch, new Vector3f(1, 0, 0)); initial.rotate((float)yaw, new Vector3f(0, 1, 0)); return initial; }
Example #26
Source File: Maths.java From LowPolyWater with The Unlicense | 5 votes |
public static void updateViewMatrix(Matrix4f viewMatrix, float x, float y, float z, float pitch, float yaw){ viewMatrix.setIdentity(); Matrix4f.rotate((float) Math.toRadians(pitch), new Vector3f(1, 0, 0), viewMatrix, viewMatrix); Matrix4f.rotate((float) Math.toRadians(yaw), new Vector3f(0, 1, 0), viewMatrix, viewMatrix); Vector3f negativeCameraPos = new Vector3f(-x, -y, -z); Matrix4f.translate(negativeCameraPos, viewMatrix, viewMatrix); }
Example #27
Source File: VectorUtils.java From ForgeHax with MIT License | 5 votes |
private static void VecTransformCoordinate(Vector4f vec, Matrix4f matrix) { float x = vec.x; float y = vec.y; float z = vec.z; vec.x = (x * matrix.m00) + (y * matrix.m10) + (z * matrix.m20) + matrix.m30; vec.y = (x * matrix.m01) + (y * matrix.m11) + (z * matrix.m21) + matrix.m31; vec.z = (x * matrix.m02) + (y * matrix.m12) + (z * matrix.m22) + matrix.m32; vec.w = (x * matrix.m03) + (y * matrix.m13) + (z * matrix.m23) + matrix.m33; }
Example #28
Source File: Animator.java From OpenGL-Animation with The Unlicense | 5 votes |
/** * This method should be called each frame to update the animation currently * being played. This increases the animation time (and loops it back to * zero if necessary), finds the pose that the entity should be in at that * time of the animation, and then applies that pose to all the model's * joints by setting the joint transforms. */ public void update() { if (currentAnimation == null) { return; } increaseAnimationTime(); Map<String, Matrix4f> currentPose = calculateCurrentAnimationPose(); applyPoseToJoints(currentPose, entity.getRootJoint(), new Matrix4f()); }
Example #29
Source File: Manipulator.java From ldparteditor with MIT License | 5 votes |
public void loadIntoMatrix(Matrix4f transformation) { transformation.setIdentity(); transformation.m30 = position.x; transformation.m31 = position.y; transformation.m32 = position.z; transformation.m00 = xAxis.x; transformation.m01 = xAxis.y; transformation.m02 = xAxis.z; transformation.m10 = yAxis.x; transformation.m11 = yAxis.y; transformation.m12 = yAxis.z; transformation.m20 = zAxis.x; transformation.m21 = zAxis.y; transformation.m22 = zAxis.z; }
Example #30
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public static Matrix4f glOrtho(double l, double r, double b, double t, double n, double f) { Matrix4f result = new Matrix4f(); result.m00 = (float) (2 / (r - l)); result.m30 = (float) (- (r + l) / (r - l)); result.m11 = (float) (2 / (t - b)); result.m31 = (float) (- (t + b) / (t - b)); result.m22 = (float) (- 2 / (f - n)); result.m23 = (float) (- (f + n) / (f - n)); result.m33 = 1f; return result; }