Question about procedural mesh (3)

Hello again,
I wonder what would be the best or easiest way to generate procedural mesh that have more than one segment such as the image representation below;

I can hand type all the vertices BUT that would take a lot of time and undesirable. Could anyone guide me about this? Thank you in advance!

If we assume that the line segment your drew in the OP should be made into a “ribbon”:
Add the DEPTH value to the Z-coordinate (into screen) to each vertex in your line segment. This would give you two sets of vertices, lets call them A and B for simplicity later on. (though actually they will be stored in the same vertex array.)

Setting up the vertex array: Keep in mind, when you define the triangles array, you will want to use the INDEX (an integer) of each vertex, in the vertex array. So, lets say you have N line segment points.

I would create your vertex array such that all of B’s points are after all of A’s points. Then A0 would be at index 0, A1 would be at index 1, B0 would be index N, B1 would be at index N+1… and so on.

Setting up the triangle array: Your first two triangles (together, forming a rectangle) will be the indexes of (A0, B0, B1), and (B1,B0,A1). (though I probably have the order of the vertices mixed up, I always do) Use a loop to get the rest of the triangles, for each line segment point, using the same pattern.

Note: if you want your ribbon to be visible from both sides, you will need to use a shader that does NOT “cull-backfaces”.