How to create a polygon

I'd like to create an arbitrary polygon from a list of points containing the polygon's vertices.

After looking at things, I'm thinking I should use the TriMesh class for this, right?  And this means I'll have triangulate the polygon myself, right?  Seems like kind of a lot of work just to draw a polygon.

I'm very much a noob to working with a 3d engine, so I'd appreciate any help I can get.

Triangulation of polygons is used somewhere in Font3D, maybe you can use this as starting point. In the first Font3D implementation I used an easy triangulation algorithm (ear cutting), but the resulting triangulation was not so good (and it had some problems with holes). The current implementation (not by me) uses a more complex algorithm giving better results, but could be harder to adopt. It all depends from what you want:

  • Do you have convex or concave polygons? Triangulation of an convex polygon is trivial.
  • How many points do you expect?
  • Do you need holes?
  • How important is the quality of the triangulation to you?

Hmm, well all of those things you listed would be nice, but for now I think I'll just limit myself to convex polygons and make the implementation myself.



I'd like to hereby place a vote for an officially sanctioned Polygon primitive in the main library :slight_smile:



Thanks for the help.




There is com.jmex.font3d.math.Triangulator, and there is my old implementation of a Triangulator class (http://www.jmonkeyengine.com/jmeforum/index.php?topic=3180.15). But I agree, a polygon primitive would be nice…