Help with procedural mesh generation. Please!

Okay, so for the purposes of being succinct. I have several points that make up a circle and several circles evenly spaced and align with on another. I am trying to create a mesh, by getting and assigning the points to vertex array. I then create an array to store calculated triangle data (It’s kind of funky, but given how the data is laid out in the vertex array, it’s necessary to parse it out that way in order to get the correct indices for the triangle array). Now the problem, I can generate a mesh, but for some reason it is not complete, as you can see for them image further below.

Mesh mesh = GetComponent<MeshFilter>().mesh;

// get vertices
List<Vector3> vertices = new List<Vector3>();
for (int i = 1; i < pathSegments * segmentLength + 1; i++)
{
    vertices.AddRange(nodeList[i]);
}

int[] triangles = new int[vertices.Count * 3];

int a = 0;
int b = 1;
int c = 6;

int e = 1;
int f = 7;
int g = 6;

// easiest way I know how to get the alternating triangle indices. 
for (int i = 0; i < triangles.Length; i = i + 3)
{
    if (i % 2 == 0)
    {
        triangles[i] = a;
        triangles[i + 1] = b;
        triangles[i + 2] = c;
        a++;
        b++;
        c++;
    }
    else
    {
        triangles[i] = e;
        triangles[i + 1] = f;
        triangles[i + 2] = g;
        e++;
        f++;
        g++;
    }
}

// finally judgement time!
mesh.vertices = vertices.ToArray();
mesh.triangles = triangles;

This is the resulting mesh:

Any help would be greatly appreciated :slight_smile:

Nailed it!

What was the issue ? and How did you resolve it ?

I am trying to create something similar. Could you please share the code?