List of usage examples for com.badlogic.gdx.math Matrix4 setToRotation
public Matrix4 setToRotation(final Vector3 v1, final Vector3 v2)
From source file:com.lyeeedar.Roguelike3D.Game.GameObject.java
License:Open Source License
public void rotate(float x, float y, float z, float angle) { Vector3 axis = Pools.obtain(Vector3.class).set(x, y, z); Matrix4 tmpMat = Pools.obtain(Matrix4.class).idt(); tmpMat.setToRotation(axis, angle); Pools.free(axis);/* ww w .j av a2 s . c o m*/ rotation.mul(tmpMat).nor(); up.mul(tmpMat).nor(); Pools.free(tmpMat); if (vo.attributes != null) { Vector3 lookAt = Pools.obtain(Vector3.class).set(0, 0, 0).add(rotation); vo.attributes.getRotation().setToLookAt(lookAt, up).inv(); Pools.free(lookAt); } }
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;//from w w w . j a v a 2 s. 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); } }