So I decided to have a go at procedural mesh generation, it's something I'm quite interested in as it's very powerful - but confusing to say the least. Especially with all the arrays you need left and right.

I've taken it on myself to make a cylinder(12-sided for now), I've manged to make the necessary vertices like this;

I'm using DrawDebugCylinder so I have a point of reference to make sure I'm on the right track and from what I can tell so far it all checks out. I store all these vertices in an array which I then hook up with CreateMeshSection and so comes the hardest part. The god forsaken triangles.

Look, math isn't my cup of tea. I understand the concept of triangles, I've done some 3d work in the past but I just can't wrap my head around as to how I would go about making this an automatic process so I can resize and add more sides to my cylinder dynamically. I've managed to make one full face by creating two triangles and this is how I hooked them up;

I'm having a hard time seeing an obvious pattern here other than looping through the vertices on one end. For example 13 through 24, but then it becomes a spiderweb of jumping between the vertices on the other end.

If anyone got some suggestions that would be greatly appreciated! Should I generate the vertices differently or am I on the right track here?


Made some progress on this, will post the results once I've refined it a bit. Haven't capped the sides yet, but the sides are working.