- Home /
Create faces between vertices on a procedurally genererated map
My map looks like below. Currently it's displayed with a few hundred planes, but I want to turn it into a mesh. The vertices are already figured out (the blue dots) and I can extrude the walls upwards, however I have no idea how to create the floor properly so that I only have triangles between the dots.
Came up with one idea that you put vertices at a distance of 1 between each other and then through a few literations join them where they can be connected to make a bigger face. This however is not optimal since you start with a gigantic mesh if you level is big.
If someone knows how to do this and care explain or atleast have something I can read I'd be happy :)

It's not clear what information you already have. Just the vertices would be pointless unless they are already in order to describe a polygon outline. However your example is a polygon with two holes (3 seperate outlines). Do you have any further rules how those vertices are actually generated? The more restrictions there are, the easier the triangulation process is. For example it seems that your edges are always either horizontal or vertical?!?
You said you currently use planes. Have you created the planes also procedurally? Or have you placed them manually? If the planes have been generated, do they overlap or have you stitched them correctly?
Answer by wibble82 · Dec 21, 2015 at 05:46 PM
As @Bunny83 says, the points alone are meaningless (or could mean anything!). You would need extra data to generate your mesh.
The most general approach would be if your only information is what points are connected to what other points (i.e. you know the edges), then you have a classic triangulation problem - you have an outer polygon (the list of connected points that form your outer wall boundary, and (in your example) 2 'holes' - lists of connected points that define inner wall boundaries.
This problem is commonly referred to as 'triangulation of a polygon with holes'. It's none trivial, but there are various algorithms to solve it. This is a good paper on the subject:
https://www.cs.ucsb.edu/~suri/cs235/Triangulation.pdf
Though I suggest you do your own googling and find one you're happy trying to implement - or somebody else's code that already implements it! :)
-Chris
Answer by Fallc · Dec 21, 2015 at 04:34 PM
Phew.... I could think of something like this:
iterate trough all vertecies and create a line to the next closets vertex (in your case which is closest on a certain axis due your pretty rectangular geometry)
iterate trough all lines and find line pairs who share the same vertex somewhere, then build a triangle in the folowing order: vertex, shared vertex, vertex.
"discard" the vertex which is shared or rather make it not availabe anymore for other triangle creation. (otherwise you would have overlapping geometry, nasty!)
I can not prove that this would work, but I hope this gives you some input :)
Your answer