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

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

Introduction

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

Prototype

public Matrix4 trn(float x, float y, float z) 

Source Link

Document

Adds a translational component to the matrix in the 4th column.

Usage

From source file:kyle.game.besiege.location.Location.java

License:Open Source License

public void drawText(SpriteBatch batch) {
    float size_factor = 1.4f;

    if ((this.type == LocationType.VILLAGE))
        size_factor = .5f * size_factor;
    if ((this.type == LocationType.CASTLE))
        size_factor = .7f * size_factor;

    Color temp = batch.getColor();
    float zoom = getKingdom().getMapScreen().getCamera().zoom;
    zoom *= size_factor;//ww  w . ja v a 2s. c o  m

    // TODO do some vector calculations to make this rotate   
    // TODO create a bunch more fonts for smoother scrolling!
    // TODO do this in Kingdom at the end of everything
    // don't draw village names at a certain point.
    if (!(this.type == LocationType.VILLAGE && zoom > 1.5) && !(this.type == LocationType.CASTLE && zoom > 3)) {
        BitmapFont font;

        if (zoom > 7) {
            font = Assets.pixel150;
            zoom = 7;
        } else if (zoom > 5) {
            font = Assets.pixel100;
            zoom = 5;
        } else if (zoom > 4) {
            font = Assets.pixel80;
            zoom = 4;
        } else if (zoom > 3) {
            font = Assets.pixel64;
            zoom = 3;
        }
        // add some fonts here for smoothness
        else if (zoom > 2.5) {
            font = Assets.pixel50;
            zoom = 2.5f;
        } else if (zoom > 2) {
            font = Assets.pixel40;
            zoom = 2f;
        } else if (zoom > 1.5) {
            font = Assets.pixel30;
            zoom = 1.5f;
        } else if (zoom > 1.2) {
            font = Assets.pixel24;
            zoom = 1.2f;
        } else if (zoom > 1) {
            font = Assets.pixel20;
            zoom = 1f;
        } else if (zoom > .75) {
            font = Assets.pixel15;
            zoom = .75f;
        } else {
            font = Assets.pixel12;
            zoom = .6f;
        }
        String toDraw = getName();

        Matrix4 mx4Font = new Matrix4();
        mx4Font.trn((getX() - (int) (4.3 * toDraw.length()) * zoom), (getY() - 5 - 5 * zoom), 0);
        mx4Font.setToRotation(new Vector3(0, 0, 1), getKingdom().getMapScreen().getRotation());
        Matrix4 tempMatrix = batch.getTransformMatrix();
        batch.setTransformMatrix(mx4Font);

        //         // draw crest
        Color clear_white = new Color();
        clear_white.b = 1;
        clear_white.r = 1;
        clear_white.g = 1;
        clear_white.a = .8f;
        //         batch.setColor(clear_white);
        //         batch.draw(this.getFaction().crest, getCenterX() - 14*zoom, getCenterY() + 13, 30*zoom, 45*zoom);
        //         batch.setColor(temp);

        // draw text
        font.setColor(clear_white);
        font.draw(batch, toDraw, getX() - (int) (4.3 * toDraw.length()) * zoom, getY() - 5 - 5 * zoom);

        batch.setTransformMatrix(tempMatrix);
    }
}