Example usage for com.badlogic.gdx.graphics.g3d.utils MeshBuilder end

List of usage examples for com.badlogic.gdx.graphics.g3d.utils MeshBuilder end

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.utils MeshBuilder end.

Prototype

public Mesh end() 

Source Link

Document

End building the mesh and returns the mesh

Usage

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

License:Open Source License

public TilePermissionsGridDisplayable(Tile[][] tiles, TextureAtlas atlas) {
    this.atlas = atlas;

    MeshBuilder meshBuilder = new MeshBuilder();

    meshBuilder.begin(VertexAttributes.Usage.Position | VertexAttributes.Usage.TextureCoordinates,
            GL20.GL_TRIANGLES);//from w w  w  . j av  a 2  s .c o m

    for (int y = 0; y < tiles.length; y++) {
        for (int x = 0; x < tiles[y].length; x++) {
            // TODO: Cache regions
            meshBuilder.setUVRange(atlas.findRegion(tiles[y][x].getPermissions().name()));

            meshBuilder.rect(x, y, 0, x + 1, y, 0, x + 1, y + 1, 0, x, y + 1, 0, 0, 0, 1);
        }
    }

    Mesh mesh = meshBuilder.end();

    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();

    TextureAttribute diffuse = TextureAttribute.createDiffuse(atlas.getTextures().first());

    modelBuilder.part("grid", mesh, GL20.GL_TRIANGLES, new Material(diffuse));

    instance = new ModelInstance(modelBuilder.end());

    instance.transform.translate(0, 0, Z_OFFSET);
}