Example usage for com.badlogic.gdx.graphics.g3d.utils ModelBuilder createRect

List of usage examples for com.badlogic.gdx.graphics.g3d.utils ModelBuilder createRect

Introduction

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

Prototype

public Model createRect(float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11,
        float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ,
        final Material material, final long attributes) 

Source Link

Document

Convenience method to create a model with a single node containing a rectangle shape.

Usage

From source file:com.mygdx.Network.Client.Tile.java

public ModelInstance getOrCreateModel(ModelBuilder modelBuilder, PathFinder worldHandler,
        ArrayList<ModelInstance> instances, Player currentPlayer) {
    if (model != null) {
        Color asd = new Color();
        asd.r += (float) x / 48 - ((float) currentPlayer.x - 32) / 32 / 48 + 0.3;
        asd.g += (float) y / 48 - ((float) currentPlayer.y - 32) / 32 / 48 + 0.3;
        asd.b += (float) 0;

        Material Material = model.materials.get(0);
        Material.set(new Material(ColorAttribute.createDiffuse(asd), ColorAttribute.createSpecular(asd),
                FloatAttribute.createShininess(0)));

        return model;
    }/*from   w w  w. j  av a2s  . c  om*/

    float pz = -y * 32;
    float px = x * 32;
    Color asd = new Color();
    asd.r += (float) ((x - currentPlayer.x / 32) + 10) / 100;
    asd.g += (float) ((y - currentPlayer.y / 32) + 10) / 100;
    asd.b += (float) 0;

    Model floor = modelBuilder.createRect(px, worldHandler.getMap()[x][y].z, pz, px + 32,
            worldHandler.getMap()[x + 1][y].z, pz, px + 32, worldHandler.getMap()[x + 1][y + 1].z, pz - 32, px,
            worldHandler.getMap()[x][y + 1].z, pz - 32, 1f, 1f, -1f,
            new Material(ColorAttribute.createDiffuse(asd), ColorAttribute.createSpecular(asd),
                    FloatAttribute.createShininess(0)),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);

    model = new ModelInstance(floor);
    return model;

}