Java Code Examples for org.lwjgl.util.vector.Matrix4f#scale()
The following examples show how to use
org.lwjgl.util.vector.Matrix4f#scale() .
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: 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 2
Source File: PerspectiveCalculator.java From ldparteditor with MIT License | 5 votes |
/** * @return The real transformation matrix of the viewport */ public Matrix4f getRealViewport() { Matrix4f viewport_transform = new Matrix4f(); Matrix4f.setIdentity(viewport_transform); float zoom = c3d.getZoom(); Matrix4f.scale(new Vector3f(zoom, zoom, zoom), viewport_transform, viewport_transform); Matrix4f viewport_rotation = c3d.getRotation(); Matrix4f.mul(viewport_rotation, viewport_transform, viewport_transform); Matrix4f viewport_translation = c3d.getTranslation(); Matrix4f.mul(viewport_transform, viewport_translation, viewport_transform); return viewport_transform; }
Example 3
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glScalef(float x, float y, float z) { Matrix4f.scale(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 4
Source File: GDataPNG.java From ldparteditor with MIT License | 4 votes |
public GDataPNG(String text, Vertex offset, BigDecimal angleA, BigDecimal angleB, BigDecimal angleC, Vertex scale, String texturePath, GData1 parent) { super(parent); this.text = text; this.texturePath = texturePath; this.texture = new GTexture(TexType.PLANAR, texturePath, null, 0, new Vector3f(), new Vector3f(), new Vector3f(), 0, 0); this.offset = offset; this.scale = scale; this.angleA = angleA; this.angleB = angleB; this.angleC = angleC; { Matrix4f tMatrix2 = new Matrix4f(); tMatrix2.setIdentity(); tMatrix = tMatrix2.scale(new Vector3f(scale.x, scale.y, scale.z)); } Matrix4f dMatrix = new Matrix4f(); dMatrix.setIdentity(); Vector4f direction = new Vector4f(0f, 0f, -1f, 1f); // Matrix4f.rotate((float) (angleC.doubleValue() / 180.0 * Math.PI), new Vector3f(0f, 0f, 1f), dMatrix, dMatrix); Matrix4f.rotate((float) (angleB.doubleValue() / 180.0 * Math.PI), new Vector3f(1f, 0f, 0f), dMatrix, dMatrix); Matrix4f.rotate((float) (angleA.doubleValue() / 180.0 * Math.PI), new Vector3f(0f, 1f, 0f), dMatrix, dMatrix); Matrix4f.transform(dMatrix, direction, direction); direction.w = 0f; direction.normalise(); direction.w = 1f; this.direction = direction; dMatrix.setIdentity(); Matrix4f.rotate((float) (angleC.doubleValue() / 180.0 * Math.PI), new Vector3f(0f, 0f, 1f), dMatrix, dMatrix); Matrix4f.rotate((float) (angleB.doubleValue() / 180.0 * Math.PI), new Vector3f(1f, 0f, 0f), dMatrix, dMatrix); Matrix4f.rotate((float) (angleA.doubleValue() / 180.0 * Math.PI), new Vector3f(0f, 1f, 0f), dMatrix, dMatrix); Matrix4f.mul(dMatrix, tMatrix, tMatrix); Vector4f vx = Matrix4f.transform(dMatrix, new Vector4f(offset.x, 0f, 0f, 1f), null); Vector4f vy = Matrix4f.transform(dMatrix, new Vector4f(0f, offset.y, 0f, 1f), null); Vector4f vz = Matrix4f.transform(dMatrix, new Vector4f(0f, 0f, offset.z, 1f), null); tMatrix.m30 = vx.x; tMatrix.m31 = vx.y; tMatrix.m32 = vx.z; tMatrix.m30 += vy.x; tMatrix.m31 += vy.y; tMatrix.m32 += vy.z; tMatrix.m30 += vz.x; tMatrix.m31 += vz.y; tMatrix.m32 += vz.z; matrix = BufferUtils.createFloatBuffer(16); tMatrix.store(matrix); matrix.position(0); }