3

I'm using slimdx in c#, and my problem is a follows:
I have a list of vertices that forms a polygon, in linestrip format, and I need to transform it to a trianglestrip that covers the polygon.
I started with a center-of-mass calculation, however it only covers convex ones, and I need a general solution.
The final result should look smth like this:

Does anyone happens to know any algorithms for the issue?

Thanks.

Community
  • 1
  • 1
Dima.Go
  • 472
  • 2
  • 7
  • 17
  • how many triangles can you use? – elyashiv Oct 22 '12 at 21:08
  • How did you ended up with a collection of lone vertices? Shouldn't you create faces at the same time as you create vertices? Considering you have a linestrip, we actually need to know how your lines are listed to know how we could convert that into tris. Beside, you cannot cover this whole shape with a single linestrip... Are you sure it's a linestrip and you are correctly using it? – LightStriker Oct 22 '12 at 21:08
  • 2
    http://en.wikipedia.org/wiki/Polygon_triangulation – John Dvorak Oct 22 '12 at 21:11
  • some code would help describe your request – Majid Max Oct 22 '12 at 23:32
  • I'll try to be more specific: I have a collection, say an array, which represents vertices of a polygon. I need to re-create the polygon from said vertices, using triangles which fill the polygon. I the image above - find the middle vertex, and form a new collection which represents the same polygon. The purpose of this is to fill the polygon with a color, which (as far as I know) cannot be done with a built-in method of slimdx. – Dima.Go Oct 23 '12 at 13:06

1 Answers1

2

There's ear clipping algorithm that is quite nice for your use case, an example can be found here:

Ear clipping c#

mrvux
  • 8,523
  • 1
  • 27
  • 61