Closing off the top of a generated cylindrical mesh

Viewed 23

Im trying to make procedurally generated skyscrapers, so the code takes N number of Vector3 for the building shape and generates the mesh upwards. No problem so far, but im not quite sure how to generate the roof . While i think the easiest way would be to add a vertice at the center of the shape and generate all triangles from there, i think that would complicate things when it comes to generating the UV for the textures (or am i wrong?)

So how should i go about to find and create the vertices on the roof? the shape of the image is somewhat simple, but i want to also use concave shapes

enter image description here

1 Answers

Myself from the past: After some experimentations you will conclude there are two ways of doing this: enter image description here

They are both valid ways, but adding a vertice at the center Will create incorrect triangles on concave shapes and it also generates more triangles than needed.

Also, While the "not adding vertices" method is somewhat simple: (pick one vertex, create all triangles with that one vertex as the root) it will need a more complex algorithm when it comes to concave shapes.

You will also remember than the singular of vertices is vertex, but not before making the example image.

Related