using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MeshEditor
{
    public static Mesh DrawMeshByCoordinates(Mesh tempMesh, Vector3[] Vertices, int[] Triangles, Vector2[] uvs, Vector3 startPoint, Vector3 endPoint, float width)
    {
        Vertices[0] = new Vector3(startPoint.x - width, startPoint.y, startPoint.z);
        Vertices[1] = new Vector3(startPoint.x, startPoint.y - width, startPoint.z);
        Vertices[2] = new Vector3(startPoint.x + width, startPoint.y, startPoint.z);
        Vertices[3] = new Vector3(startPoint.x, startPoint.y + width, startPoint.z);
        // left  
        Vertices[4] = new Vector3(startPoint.x - width, startPoint.y, startPoint.z);
        Vertices[5] = new Vector3(startPoint.x, startPoint.y - width, startPoint.z);
        Vertices[6] = new Vector3(endPoint.x, endPoint.y - width, endPoint.z);
        Vertices[7] = new Vector3(endPoint.x - width, endPoint.y, endPoint.z);
        // back
        Vertices[8] = new Vector3(endPoint.x - width, endPoint.y, endPoint.z);
        Vertices[9] = new Vector3(endPoint.x, endPoint.y - width, endPoint.z);
        Vertices[10] = new Vector3(endPoint.x + width, endPoint.y, endPoint.z);
        Vertices[11] = new Vector3(endPoint.x, endPoint.y + width, endPoint.z);
        // right  
        Vertices[12] = new Vector3(endPoint.x, endPoint.y + width, endPoint.z);
        Vertices[13] = new Vector3(endPoint.x + width, endPoint.y, endPoint.z);
        Vertices[14] = new Vector3(startPoint.x + width, startPoint.y, startPoint.z);
        Vertices[15] = new Vector3(startPoint.x, startPoint.y + width, startPoint.z);
        // Top
        Vertices[16] = new Vector3(endPoint.x - width, endPoint.y, endPoint.z);
        Vertices[17] = new Vector3(endPoint.x, endPoint.y + width, endPoint.z);
        Vertices[18] = new Vector3(startPoint.x, startPoint.y + width, startPoint.z);
        Vertices[19] = new Vector3(startPoint.x - width, startPoint.y, startPoint.z);
        // Bottom
        Vertices[20] = new Vector3(endPoint.x, endPoint.y - width, endPoint.z);
        Vertices[21] = new Vector3(endPoint.x + width, endPoint.y, endPoint.z);
        Vertices[22] = new Vector3(startPoint.x + width, startPoint.y, startPoint.z);
        Vertices[23] = new Vector3(startPoint.x, startPoint.y - width, startPoint.z);
        tempMesh.vertices = Vertices;
        tempMesh.triangles = Triangles;
        tempMesh.uv = uvs;

        tempMesh.RecalculateNormals();
        return tempMesh;
    }
    
}
