List of usage examples for com.badlogic.gdx.math Matrix4 translate
public Matrix4 translate(float x, float y, float z)
From source file:CB_Locator.Map.MapViewBase.java
License:Open Source License
protected void renderDebugInfo(Batch batch) { CB_RectF r = this.thisWorldRec; Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST); BitmapFont font = Fonts.getNormal(); font.setColor(Color.BLACK);/* w ww . j a v a 2 s . c o m*/ Matrix4 def = new Matrix4().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); def.translate(r.getX(), r.getY(), 1); batch.setProjectionMatrix(def); // str = debugString; font.draw(batch, str, 20, 120); str = "fps: " + Gdx.graphics.getFramesPerSecond(); font.draw(batch, str, 20, 100); str = String.valueOf(aktZoom) + " - camzoom: " + Math.round(camera.zoom * 100) / 100; font.draw(batch, str, 20, 80); str = "lTiles: " + mapTileLoader.LoadedTilesSize() + " - qTiles: " + mapTileLoader.QueuedTilesSize(); font.draw(batch, str, 20, 60); str = "lastMove: " + lastMovement.x + " - " + lastMovement.y; font.draw(batch, str, 20, 20); Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); }
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) */// ww w . j a v a 2s . c om @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
@Override public void postTranslate(float cx, float cy) { Matrix4 m = new Matrix4(); m.translate(cx, cy, 0); m.mul(this.matrix4); set(m);/*from ww w. j av a 2 s . co m*/ }
From source file:CB_UI_Base.graphics.Images.VectorDrawable.java
License:Open Source License
@Override public void draw(Batch batch, float x, float y, float width, float height) {// Draw only not rotate if (isDisposed.get()) { return;//from w w w . jav a 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); GL.batch.setProjectionMatrix(oriMatrix); }
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;/*from ww w. j av a2 s .c om*/ } 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:com.kotcrab.vis.runtime.system.render.TextRenderSystem.java
License:Apache License
private void updateText(int entityId) { Matrix4 translationMatrix = text.getTranslationMatrix(); GlyphLayout layout = text.getGlyphLayout(); if (text.isAutoSetOriginToCenter()) { origin.setOrigin(layout.width / 2, layout.height / 2); }//from w w w. ja v a 2 s.c o m translationMatrix.idt(); translationMatrix.translate(transform.getX() + origin.getOriginX(), transform.getY() + origin.getOriginY(), 0); translationMatrix.rotate(0, 0, 1, transform.getRotation()); translationMatrix.scale(transform.getScaleX(), transform.getScaleY(), 1); translationMatrix.translate(-origin.getOriginX(), -origin.getOriginY(), 0); translationMatrix.translate(0, layout.height, 0); //assign vertices, similar to: (we can skip zeros) //Polygon polygon = new Polygon(new float[]{0, 0, // textLayout.width, 0, // textLayout.width, textLayout.height, // 0, textLayout.height}); polygonVerts[2] = layout.width; polygonVerts[4] = layout.width; polygonVerts[5] = layout.height; polygonVerts[7] = layout.height; polygon.setPosition(transform.getX(), transform.getY()); polygon.setRotation(transform.getRotation()); polygon.setScale(transform.getScaleX(), transform.getScaleY()); polygon.setOrigin(origin.getOriginX(), origin.getOriginY()); text.updateBounds(polygon.getBoundingRectangle()); }
From source file:com.lyeeedar.Roguelike3D.Game.LevelObjects.Door.java
License:Open Source License
@Override public void update(float delta, Camera cam) { if (particleEffect != null) { particleEffect.update(delta, cam); }// w w w.j av a2s . c o m if (moving) { if (!open) { angle += delta * 100; if (angle > 90) { angle = 90; solid = false; open = true; moving = false; } Matrix4 hinge = new Matrix4(); hinge.translate(-hingex, 0, -hingez); hinge.rotate(0, 1, 0, angle); hinge.translate(hingex, 0, hingez); vo.attributes.getRotation().set(hinge); } else { solid = true; angle -= delta * 100; if (angle < 0) { open = false; angle = 0; moving = false; } Matrix4 hinge = new Matrix4(); hinge.translate(-hingex, 0, -hingez); hinge.rotate(0, 1, 0, angle); hinge.translate(hingex, 0, hingez); vo.attributes.getRotation().set(hinge); } } }
From source file:com.mbrlabs.mundus.commons.g3d.MG3dModelLoader.java
License:Apache License
private ModelNode parseNodesRecursively(JsonValue json) { ModelNode jsonNode = new ModelNode(); String id = json.getString("id", null); if (id == null) throw new GdxRuntimeException("Node id missing."); jsonNode.id = id;//from www. ja v a 2 s . co m JsonValue translation = json.get("translation"); if (translation != null && translation.size != 3) throw new GdxRuntimeException("Node translation incomplete"); jsonNode.translation = translation == null ? null : new Vector3(translation.getFloat(0), translation.getFloat(1), translation.getFloat(2)); JsonValue rotation = json.get("rotation"); if (rotation != null && rotation.size != 4) throw new GdxRuntimeException("Node rotation incomplete"); jsonNode.rotation = rotation == null ? null : new Quaternion(rotation.getFloat(0), rotation.getFloat(1), rotation.getFloat(2), rotation.getFloat(3)); JsonValue scale = json.get("scale"); if (scale != null && scale.size != 3) throw new GdxRuntimeException("Node scale incomplete"); jsonNode.scale = scale == null ? null : new Vector3(scale.getFloat(0), scale.getFloat(1), scale.getFloat(2)); String meshId = json.getString("mesh", null); if (meshId != null) jsonNode.meshId = meshId; JsonValue materials = json.get("parts"); if (materials != null) { jsonNode.parts = new ModelNodePart[materials.size]; int i = 0; for (JsonValue material = materials.child; material != null; material = material.next, i++) { ModelNodePart nodePart = new ModelNodePart(); String meshPartId = material.getString("meshpartid", null); String materialId = material.getString("materialid", null); if (meshPartId == null || materialId == null) { throw new GdxRuntimeException("Node " + id + " part is missing meshPartId or materialId"); } nodePart.materialId = materialId; nodePart.meshPartId = meshPartId; JsonValue bones = material.get("bones"); if (bones != null) { nodePart.bones = new ArrayMap<String, Matrix4>(true, bones.size, String.class, Matrix4.class); int j = 0; for (JsonValue bone = bones.child; bone != null; bone = bone.next, j++) { String nodeId = bone.getString("node", null); if (nodeId == null) throw new GdxRuntimeException("Bone node ID missing"); Matrix4 transform = new Matrix4(); JsonValue val = bone.get("translation"); if (val != null && val.size >= 3) transform.translate(val.getFloat(0), val.getFloat(1), val.getFloat(2)); val = bone.get("rotation"); if (val != null && val.size >= 4) transform.rotate( tempQ.set(val.getFloat(0), val.getFloat(1), val.getFloat(2), val.getFloat(3))); val = bone.get("scale"); if (val != null && val.size >= 3) transform.scale(val.getFloat(0), val.getFloat(1), val.getFloat(2)); nodePart.bones.put(nodeId, transform); } } jsonNode.parts[i] = nodePart; } } JsonValue children = json.get("children"); if (children != null) { jsonNode.children = new ModelNode[children.size]; int i = 0; for (JsonValue child = children.child; child != null; child = child.next, i++) { jsonNode.children[i] = parseNodesRecursively(child); } } return jsonNode; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java
License:Apache License
/** transforms the given matrix according to the given orientation * @param mat the matrix to transform//from w ww . jav a 2s . c o m * @param orientation the orientation */ public void transform(Matrix4 mat, String orientation) { mat.idt(); if (orientation.equals(aliases.isometric)) { mat.scale((float) (Math.sqrt(2) / 2), (float) (Math.sqrt(2) / 4), 1); mat.rotate(0, 0, 1, -45); mat.translate(-1, 1, 0); mat.scale(unitScale * 2, unitScale * 2, unitScale * 2); } else if (orientation.equals(aliases.staggered)) { mat.scale(unitScale, unitScale, unitScale); int mapHeight = findProperty(aliases.height, 0, mapProperties, layerProperties); mat.translate(-tileWidth / 2, -tileHeight * (mapHeight / 2) + tileHeight / 2, 0); } else mat.scale(unitScale, unitScale, unitScale); }
From source file:se.danielj.skuttandenyancat.Credits.java
License:GNU General Public License
@Override public void create() { camera = new OrthographicCamera(Constants.FRAME_WIDTH * 2, Constants.FRAME_HEIGHT * 2); logo = SpriteManager.getSprite("1gam-logo"); menuButtonAtlas = SpriteManager.getSprite("pause-menu-button"); menuButtonPressedAtlas = SpriteManager.getSprite("pause-menu-button-pressed"); batch = new SpriteBatch(); batch.setProjectionMatrix(camera.combined); Matrix4 m = new Matrix4(); m.translate(-Constants.FRAME_WIDTH, -Constants.FRAME_HEIGHT, 0); batch.setTransformMatrix(m);//w ww . j a va 2s . c om font = FontManager.getFontHalf(); buttonFont = FontManager.getFont(); stage = new Stage(); stage.setViewport(Constants.FRAME_WIDTH * 2, Constants.FRAME_HEIGHT * 2, false); inputMultiplexer.addProcessor(stage); stage.addActor(new MenuButton("Return", 0, new MenuButtonListener() { @Override protected void action() { controller.setScene(Scene.MAIN_MENU); } })); LabelStyle labelStyle = new LabelStyle(); font.setScale(0.5f); labelStyle.font = font; String textString = "Skuttande Nyan Cat was made during January 2013 for One Game A Month\n\n\n\n\nProgramming & graphics: Daniel \"MaTachi\" Jonsson, www.danielj.se\n\nJava libraries: LibGDX & Artemis\nFonts: Consola Mono & Intuitive\nBackground music: Nyanyanyanyanyanyanya! by daniwellP\nSoftware used: Eclipse, GIMP, Aseprite & MyPaint on Ubuntu\nSound effects editor used: as3sfxr"; text = new Label(textString, labelStyle); text.setPosition(60, 180); inputMultiplexer.addProcessor(this); }