|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.geom.TriangulationUtils
public class TriangulationUtils
Utility routines for triangulating arbitrary polygons.
The concave triangulation routine is designed for small numbers of vertices as it uses a much simpler, but slower algorithm that is O(kn) where k is the number of concave vertices, rather than the more efficient, but much more complex to implement Seidel's Algorithm. A summary of the implementation can be found here.
If at any time an error is detected in the input geometry, the return value of the triangulation methods will be a negative value. The number will still indicate the number of triangles successfully created for the return, but the negative is used to indicate an error occurred that could not allow for any more triangulation to take place.
Seidel's algorithm is described here: http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html
Constructor Summary | |
---|---|
TriangulationUtils()
Construct a new instance of the triangulation utilities. |
|
TriangulationUtils(int size)
Construct a new instance of the triangulation utilities with a given maximum polygon size hint. |
Method Summary | |
---|---|
void |
clearCachedObjects()
Clean up the internal cache and reduce it to zero. |
static boolean |
isConvexVertex(float[] coords,
int p0,
int p,
int p1,
float[] normal)
Check to see if this vertex is a concave vertex or convex. |
int |
triangulateConcavePolygon(float[] coords,
int[] coordOutput,
float[] normal)
Triangulate a concave polygon in the given array. |
int |
triangulateConcavePolygon(float[] coords,
int[] coordIndex,
int[] coordOutput,
float[] normal)
Triangulate a concave polygon using an indexed coordinates array. |
int |
triangulateConcavePolygon(float[] coords,
int startIndex,
int numVertex,
int[] coordOutput,
float[] normal)
Triangulate a concave polygon in the given array. |
int |
triangulateConcavePolygon(float[] coords,
int startIndex,
int numVertex,
int[] coordIndex,
int[] coordOutput,
float[] normal)
Triangulate a concave polygon using an indexed coordinates array. |
int |
triangulateConcavePolygon(float[] coords,
int startIndex,
int numVertex,
int[] coordIndex,
int firstNormalIndex,
int[] normalIndex,
int firstColorIndex,
int[] colorIndex,
int firstTexCoordIndex,
int[] texCoordIndex,
int[] coordOutput,
int[] normalOutput,
int[] colorOutput,
int[] texCoordOutput,
float[] normal)
Triangulate a concave polygon using an indexed coordinates array. |
int |
triangulateConcavePolygon(float[] coords,
int startIndex,
int numVertex,
int firstNormalIndex,
int firstColorIndex,
int firstTexCoordIndex,
int[] coordOutput,
int[] normalOutput,
int[] colorOutput,
int[] texCoordOutput,
float[] normal)
Triangulate a concave polygon in the given array. |
void |
triangulatePolygon2D(int numContours,
int[] contourCounts,
float[] vertices,
int[] triangles)
Triangulate a simple polygon that may have zero or more holes in it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TriangulationUtils()
public TriangulationUtils(int size)
size
- Hint to the maximum size of polygon to deal withMethod Detail |
---|
public void triangulatePolygon2D(int numContours, int[] contourCounts, float[] vertices, int[] triangles)
Each part of the polygon is defined by a set of contour points. The outer-most set of points must be defined in counter-clockwise order. All inner points must be defined in clock-wise order.
public int triangulateConcavePolygon(float[] coords, int startIndex, int numVertex, int[] coordIndex, int[] coordOutput, float[] normal)
If an error occurs, the result will be negative number of triangles.
coords
- The coordinates of the facestartIndex
- The index of the first coordinate in the facenumVertex
- The number of vertices to read from the listcoordOutput
- The array to copy the coord index values tonormal
- The normal to this face these vertices are a part of
public int triangulateConcavePolygon(float[] coords, int[] coordIndex, int[] coordOutput, float[] normal)
If an error occurs, the result will be negative number of triangles.
coords
- The coordinates of the facecoordOutput
- The array to copy the coord index values tonormal
- The normal to this face these vertices are a part of
public int triangulateConcavePolygon(float[] coords, int startIndex, int numVertex, int[] coordIndex, int firstNormalIndex, int[] normalIndex, int firstColorIndex, int[] colorIndex, int firstTexCoordIndex, int[] texCoordIndex, int[] coordOutput, int[] normalOutput, int[] colorOutput, int[] texCoordOutput, float[] normal)
If an error occurs, the result will be negative number of triangles.
coords
- The coordinates of the facestartIndex
- The index of the first coordinate in the facenumVertex
- The number of vertices to read from the listfirstNormalIndex
- The first position of the normalIndex arraynormalIndex
- The index of normals for each coordinatefirstColorIndex
- The first position of the colorIndex arraycolorIndex
- The index of color for each coordinatefirstTexCoordIndex
- The first position of the texCoordIndex arraytexCoordIndex
- The index of textureCoordinates for each coordinatecoordOutput
- The array to copy the coord index values tonormalOutput
- The array to copy the normal index values tocolorOutput
- The array to copy the color index values totexCoordOutput
- The array to copy the texCoord index values tonormal
- The normal to this face these vertices are a part of
public int triangulateConcavePolygon(float[] coords, int startIndex, int numVertex, int[] coordOutput, float[] normal)
If an error occurs, the result will be negative number of triangles.
coords
- The coordinates of the facestartIndex
- The index of the first coordinate in the facenumVertex
- The number of vertices to read from the listcoordOutput
- The array to copy the coord index values tonormal
- The normal to this face these vertices are a part of
public int triangulateConcavePolygon(float[] coords, int[] coordOutput, float[] normal)
If an error occurs, the result will be negative number of triangles.
coords
- The coordinates of the facecoordOutput
- The array to copy the coord index values tonormal
- The normal to this face these vertices are a part of
public int triangulateConcavePolygon(float[] coords, int startIndex, int numVertex, int firstNormalIndex, int firstColorIndex, int firstTexCoordIndex, int[] coordOutput, int[] normalOutput, int[] colorOutput, int[] texCoordOutput, float[] normal)
If an error occurs, the result will be negative number of triangles.
coords
- The coordinates of the facestartIndex
- The index of the first coordinate in the facenumVertex
- The number of vertices to read from the listfirstNormalIndex
- The first position of the normalIndex arrayfirstColorIndex
- The index of color for each coordinatefirstTexCoordIndex
- The first position of the texCoordIndex arraycoordOutput
- The array to copy the coord index values tonormalOutput
- The array to copy the normal index values tocolorOutput
- The array to copy the color index values totexCoordOutput
- The array to copy the texCoord index values tonormal
- The normal to this face these vertices are a part of
public void clearCachedObjects()
public static boolean isConvexVertex(float[] coords, int p0, int p, int p1, float[] normal)
coords
- The array to read coodinate values fromp0
- The index of the previous vertex to the one in questionp
- The index of the vertex being testedp1
- The index after the vertex after the one in questionnormal
- The normal to this face these vertices are a part of
|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |