To set the point size of rendered objects, use the Point Size command.
where n is the number of pixels. Note that this might not be the actual number of pixels rendered, depending on other settings such as anti-aliasing and your hardware configuration.
Set the line width using the Line Width command
To make stippled lines, use the Line Stipple command.
Factor is a stretching factor. Pattern is a 16-bit integer that turns pixels on or off. Use Enable(LINE_STIPPLE) to turn the effect on.
For example, imagine you want the dotted line pattern 0000000011111111. This is equal to 255 in decimal notation, so use the command Line Stipple(1, 255).
The factor argument expands each binary digit to two digits. In the example above, Line Stipple(2, 255) would result in 00000000000000001111111111111111.
For example, the following script draws three lines, each of different widths (the Line Width commands) and stippling patterns.
scene << Enable( LINE_STIPPLE );
scene << Begin( LINES );
scene << End();
scene << Begin( LINES );
scene << End();
scene << Begin( LINES );
scene << End();
scene << Update;
图 13.11 Stipples
To set the drawing mode of a polygon, use the Polygon Mode command.
图 13.12 Points, Line, and Fill Modes
For example, the following script creates a display list that defines a triangle. This display list is used three times in conjunction with Translate, Rotate, and Color commands to draw triangles in three positions. In addition, the Polygon Mode command changes the drawing mode of each triangle. Note there is no explicit call to the FILL mode, since it is the default.
The following table dissects the script, showing how the Translate and Rotate commands accumulate to manipulate a single display list.
shape = Scene Display List();
|
|
shape << Begin(TRIANGLES);
shape << End();
|
Creates a display list named shape that holds vertices for the triangles. All the z vertices are zero since this is a two dimensional scene
|
New Window( "Fill Modes", scene );
|
|
scene << Call List(shape);
scene << Update;
|
|
scene << Polygon Mode(FRONT_AND_BACK, LINE);
scene << Call List(shape);
scene << Update;
|
|
scene << Polygon Mode(FRONT_AND_BACK, POINT);
scene << Call List(shape);
scene << Update;
|
Some developers use the fill mode in concert with the line mode to draw a filled polygon with a differently colored border. However, due to the way the figures are rendered, they sometimes do not line up correctly. The Polygon Offset command is used to correct for this so-called “stitching” problem.
To enable offsetting, use Enable(POLYGON_OFFSET_FILL), Enable(POLYGON_OFFSET_LINE), or Enable(POLYGON_OFFSET_POINT), depending on the desired mode. The actual offset values are calculated as m*(factor)+r*(units), where m is the maximum depth slope of the polygon and r is the smallest value guaranteed to produce a resolvable difference in window coordinate depth values. Start with Polygon Offset(1,1) if you need this.
An example of Polygon Offset is in the Surface Plot platform, when a surface and a mesh are displayed on top of each other, or a surface and contours displayed on top of each other. In either case, the surface would interfere with the lines if the lines were not moved closer or the surface moved farther from the viewer.