Procedural Mesh

I am having trouble creating a procedural mesh from user defined vertices. the user can place any amount of vertices then the program creates the triangles. so far i have not been able to get it to work right, my code always leaves gaps or creates triangles outside of the defined shape. any ideas?

alt text