|
GeometryInfo and the Util Geometry ClassesSourced from java3d-interest list. The original question asked was:I've been experimenting with GeometryInfo for producing triangulations of arbitrary polygons, and according to the docs/examples, you should create an array of coordinates, assign them to a GeometryInfo, and then call Triangulator's triangulate() method to triangulate the polygon. However, in the runs I've done, if you omit the call to triangulate(), the polygon still gets triangulated (presumably by GeometryInfo itself). Calling the Triangulator constructor with an argument of 1 (EARS_RANDOM) will produce a different triangulation than that produced by GeometryInfo on its own, so the Triangulator object obviously does do something, but it seems that the default Triangulator (with no arguments to the constructor) just produces the same results as if it hadn't been called at all.
The reply posted by Paul Pantera of Sun is: GeometryInfo does a lot in the background. If you put your geometry into it as POLYGON_ARRAY and then immediately call getGeometryArray(), it will create a default triangulator and triangulate your data, then unindexify it, and then create the GeometryArray and pass it back. There's no other choice because you can't put polygons into a GeometryArray. The word "polygon" is never used anywhere in Java 3D except in GeometryInfo and the triangulator. To further expand this, the NormalGenerator and Stripifier only work on indexed triangles. Therefore, no matter what format your data is in, it will be converted to indexed triangles if you call the NormalGenerator or Stripfier. This is hidden from the user. If you send in quads and call the stripfier, you will get triangle strips out, and you won't know that your quads were converted to indexed triangles in the interim. If you send quads (or fans or strips) to the NormalGenerator, they get converted to indexed triangles before Normals are calculated. If you then call getGeometryArray(), the triangles are converted back to the original primitive in the most intelligent way possible. If it was originally fans or strips, it will attempt to stitch them back together, but it may have to break a strip in two if there was a hard edge in the middle of the strip. It does the same thing for quads. (There can't be a hard edge in the middle of a quad because the same facet normal is used by both sub-triangles of the quad). This probably rarely happens because most people aren't going to generate normals and then call getGeometryArray(), they're going to call the stripifier first. In that case, the data is left as indexed triangles and sent immediately to the stripifier. It's never converted back to the original primitive type. Keeping all that in mind, POLYGON_ARRAY is treated just like any other primitive by GeometryInfo. Before it can be sent to the NormalGenerator or Stripifier, it must first be converted to triangles. It uses the triangulator utility to do this. Where it differs from the other primitives is when you don't call the Stripifyer. If you call getGeometryArray() on POLYGON_ARRAY data without calling the stripifier, you will always get back individual triangles. So the answer to your question is yes, you don't need to call the triangulator explicitly (unless you want to specify the earOrder) because it gets called automatically when POLYGON_ARRAY data is used. Does it hurt to call it explicitly? Not much. The triangulator is smart enough to do nothing if the input data is already triangles. Homework:
|
|
[ j3d.org ]
[ Aviatrix3D ]
[ Code Repository ]
[ Java3D ]
[ OpenGL ]
[ Books ]
[ Contact Us ]
Hosted by Yumetech Last Updated: $Date: 2006/04/18 18:20:05 $ |