Generate Polygon Plane from Array
Hello there. So I am trying to generate polygon plane (as a road) using by array I have which contains Vector3 items.
First, I draw a bezier curve, according to points on bezier curve, I determine bounds of my path. Now I'm trying to reshape/create a plane with those points to shape it into desired path.
void DrawMesh()
{
Vector3[] MeshBounds = new Vector3[CurvePoints.Length * 2];
Mesh mesh = Pathmesh.GetComponent<MeshFilter>().mesh;
mesh.Clear();
int index = 0;
foreach (Vector3 point in CurvePoints)
{
MeshBounds[index] = new Vector3(point.x - 5, point.y, point.z);
MeshBounds[index] = new Vector3(point.x + 5, point.y, point.z);
}
mesh.vertices = MeshBounds;
List<int> Larray = new List<int>();
for (int i = 1; i < CurvePoints.Length-2; i++)
{
Larray.Add(i - 1);
Larray.Add(i);
Larray.Add(i + 1);
}
mesh.triangles = Larray.ToArray();
mesh.RecalculateBounds();
mesh.RecalculateNormals();
mesh.name = "Path";
Pathmesh.GetComponent<MeshFilter>().mesh = mesh;
}
This is the piece of code that I'm trying to draw/reshape plane polygon. Problem is I can't see anything in the scene(Yes added to the scene).
What might be problem, which part of my approach is wrong ?
Edit1:
Just an idea, maybe creating saparate planes for each point and merge them with combine would fix my problem(ignore the code above). Result;
Short path appears by itself when I merge the planes that forms other part. Also I believe because of Z-Fight thingy, it flickers pretty bad.