Subdivision classes
Overview
These classes provide a framework in which it is possible to
perform Catmull-Clark subdivision on polygon meshes. There are
two main classes:
-
Mesh, which builds a mesh
representation from an array of 3-tuples of floats,
representing the vertices of the mesh, and an array of
integers, representing the faces of the mesh in the
VRML/Inventor "coordIndex" style: a face is represented by a
sequence of numbers, corresponding to the index number of the
corner vertices, which are traced in counter-clockwise order,
and a -1 is used after the last corner. The Catmull-Clark
algorithm requires quadrilateral meshes.
-
VRMLDivide, which provides a
VRML
adaptor on top of Mesh. It allows you to create a mesh
from a VRML IndexedFaceSet, and output subdivided meshes as
VRML text. This text can then be turned into scene graph using
the VRML
Browser.createVrmlFromString
method.
Mesh
The Mesh constructor consumes an input mesh, which is specified by
two parameters:
int[] ci
Coordinate indices; specifies face
information. Every face is specified as a sequence of
non-negative integers, representing the indices of the vertices
making up it's corners. Data from different faces is separated
by a -1.
float[][] p
The vertices. An array of 3-tuples of points, which represent
x, y, and z coordinates.
It converts this representation into an internal structure
representing adjacency information. This internal structure
consists of
Faces,
Vertices, and
Stencils.
A Face knows it's neighboring faces and the Vertices making up
it's corners. This web of adjacency information remains unchanged
by subdivision, as it represents the adjacency at the coarsest
level only.
A Face also contains a set of Stencils, which represent subdivided
face information. Stencils are, conceptually, square arrays of
points (represented by the Point3
utility class). GetStencil
which will retrieve the nth stencil. The level 0 stencil contains
the coarse-level information. Other stencils are populated by
calling a
subdivision routine. The subdivision routine uses the stencil
at the next coarser level to construct the new level. The stencil
at level n contains a (2^n+1) by (2^n+1) array of points.
Accessor operations at the Stencil level allow access to points
neighoring any point in the Stencil, including those that may be
on another face.
This Face/Stencil/Vertex structure thus allows the conversion of
topological location on the mesh into actual, 3-dimensional
location.
VRMLDivide
The VMRLDivide constructor takes an SoIndexedFaceSet node, and a
field representing the coordIndex field of the SoIndexedFaceSet.
If the VRML API had been clever enough to make coordIndex an
exposedField, this extra parameter would not have been necessary.
The constructor ferrets through these elements looking for the
necessary inputs to the Mesh constructor and creates an internal
mesh.
The VRMLDivide class also exposes the Mesh's subdivision methods,
and a method to convert a subdivided mesh at a given level into
VRML text.
author