Java Code Examples for com.badlogic.gdx.math.Matrix4#translate()
The following examples show how to use
com.badlogic.gdx.math.Matrix4#translate() .
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: SpinEffectFactory.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
@Override public void draw(Batch batch) { age += Gdx.graphics.getDeltaTime(); final float progress = age * INV_LIFETIME; final float currentSize = Interpolation.pow2In.apply(size, 0, progress); final float currentRotation = Interpolation.sine.apply(0, TOTAL_ROTATION, progress); final Matrix4 original = batch.getTransformMatrix().cpy(); final Matrix4 rotated = batch.getTransformMatrix(); final float disp = +0.5f * (size - currentSize) // the smaller, the more we need to "push" to center + currentSize * 0.5f; // center the cell for rotation rotated.translate(pos.x + disp, pos.y + disp, 0); rotated.rotate(0, 0, 1, currentRotation); rotated.translate(currentSize * -0.5f, currentSize * -0.5f, 0); // revert centering for rotation batch.setTransformMatrix(rotated); Cell.draw(color, batch, 0, 0, currentSize); batch.setTransformMatrix(original); }
Example 2
Source File: GameWorldRenderer.java From uracer-kotd with Apache License 2.0 | 5 votes |
private void renderTilemapPlane () { ShaderProgram shader = shNormalDepthNoDiffuse; float meshZ = -(camPersp.far - camPersp.position.z) + (camPersp.far * (1 - (camOrtho.zoom))); float k = OrthographicAlignedStillModel.BlenderToURacer; float scalex = 6, scalez = 4; Matrix4 model = mtx; tmpvec.set(camPersp.position.x, camPersp.position.y, meshZ + 0.5f); model.idt(); model.translate(tmpvec); model.rotate(1, 0, 0, 90); model.scale(scalex * k, 1, scalez * k); mtx2.set(camPersp.view).mul(model); nmat.set(mtx2).inv().transpose(); shader.begin(); shader.setUniformf("inv_depth_scale", DefaultSsaoScale); shader.setUniformf("near", camPersp.near); shader.setUniformf("far", camPersp.far); shader.setUniformMatrix("proj", camPersp.projection); shader.setUniformMatrix("view", camPersp.view); shader.setUniformMatrix("nmat", nmat); shader.setUniformMatrix("model", model); plane.render(shader, GL20.GL_TRIANGLE_FAN); shader.end(); }
Example 3
Source File: Tree.java From Skyland with MIT License | 5 votes |
private void growTree(BulletWorld world) { Matrix4 transform = stump.transform.cpy(); transform.translate(0, 1.15f, 0); BulletEntity staticTree = world.add("staticTree", transform); staticTree.body.setCollisionFlags(staticTree.body.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT); staticTree.body.setActivationState(com.badlogic.gdx.physics.bullet.collision.Collision.DISABLE_DEACTIVATION); staticTree.radius = 1.5f; staticTree.body.userData = new BulletUserData("staticTree", staticTree); this.tree = staticTree; }
Example 4
Source File: TrackTrees.java From uracer-kotd with Apache License 2.0 | 4 votes |
public void transform (PerspectiveCamera camPersp, OrthographicCamera camOrtho) { float meshZ = -(camPersp.far - camPersp.position.z) + (camPersp.far * (1 - (camOrtho.zoom))); for (int i = 0; i < models.size(); i++) { TreeStillModel m = models.get(i); Matrix4 transf = m.transformed; // compute position tmpvec.x = (m.positionOffsetPx.x - camPersp.position.x) + (camPersp.viewportWidth / 2) + m.positionPx.x; tmpvec.y = (m.positionOffsetPx.y + camPersp.position.y) + (camPersp.viewportHeight / 2) - m.positionPx.y; tmpvec.z = 1; tmpvec.x *= ScaleUtils.Scale; tmpvec.y *= ScaleUtils.Scale; tmpvec.x += ScaleUtils.CropX; tmpvec.y += ScaleUtils.CropY; // transform to world space camPersp.unproject(tmpvec, ScaleUtils.CropX, ScaleUtils.CropY, ScaleUtils.PlayWidth, ScaleUtils.PlayHeight); // build model matrix Matrix4 model = m.mtxmodel; tmpvec.z = meshZ; model.idt(); model.translate(tmpvec); model.rotate(m.iRotationAxis, m.iRotationAngle); model.scale(m.scaleAxis.x, m.scaleAxis.y, m.scaleAxis.z); // comb = (proj * view) * model (fast mul) transf.set(camPersp.combined).mul(m.mtxmodel); // transform the bounding box m.boundingBox.inf().set(m.localBoundingBox); m.boundingBox.mul(m.mtxmodel); // create an AABB out of the corners of the original // AABB transformed by the model matrix // bb.inf(); // Vector3[] corners = m.localBoundingBox.getCorners(); // for(int k = 0; k < corners.length; k++) // { // vtrans[k].x = corners[k].x; // vtrans[k].y = corners[k].y; // vtrans[k].z = corners[k].z; // vtrans[k].mul( tmpmtx ); // bb.ext(vtrans[k]); // } // // m.boundingBox.inf(); // m.boundingBox.set( bb ); } }