private Mesh CreateNorthMesh(UnitMeshModificationModel model) { var m = model; var mesh = new Mesh(); var vertices = new List <Vector3>() { V(m.WidthEndPoint, m.meshOrigin.y, 0), V(m.meshOrigin.x, m.HeightEndPoint, 0), V(m.meshOrigin.x, m.meshOrigin.y, 0), V(m.WidthEndPoint, m.HeightEndPoint, 0) }; mesh.SetVertices(vertices); var triangles = new List <int>() { 0, // First triangle - count the 2, 1, 0, // Second triangle 1, 3 }; mesh.SetTriangles(triangles, 0); var normals = new List <Vector3>() { Vector3.back, Vector3.back, Vector3.back, Vector3.back }; mesh.SetNormals(normals); var uvs = MeshUtilities.GetPlaneUVs(); mesh.SetUVs(0, uvs); mesh.RecalculateBounds(); ; return(mesh); }
private Mesh CreateFloorMesh(UnitMeshModificationModel model) { var m = model; var mesh = new Mesh(); var vertices = new List <Vector3>() { V(m.WidthEndPoint, 0, m.meshOrigin.z), V(m.meshOrigin.x, 0, m.DepthEndPoint), V(m.meshOrigin.x, 0, m.meshOrigin.z), V(m.WidthEndPoint, 0, m.DepthEndPoint) }; mesh.SetVertices(vertices); var triangles = new List <int>() { // original 0 1 2 1 0 3 2, // First triangle - count the 1, 0, 3, // Second triangle 0, 1 }; mesh.SetTriangles(triangles, 0); var normals = new List <Vector3>() { Vector3.up, Vector3.up, Vector3.up, Vector3.up }; mesh.SetNormals(normals); var uvs = MeshUtilities.GetPlaneUVs(); mesh.SetUVs(0, uvs); mesh.RecalculateBounds(); ; return(mesh); }