Example usage for com.badlogic.gdx.graphics Mesh getVertices

List of usage examples for com.badlogic.gdx.graphics Mesh getVertices

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Mesh getVertices.

Prototype

public float[] getVertices(int srcOffset, int count, float[] vertices) 

Source Link

Document

Copies the specified vertices from the Mesh to the float array.

Usage

From source file:com.github.fauu.helix.editor.displayable.TilePermissionsGridDisplayable.java

License:Open Source License

public void updateTiles(HashMap<Integer, Tile> tilesWithIndices) {
    Mesh mesh = instance.model.meshes.first();

    // TODO: Get rid of magic numbers
    for (Map.Entry<Integer, Tile> tileWithIndex : tilesWithIndices.entrySet()) {
        int index = tileWithIndex.getKey();
        Tile tile = tileWithIndex.getValue();

        float[] vertices = new float[4 * 5];

        mesh.getVertices(index * 4 * 5, 4 * 5, vertices);

        TextureRegion region = atlas.findRegion(tile.getPermissions().name());

        float[] uv = new float[] { region.getU(), region.getV2(), region.getU2(), region.getV2(),
                region.getU2(), region.getV(), region.getU(), region.getV() };

        for (int i = 0; i < 4; i++) {
            vertices[i * 5 + 3] = uv[i * 2];
            vertices[i * 5 + 4] = uv[i * 2 + 1];
        }//ww  w.  j  av  a 2  s  .  com

        mesh.updateVertices(index * 4 * 5, vertices);
    }
}