Use a geometry merge factory

From JReality Wiki
Jump to: navigation, search

Source file: GeometryMergeExample

JavaDoc: GeometryMergeFactory

Run as Java webstart

This example shows how to use an instance of GeometryMergeFactory. This factory is useful when you have the need to combine many small geometries into a single geometry.

The example constructs a small scene graph with several heterogeous geometries. It then uses a geometry merge factory to merge this scene graph into a single geometry; and displays the original scene graph and the merged result (translated appropriately) in a JRViewer instance.

This merging process can be tricky since the various geometries which are to be merged can be quite heterogeneous with respect to the their vertex, edge, and face attributes, while the resulting geometry must create a uniform version.

For example if one geometry has face colors set but another doesn't, the latter geometry will inherit its face color from the appearance state. The appearance state however must also be implicitly merged, so this information has to be translated into explicit face color information, typically by constructing a list of face colors which are all identical to the face color specified by the appearance state. Etc.

Similar problems arise if some of the vertex data is 3D while other is 4D (homogeneous). Then all such data is promoted to be 4D by setting homogeneous coordinate to 1.

Previous: Use a thickened surface factory Developer Tutorial: Contents Next: Use a clipping plane