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

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

Introduction

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

Prototype

public Mesh updateVertices(int targetOffset, float[] source) 

Source Link

Document

Update (a portion of) the vertices.

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];
        }/*from  w  w w .  j  a  va2 s .c  om*/

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