Extrusions are interesting because they potentially provide for a compact representation of surface data. A swept surface of m points by n points requires O(m x n) bytes of data to represent it as a quadrilateral mesh. The same surface requires only O(m + n) bytes when represented as a sweep.
Extrusions are also interesting because they allow a designer to specify complex shapes in a simple manner.
This proposal is based on the API provided through the freely available tubing and extrusion library. The tubing and extrusion library is a C language API that renders extrusions through OpenGL. It automatically generates the surface, normals for lighting, and texture coordinates.
PROTO Extrusion [ # indicates that this is an extrusion node field MFVec2f crssSection # polyline cross-section to be extruded field MFVec2f normals # normals to the contour field MFVec3f spine # 3D polyline extrusion path / spine field MFVec3f pathColors # colors to be applied along the path. field MFVec3f pathXforms # list of 2 by 3 affine matrices field SFVec3f up [0 1 0] # y-axis of contour in 3-space field SFVec3f frontCap # perpendicular to the front cap. field SFVec3f backCap # perpendicular to the back cap. field SFEnum joinstyle [ANGLE] # the join style field SFBool drawCap [TRUE] # if true, draw the end caps field SFEnum normStyle [PATH_EDGE] # how normals are used. field SFEnum texGen [OFF] # texture coordinate generation style }The contour field defines a 2D polyline that represents the cross-section of the extrusion. The contour will be swept along the 3D polyline path (spine) to define the surface. The contour field must be present, otherwise, an extrusion cannot be drawn.
The contourNormals field defines an array of 2D normals to the contour. The 2D normals will be extruded along the polyline path to generate the 3D normals needed for lighting. If the contourNormals field is not present, then facet normals will be computed and used.
The path defines the 3D polyline path (spine) along which the polyline is extruded. The path field MUST be present, otherwise, an extrusion cannot be drawn.
The pathColors field defines colors which will be used to color the vertices along the path. The colors will be used as the diffuse component of the material. If this field is missing, the current material will be used.
The pathXforms field defines a series of 2 by 3 affine matrices that are to be applied to the contour at each path vertex. If this field is missing, then unit matrices are assumed.
The up field defines the orientation of the contour's y-axis in 3D space. That is, the contour is interpreted in a 2D coordinate system whose y-axis is "up", and whose x-axis is defined as the cross product of up and the first segment of path. If this field is missing, the value is taken to be [0 1 0].
The frontCap field defines the orientation of the front end-cap of the extrusion. It is used, in conjunction with the join style, to define how the end of the extrusion should be trimmed. If this field is missing, then the frontCap vector is taken to be parallel to the first segment of the path. That is, the front cap is drawn perpendicular to the first segment of the "path".
The backCap field defines the orientation of the back end-cap of the extrusion. It is used, in conjunction with the join style, to define how the end of the extrusion should be trimmed. If this field is missing, then the backCap vector is taken to be parallel to the last segment of the path. That is, the back cap is drawn perpendicular to the last segment of the "path".
The joinstyle node defines how segments are to be joined. There are four possible values:
RAW # ends are perpendicular to segments ANGLE # segments join together. CUT # joins are trimmed. ROUND # joins are rounded.
The drawCap field indicates whether the end caps should be drawn.
The normStyle field indicates how normals should be handled. It can take on one of four values:
FACET # one normal per facet CONTOUR_FACET # normals along the edge of the path. PATH_FACET # normals along the edge of the contour EDGE # normals along the edge of both contour and path.
The texGen field indicates whether and how texture coordinates are generated for the extrusion It can take on one of 13 values:
OFF # texture generation disabled. VERTEX_FLAT # See API documentation NORMAL_FLAT VERTEX_CYL NORMAL_CYL VERTEX_SPH NORMAL_SPH MODEL_VERTEX_FLAT MODEL_NORMAL_FLAT MODEL_VERTEX_CYL MODEL_NORMAL_CYL MODEL_VERTEX_SPH MODEL_NORMAL_SPH
PROTO PolyCylinder { # indicates that this is a polycylinder field MFVec3f path # 3D polyline extrusion path field MFVec3f pathColors # colors to be applied along the path. field MFVec3f pathXforms # list of 2 by 3 affine matrices field SFVec3f frontCap # orientation of the front cap. field SFVec3f backCap # orientation of the back cap. field SFEnum joinstyle ANGLE # the join style field SFBool drawCap TRUE # if true, draw the end cap field SFEnum normStyle PATH_EDGE # how normals are used. field SFEnum texGen OFF # texture coordinate generation }
r 0 0 0 r 0That is, the contour is scaled uniformly by the radius at each vertex.
PROTO PolyCone { # indicates that this is an extrusion node field MFVec3f path # 3D polyline extrusion path field MFVec3f pathColors # colors to be applied along the path. field MFFloat radii # radius at each vertex field SFVec3f frontCap # orientation of the front cap. field SFVec3f backCap # orientation of the back cap. field SFEnum joinstyle ANGLE # the join style field SFBool drawCap TRUE # if true, draw the end cap field SFEnum normStyle PATH_EDGE # how normals are used. field SFEnum texGen OFF # texture coordinate generation }
The effect of crease angles can be emulated by drawing the extrusion in parts, with different normal-generation styles for each part.
| width*cos(twist) -width*sin(twist) 0 | | width*sin(twist) width*cos(twist) 0 |We have found the full form useful when defining screw-shapes, that is, surfaces of revolution that are offset as they are swept. The third fields (0 in the above), are critical for achieving the shearing motion when sweeping the curve.
The affine-matrix form is admittedly confusing to the general public. Therefore, it might make sense to define a node of the form
PROTO GeneralCylinder { # indicates that this is an extrusion node field MFVec3f path # 3D polyline extrusion path field MFVec3f pathColors # colors to be applied along the path. field MFFloat width # scale cross section field MFFloat twist # rotate cross section field MFFloat tx # translate cross section in x direction field MFFloat ty # translate cross section in y direction field SFVec3f frontCap # orientation of the front cap. field SFVec3f backCap # orientation of the back cap. field SFEnum joinstyle ANGLE # the join style field SFBool drawCap TRUE # if true, draw the end cap field SFEnum normStyle PATH_EDGE # how normals are used. field SFEnum texGen OFF # texture coordinate generation }where the affine is given by
| width*cos(twist) -width*sin(twist) tx | | width*sin(twist) width*cos(twist) ty |It is not clear that this less-general form easier or better than the fully general form.