Example usage for com.badlogic.gdx.math Matrix4 idt

List of usage examples for com.badlogic.gdx.math Matrix4 idt

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Matrix4 idt.

Prototype

public Matrix4 idt() 

Source Link

Document

Sets the matrix to an identity matrix.

Usage

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  .j  a va 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.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//  ww w  .ja va2  s. co  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);
}