package cc.clv.BlueRobe.graphics;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.model.Node;
import com.badlogic.gdx.graphics.g3d.model.NodePart;
import com.badlogic.gdx.graphics.g3d.utils.MeshBuilder;

import cc.clv.BlueRobe.engine.GroundBlock;

public class GroundBlockModel extends Model {

    public static final float UNIT = 16f;
    public static final float WIDTH = UNIT * 11;
    public static final float HEIGHT = UNIT * 2;
    public static final float DEPTH = UNIT * 10;

    private final GroundBlock.Type type;

    public GroundBlockModel(GroundBlock.Type type) {
        this.type = type;

        switch (type) {
            case DebugWhite:
                createDebugBlock(Color.WHITE);
                break;
            case DebugGray:
                createDebugBlock(Color.LIGHT_GRAY);
                break;
            case Grass:
                createDebugBlock(new Color(0x88ff60ff));
                break;
            default:
                createDebugBlock(Color.DARK_GRAY);
        }
    }

    private void createDebugBlock(Color color) {
        Material material = new Material(ColorAttribute.createDiffuse(color));

        MeshBuilder meshBuilder = new MeshBuilder();
        meshBuilder.begin(VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);

        Node node = new Node();
        node.id = "block";
        node.parts.add(new NodePart(meshBuilder.part("base", GL20.GL_TRIANGLES), material));

        meshBuilder.box(WIDTH, HEIGHT, DEPTH);

        meshBuilder.end();

        nodes.add(node);
    }
}

@@ -1151,40 +1151,19 @@
 eate
-Debug
+Grass
 Block(
-new Color(0x88ff60ff)
 );%0A 
@@ -1773,24 +1773,24 @@
 der.end();%0A%0A
-
         node
@@ -1807,11 +1807,930 @@
 );%0A    %7D
+%0A%0A    private void createGrassBlock() %7B%0A        Color color1 = new Color(0x99ff70ff);%0A        Color color2 = new Color(0xaaff80ff);%0A%0A        Material material1 = new Material(ColorAttribute.createDiffuse(color1));%0A        Material material2 = new Material(ColorAttribute.createDiffuse(color2));%0A%0A        MeshBuilder meshBuilder = new MeshBuilder();%0A        float zBase = -DEPTH / 2 + UNIT / 2;%0A        for (int i = 0; i %3C 10; i++) %7B%0A            Material material = i %25 2 == 0 ? material1 : material2;%0A%0A            meshBuilder.begin(VertexAttributes.Usage.Position %7C VertexAttributes.Usage.Normal);%0A%0A            Node node = new Node();%0A            node.id = %22line-%22 + i;%0A            node.parts.add(new NodePart(meshBuilder.part(%22base%22, GL20.GL_TRIANGLES), material));%0A%0A            meshBuilder.box(0, 0, zBase + UNIT * i, WIDTH, HEIGHT, UNIT);%0A%0A            meshBuilder.end();%0A%0A            nodes.add(node);%0A        %7D%0A    %7D
 %0A%7D%0A

Change grass block pattern