List of usage examples for com.badlogic.gdx.math Matrix4 mul
public Matrix4 mul(Matrix4 matrix)
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
/** * Postconcats the matrix with the specified matrix. M' = other * M *//*from ww w . j av a 2 s .c om*/ @Override public void postConcat(ext_Matrix matrix) { Matrix4 m = matrix.getMatrix4(); m.mul(this.matrix4); set(m); // this.matrix4.mul(matrix.getMatrix4()); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
/** * Preconcats the matrix with the specified translation. M' = M * T(x, y) *//*from ww w . j a v a 2 s . co m*/ @Override public void preTranslate(float x, float y) { Matrix4 m = new Matrix4(); m.translate(x, y, 0); m.mul(this.matrix4); set(m); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
/** * Preconcats the matrix with the specified scale. M' = M * S(x, y) *//*from ww w .j a v a 2s .c om*/ @Override public void preScale(float x, float y) { Matrix4 m = new Matrix4(); m.scale(x, y, 1); m.mul(this.matrix4); set(m); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
/** * Postconcats the matrix with the specified rotation. M' = R(degrees) * M *//*w w w . j a v a2 s .c om*/ @Override public void postRotate(float angle) { Matrix4 m = new Matrix4(); m.rotate(0, 0, 1, angle); m.mul(this.matrix4); set(m); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public void postScale(float rx, float ry) { Matrix4 m = new Matrix4(); m.scale(rx, ry, 1);//from w w w. j a v a2s . c om m.mul(this.matrix4); set(m); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public void postTranslate(float cx, float cy) { Matrix4 m = new Matrix4(); m.translate(cx, cy, 0);//from w ww. j av a 2 s . c o m m.mul(this.matrix4); set(m); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public void preRotate(float angle) { Matrix4 m = new Matrix4(); m.rotate(0, 0, 1, angle);//from w w w.j av a 2 s . com m.mul(this.matrix4); set(m); }
From source file:CB_UI_Base.graphics.Images.VectorDrawable.java
License:Open Source License
public void draw(Batch batch, float x, float y, final float width, final float height, float rotated) { if (isDisposed.get()) { return;/*w ww . j a va 2 s .c o m*/ } final Matrix4 oriMatrix = GL.batch.getProjectionMatrix().cpy(); Matrix4 thisDrawMatrix = oriMatrix.cpy(); thisDrawMatrix.translate(x, y, 0); drawFbo(batch, x, y, width, height, oriMatrix, thisDrawMatrix); for (MatrixDrawable drw : rotateDrawableList) { Matrix4 matrix = thisDrawMatrix.cpy(); ext_Matrix drwMatrix = new GL_Matrix(drw.matrix); matrix.mul(drwMatrix.getMatrix4().cpy()); GL.batch.setProjectionMatrix(matrix); drw.drawable.draw(GL.batch, 0, 0, width, height, -rotated * MathUtils.degreesToRadians); } GL.batch.setProjectionMatrix(oriMatrix); }
From source file:CB_UI_Base.graphics.Images.VectorDrawable.java
License:Open Source License
private void drawFbo(Batch batch, float x, float y, final float width, final float height, final Matrix4 oriMatrix, Matrix4 thisDrawMatrix) { final int fboScalerWidth = (int) (this.DEFAULT_WIDTH * FBO_SCALER); final int fboScalerHeight = (int) (this.DEFAULT_HEIGHT * FBO_SCALER); if (!RunOnGlSetted && m_fboEnabled && m_fboRegion == null) { RunOnGlSetted = true;/*from w w w .j a va 2s. c o m*/ GL.that.RunOnGL(new IRenderFBO() { @Override public void run() { synchronized (isDisposed) { if (isDisposed.get()) { return; } try { Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST); long start = System.currentTimeMillis(); m_fbo = new FrameBuffer(Format.RGBA8888, fboScalerWidth, fboScalerHeight, false); m_fboRegion = new TextureRegion(m_fbo.getColorBufferTexture()); m_fboRegion.flip(flipX, flipY); m_fbo.begin(); // clear screen Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); GL.batch.setColor(new Color(Color.WHITE)); GL.batch.begin(); Matrix4 matrix = new Matrix4().setToOrtho2D(0, 0, width, height); matrix.scale(FBO_SCALER, FBO_SCALER, 1); GL.batch.setProjectionMatrix(matrix); // draw Background GL.batch.disableBlending(); background.draw(GL.batch, 0, 0, fboScalerWidth, fboScalerHeight); GL.batch.enableBlending(); int count = 0; for (int i = 0, n = drawableList.size(); i < n; i++) { MatrixDrawable drw = drawableList.get(i); if (count++ > 2500) { GL.batch.flush(); count = 0; } matrix = new Matrix4().setToOrtho2D(0, 0, width, height); if (drw.matrix != null) { matrix.mul(drw.matrix.getMatrix4()); } GL.batch.setProjectionMatrix(matrix); drw.drawable.draw(GL.batch, 0, 0, width, height, 0); } if (m_fbo != null) { GL.batch.end(); m_fbo.end(); m_fboEnabled = false; } FBOisDrawed = true; FBO_DrawingTime = System.currentTimeMillis() - start; Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); GL.batch.setProjectionMatrix(oriMatrix); m_fboEnabled = false; } catch (Exception e) { e.printStackTrace(); } } } }); } if (m_fboRegion != null) { // TODO clear and release the drawables that drawed on m_fboRegion // if first drawing of m_fboRegion batch.draw(m_fboRegion, x, y, width, height); } else { int count = 0; for (int i = 0, n = drawableList.size(); i < n; i++) { MatrixDrawable drw = drawableList.get(i); if (!drw.reaelDraw) continue; if (count++ > 2500) { GL.batch.flush(); count = 0; } Matrix4 matrix = thisDrawMatrix.cpy(); if (drw.matrix != null) matrix.mul(drw.matrix.getMatrix4()); GL.batch.setProjectionMatrix(matrix); drw.drawable.draw(GL.batch, 0, 0, width, height, 0); } } }
From source file:com.badlogic.gdx.tests.android.MatrixTest.java
License:Apache License
@Override public void create() { font = new BitmapFont(); batch = new SpriteBatch(); Matrix4 m1 = new Matrix4(); Matrix4 m2 = new Matrix4(); float[] a1 = new float[16]; float[] a2 = new float[16]; float[] a3 = new float[16]; Matrix.setIdentityM(a1, 0);/*from w w w . ja va 2s .c o m*/ Matrix.setIdentityM(a2, 0); Matrix.setIdentityM(a3, 0); long startTime = System.nanoTime(); int ops = 0; while (System.nanoTime() - startTime < 5000000000l) { Matrix.multiplyMM(a1, 0, a2, 0, a3, 0); ops++; } results = "Matrix ops: " + ops + "\n"; // warm up startTime = System.nanoTime(); ops = 0; while (System.nanoTime() - startTime < 2000000000l) { m1.mul(m2); ops++; } startTime = System.nanoTime(); ops = 0; while (System.nanoTime() - startTime < 5000000000l) { m1.mul(m2); ops++; } results += "Matrix4 ops: " + ops + "\n"; }