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

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

Introduction

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

Prototype

@Override
    public void setUVRange(TextureRegion region) 

Source Link

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  www.  ja  v  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);
}