// Path: src/java/yaw/engine/meshs/strategy/BoundingBoxDrawingStrategy.java
// public class BoundingBoxDrawingStrategy implements MeshDrawingStrategy {
// 
//     @Override
//     public void drawMesh(Mesh pMesh) {
//         glEnable(GL_POLYGON_OFFSET_FILL);
//         glEnable(GL_PROGRAM_POINT_SIZE);
//         glPolygonOffset(1, 0);
//         glDrawElements(GL_LINES, pMesh.getIndices().length, GL_UNSIGNED_INT, 0);
//     }
// }
// 
// Path: src/java/yaw/engine/meshs/strategy/DefaultDrawingStrategy.java
// public class DefaultDrawingStrategy implements MeshDrawingStrategy {
// 
// 
//     @Override
//     public void drawMesh(Mesh pMesh) {
//         // Draw the mVertices
//         glDrawElements(GL_TRIANGLES, pMesh.getIndices().length, GL_UNSIGNED_INT, 0);
//     }
// 
// }


import yaw.engine.meshs.strategy.BoundingBoxDrawingStrategy;
import org.joml.Vector3f;
import yaw.engine.meshs.strategy.DefaultDrawingStrategy;
import java.util.HashMap;
import java.util.Map;
package yaw.engine.meshs;



/**
 * Generic Mesh generator, can create specific mesh just with a map (goal)
 */
public class MeshBuilder {
    private static final String BLOCK_MESH = "block";
    private static final String GROUND_MESH = "ground";
    private static final String HALF_BLOCK_MESH = "half-block";
    private static final String PYRAMID_MESH = "pyramid";
    private static final String OCTAHEDRON_MESH = "octahedron";
    private static final String TETRAHEDRON_MESH = "tetrahedron";
    //

    //TODO remove the text coord array, only use it for test

    /**
     * Generate a mesh with the specified material (cx, cy, cz, reflectance), width, length and height
     *
     * @param meshType meshType
     * @param xLength  width
     * @param yLength  length
     * @param zLength  height
     * @param cx       Red value of the material
     * @param cy       Green  value of the material
     * @param cz       Blue  value of the material
     * @return Mesh
     */
    @Deprecated
    public static Mesh generate(String meshType, float xLength, float yLength, float zLength, float cx, float cy, float cz) {
        Mesh mesh = null;
        /*Warning default reflectance*/
        Material lMaterial = null;
        try {
            lMaterial = new Material(new Vector3f(cx, cy, cz));
        } catch (Exception pE) {
            pE.printStackTrace();
        }
        //System.out.println(meshType);
        switch (meshType) {
            case BLOCK_MESH:
                mesh = generateBlock(xLength, yLength, zLength);
                break;
            case GROUND_MESH:
                mesh = generateGround(xLength, yLength, zLength);
                break;
            case HALF_BLOCK_MESH:
                mesh = generateHalfBlock(xLength, yLength, zLength);
                break;
            case PYRAMID_MESH:
                mesh = generatePyramid(xLength, yLength, zLength);
                break;
            case OCTAHEDRON_MESH:
                mesh = generateOctahedron();
                break;
            case TETRAHEDRON_MESH:
                mesh = generateTetrahedron();
                break;
            default:
                System.out.println("error");
        }
        if (mesh != null) mesh.setMaterial(lMaterial);
        return mesh;
        //return generate(xLength, yLength, zLength, new Material(new Vector3f(cx, cy, cz), r));
    }

    /**
     * Generate a BlockMesh with the specified material , width, length and height.
     * Create vertices based on the specified width, length and height.
     * Normals and indices are hard coded
     *
     * @param xLength xLength
     * @param yLength yLength
     * @param zLength zLength
     * @return BlockMesh
     */
    @Deprecated
    public static Mesh generateBlock(float xLength, float yLength, float zLength) {
        float x = xLength / 2f;
        float y = yLength / 2f;
        float z = zLength / 2f;
        float[] vertices = new float[]{
                //Front face
                x, y, z, -x, y, z, -x, -y, z, x, -y, z,
                //Top face
                x, y, z, -x, y, z, x, y, -z, -x, y, -z,
                //Back face
                x, y, -z, -x, y, -z, -x, -y, -z, x, -y, -z,
                //Bottom face
// Path: src/java/yaw/engine/meshs/strategy/BoundingBoxDrawingStrategy.java
// public class BoundingBoxDrawingStrategy implements MeshDrawingStrategy {
// 
//     @Override
//     public void drawMesh(Mesh pMesh) {
//         glEnable(GL_POLYGON_OFFSET_FILL);
//         glEnable(GL_PROGRAM_POINT_SIZE);
//         glPolygonOffset(1, 0);
//         glDrawElements(GL_LINES, pMesh.getIndices().length, GL_UNSIGNED_INT, 0);
//     }
// }
// 
// Path: src/java/yaw/engine/meshs/strategy/DefaultDrawingStrategy.java
// public class DefaultDrawingStrategy implements MeshDrawingStrategy {
// 
// 
//     @Override
//     public void drawMesh(Mesh pMesh) {
//         // Draw the mVertices
//         glDrawElements(GL_TRIANGLES, pMesh.getIndices().length, GL_UNSIGNED_INT, 0);
//     }
// 
// }


// Path: src/java/yaw/engine/meshs/MeshBuilder.java
import yaw.engine.meshs.strategy.BoundingBoxDrawingStrategy;
import org.joml.Vector3f;
import yaw.engine.meshs.strategy.DefaultDrawingStrategy;
import java.util.HashMap;
import java.util.Map;

package yaw.engine.meshs;



/**
 * Generic Mesh generator, can create specific mesh just with a map (goal)
 */
public class MeshBuilder {
    private static final String BLOCK_MESH = "block";
    private static final String GROUND_MESH = "ground";
    private static final String HALF_BLOCK_MESH = "half-block";
    private static final String PYRAMID_MESH = "pyramid";
    private static final String OCTAHEDRON_MESH = "octahedron";
    private static final String TETRAHEDRON_MESH = "tetrahedron";
    //

    //TODO remove the text coord array, only use it for test

    /**
     * Generate a mesh with the specified material (cx, cy, cz, reflectance), width, length and height
     *
     * @param meshType meshType
     * @param xLength  width
     * @param yLength  length
     * @param zLength  height
     * @param cx       Red value of the material
     * @param cy       Green  value of the material
     * @param cz       Blue  value of the material
     * @return Mesh
     */
    @Deprecated
    public static Mesh generate(String meshType, float xLength, float yLength, float zLength, float cx, float cy, float cz) {
        Mesh mesh = null;
        /*Warning default reflectance*/
        Material lMaterial = null;
        try {
            lMaterial = new Material(new Vector3f(cx, cy, cz));
        } catch (Exception pE) {
            pE.printStackTrace();
        }
        //System.out.println(meshType);
        switch (meshType) {
            case BLOCK_MESH:
                mesh = generateBlock(xLength, yLength, zLength);
                break;
            case GROUND_MESH:
                mesh = generateGround(xLength, yLength, zLength);
                break;
            case HALF_BLOCK_MESH:
                mesh = generateHalfBlock(xLength, yLength, zLength);
                break;
            case PYRAMID_MESH:
                mesh = generatePyramid(xLength, yLength, zLength);
                break;
            case OCTAHEDRON_MESH:
                mesh = generateOctahedron();
                break;
            case TETRAHEDRON_MESH:
                mesh = generateTetrahedron();
                break;
            default:
                System.out.println("error");
        }
        if (mesh != null) mesh.setMaterial(lMaterial);
        return mesh;
        //return generate(xLength, yLength, zLength, new Material(new Vector3f(cx, cy, cz), r));
    }

    /**
     * Generate a BlockMesh with the specified material , width, length and height.
     * Create vertices based on the specified width, length and height.
     * Normals and indices are hard coded
     *
     * @param xLength xLength
     * @param yLength yLength
     * @param zLength zLength
     * @return BlockMesh
     */
    @Deprecated
    public static Mesh generateBlock(float xLength, float yLength, float zLength) {
        float x = xLength / 2f;
        float y = yLength / 2f;
        float z = zLength / 2f;
        float[] vertices = new float[]{
                //Front face
                x, y, z, -x, y, z, -x, -y, z, x, -y, z,
                //Top face
                x, y, z, -x, y, z, x, y, -z, -x, y, -z,
                //Back face
                x, y, -z, -x, y, -z, -x, -y, -z, x, -y, -z,
                //Bottom face
                x, -y, z, -x, -y, z, x, -y, -z, -x, -y, -z,