com.sun.j3d.utils.geometry
Class Triangulator

java.lang.Object
  |
  +--com.sun.j3d.utils.geometry.Triangulator

public class Triangulator
extends java.lang.Object

Triangulator is a utility for turning arbitrary polygons into triangles so they can be rendered by Java 3D. Polygons can be concave, nonplanar, and can contain holes (see GeometryInfo).


Constructor Summary
Triangulator()
          Creates a new instance of the Triangulator.
Triangulator(int earOrder)
          Creates a new instance of a Triangulator.
 
Method Summary
 void triangulate(GeometryInfo gi)
          This routine converts the GeometryInfo object from primitive type POLYGON_ARRAY to primitive type TRIANGLE_ARRAY using polygon decomposition techniques.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Triangulator

public Triangulator()
Creates a new instance of the Triangulator.

Triangulator

public Triangulator(int earOrder)
Creates a new instance of a Triangulator. This new Triangulator object will triangulate a given n-sized polygon based on the value of earOrder. There are 3 possible value for earOrder - EARS_SEQUENCE, EARS_RANDOM and EARS_SORTED. The value is to influence the pattern of the triangulation, by influencing the selection of ear to be clipped. EARS_SEQUENCE - the ears are clipped pretty much in the same order as they are detected. This results in fan-like triangulations. It is the fastest of all, and is used as the default setting. EARS_RANDOM - randomly selects an ear to be clipped among all the ears which can be clipped at that particular stage of the algorithm. This option tends to generate triangulations which are visually more pleasing. It usually produces triangulations which have less skinny triangles than the triangulations produced by EARS_SEQUENCE. EARS_SORTED - alway clip the ear that is the least skinny among all the ears that can be clipped. This produces triangles with better angular quality, but increases cpu and memory consumption.
Method Detail

triangulate

public void triangulate(GeometryInfo gi)
This routine converts the GeometryInfo object from primitive type POLYGON_ARRAY to primitive type TRIANGLE_ARRAY using polygon decomposition techniques.

 Example of usage:
   Triangulator tr = new Triangulator();
   tr.triangulate(ginfo); // ginfo contains the geometry.
   shape.setGeometry(ginfo.getGeometryArray()); // shape is a Shape3D.

Parameters:
ginfo - Geometry to be triangulated