APOCALYX is a...

free Game Engine based on OpenGL (MAIL) (SITE) (FORUM) (BLOG)

Sunday, June 29, 2008

Tubing and Extrusion

After the addition of a few primitive shapes in the last preview of the engine, I realized that is easy with only a little effort to add also other more interesting shapes. In fact, the engine already includes the GLE Tubing and Extrusion Library because another library, that draws 3D text, need it. In practice, GLE is useful to draw tubes or extruded surfaces in several fashions according to chosen parameters. The implementation is almost straightforward and I'm writing it right now.

As the author says: "GLE is a graphics application programming interface that consists of a number of subroutines for drawing tubing and extrusions. It is a very fast implementation of these shapes, outperforming all other implementations, most by orders of magnitude.
More in detail, GLE contains a collection of routines for drawing sweeps and extrusions. A "sweep" or "extrusion" is a 2D contour (polyline) that is swept or extruded along a 3D path (polyline). For example, sweeping a circle along a straight line will generate a cylinder. Sweeping a circle along a circular path will generate a doughnut (torus).
The library also includes a set of utility routines for drawing some of the more common extruded shapes: a polycylinder, a polycone, a generalized torus (circle swept along a helical path), a "helix" (arbitrary contour swept along a helical path) and a "lathe" (arbitrary contour swept along a helical path, with torsion used to keep the contour aligned).
The most general extrusion supported by this library allows an arbitrary 2D contour to be swept around an arbitrary 3D path. A set of normal vectors can be specified to go along with the contour; the normal vectors determine the appearance of the contour when lighting is turned on. A set of colors and affine matrices can be specified to go along with the 3D path. The colors are used to color along the path. The affine matrices are used to operate on the contour as it is swept along. If no affine matrices are specified, the contour is extruded using the mathematical concept of "parallel translation" or "Gaussian translation". That is, the contour is moved (and drawn) along the extrusion path in a "straight" manner. If there are affine matrices, they are applied to the contour at each extrusion segment before the segment is drawn.
The affine matrices allow work in a quasi-non-Euclidean space. They essentially allow the contour to be distorted as it is swept along. The allow the contour to be rotated, translated and rescaled as it is drawn. For example, a rescaling will turn a polycylinder into a poly-cone, since the circle that is being extruded is scaled to a different size at each extrusion vertex. A rotation allows the contour to be spun around while it is being extruded, thus for instance allowing drill-bit type shapes to be drawn. A translation allows the appearance of shearing in real space; that is, taking a contour and displacing it, without otherwise bending it.
"

No comments: