Package com.badlogic.gdx.math
Class EarClippingTriangulator
- java.lang.Object
-
- com.badlogic.gdx.math.EarClippingTriangulator
-
public class EarClippingTriangulator extends java.lang.ObjectA simple implementation of the ear cutting algorithm to triangulate simple polygons without holes. For more information:- http://cgm.cs.mcgill.ca/~godfried/ teaching/cg-projects/97/Ian/algorithm2.html
- http://www.geometrictools.com/Documentation /TriangulationByEarClipping.pdf
If the polygon vertices are very large or very close together then
GeometryUtils.isClockwise(float[], int, int)may not be able to properly assess the winding (because it uses floats). In that case the vertices should be adjusted, eg by finding the smallest X and Y values and subtracting that from each vertex.
-
-
Constructor Summary
Constructors Constructor Description EarClippingTriangulator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ShortArraycomputeTriangles(float[] vertices)ShortArraycomputeTriangles(float[] vertices, int offset, int count)Triangulates the given (convex or concave) simple polygon to a list of triangle vertices.ShortArraycomputeTriangles(FloatArray vertices)
-
-
-
Method Detail
-
computeTriangles
public ShortArray computeTriangles(FloatArray vertices)
- See Also:
computeTriangles(float[], int, int)
-
computeTriangles
public ShortArray computeTriangles(float[] vertices)
- See Also:
computeTriangles(float[], int, int)
-
computeTriangles
public ShortArray computeTriangles(float[] vertices, int offset, int count)
Triangulates the given (convex or concave) simple polygon to a list of triangle vertices.- Parameters:
vertices- pairs describing vertices of the polygon, in either clockwise or counterclockwise order.- Returns:
- triples of triangle indices in clockwise order. Note the returned array is reused for later calls to the same method.
-
-