I was recently given an assignment to generate a mesh from code, in Unity.
At runtime, the player will click at random positions on the screen. An array will store all these points. There must be at least 4 points for the calculation to take place. The users clicks will stop getting accepted once the player has clicked very close to the first clicked point (till here, I got it to work).
After all the points are added to the array/List, a mesh should be created from those points.
I thought of a few algorithms to work it out. First one - Delaunay triangulation
But what if there are 5 points on the same circle for the mesh? This negates the Delaunay's algorithm.
So I figured I'd first take the entire list of points, and parse through each point to find a convex hull. And then try to do each of the triangles within.
I'm not sure if I'm doing this the right way, or if there is any better way for what I want to do. If this is the best way, I don't know how to do the algorithm for the triangulation inside the convex hull