mapbox / earcut.hpp

Fast, header-only polygon triangulation
ISC License
858 stars 133 forks source link

Documentation? #7

Closed benadler closed 9 years ago

benadler commented 9 years ago

I'm new to triangulation/tesselation and wonder how to use this library. Could you please add a minimum of documentation to readme.md? Some questions I have after glancing over test.cpp:

A Polygon is a vector of vector of pairs of e.g. doubles. Is the first vector in the vector the outer ring, all following vectors are holes?

Taking the dude-fixture as an example, the first point is not repeated at the end. Is it legal to repeat it?

Does it support three dimensions?

When retrieving vertices and indices, are the indices and their order intended for GL_TRIANGLE_FAN, GL_TRIANGLES, GL_TRIANGLE_STRIP? Looking at test.cpp's trianglesArea() makes me think its GL_TRIANGLES. If so, is there an easy way to transform that into a VBO for GL_TRIANGLE_STRIP?

Thank you!

lyzidiamond commented 9 years ago

Hi @benadler! @kkaefer just added some documentation to the README last night. Take a look!

benadler commented 9 years ago

I read the readme, and it contains helpful information. It does not, however, answer any of my questions above.

mourner commented 9 years ago

Is the first vector in the vector the outer ring, all following vectors are holes?

Correct.

the first point is not repeated at the end. Is it legal to repeat it?

Yes, you can do either — the algorithm doesn't care, it trims out duplicate points.

Does it support three dimensions?

Not at this time.

When retrieving vertices and indices, are the indices and their order intended for GL_TRIANGLE_FAN, GL_TRIANGLES, GL_TRIANGLE_STRIP? Looking at test.cpp's trianglesArea() makes me think its GL_TRIANGLES.

Right, it's triangles.

If so, is there an easy way to transform that into a VBO for GL_TRIANGLE_STRIP?

Probably not, although I haven't look into this seriously.

kkaefer commented 9 years ago

If so, is there an easy way to transform that into a VBO for GL_TRIANGLE_STRIP?

You could use a library like http://www.nvidia.com/object/nvtristrip_library.html

benadler commented 9 years ago

That was very helpful, thanks to you both!