Triangulation

Hey, I have an object of class java.awt.Polygon (extends java.awt.Shape) which currently has stored in it a set of vertices. I can retrieve the order and positions of the vertices in 2D space using the PathIterator from the Polygon class.

I was hoping to be able to render the Shape using those set of vertices in Xith3D, however Xith3D only renders in triangles/quads not polygons (correct me if I’m wrong here) so I was wondering if anybody knew of any algorithms or links to such algorithms that might be able to form a set of triangles out of the given set of points?

Bit of a strange question I know, just wondering if anybody could think of a workaround/solution though?

Thanks in advance.

Hi,

You can use GLU Tesselator from net.java.games.jogl.impl.tesselator package. You should construct GLUtesselatorImpl object, set its options using gluTessProperty and define a tesselation callback using gluTessCallback. Inside methods of your callback object, you collect the triangle data and put it into float arrays that can after be used to construct Xith3D shapes.

Yuri