Statement:
I'm creating a program that lets users lay out their own non-directional graph (nodes and edges). Once they press a specific button, I want to create a triangulated mesh out of each 'gap' in the graph. Here are two images that should give you an idea of what I'm after:
There are a few caveats:
- Since users have full control, I can get 3, 4, 5...n sided spaces
- A user can create either convex or concave shapes
- The application is being made in Unity with C#
My own attempts up to this point have been very inefficient and can fail in very unusual graph layouts. My general plan was to grab one node and follow the most acute angle around a cycle until I got back to the first node. This works in part, but I have no way of knowing if I've gotten every space. Additionally, I can end up with two identical meshes that cover the same space (albeit with a different node order).
I'd appreciate any help you can give me with this stumper. To help things along, I am already familiar with convex hull algorithms and triangulation.
Update:
I can't post any code because I'm under NDA for this project, but the data structures are pretty simple.
Nodes have a position (vector 3, but y is always 0) and a List of connected edges.
Edges have a first node, second node and a position (midpoint).
I want to generate a Mesh object for each gap. This mesh object has a static array of vertices (vector 3s) and a static array of triangles (which are ints and relate to vertex indices).