The code segment and result in Figure 6 illustrate how three points with different
widths can be rendered at different locations. Note that in line 19, PointAttributes has set
antialiasing to false to result in the output shown.
By adding a few more line of codes to those in Figure 6, Figure 7 shows how spherical
or circular points can be rendered. Note that the additional code is to create a PolygonAt-
tributes object (lines 10 and 11) in the same BranchGroup. Then, POLYGON_LINE is used
and antialiasing is set to true to result in the output shown.
LineAttributes objects change how line primitives are rendered by controlling the types
(for example, solid or dashed) of the line patterns to be used, the width of the line, and
whether antialiasing is enabled. Figures 8 and 9 show some sell-explanatory code segments
and the corresponding results on some test lines rendered using LineWidth, LinePattern
and Line Antialiasing properties.
PolygonAttributes objects control how polygon primitives will be rendered. This includes
how the polygon will be rasterized, and whether a special depth offset is set or culled. The
default for filling polygons can also be easily changed using the setPolygonMode() method
to show only the wire frame or vertices.
Furthermore, the PolygonAttribute class includes a method to reduce the number of
polygons to be rendered through the use of setCullFace() method. This is illustrated in the
code segment in Figure 10, where lines 15 to 23 set the appearance with the CULL_NONE
attribute so that both the front and back of the object are rendered (Java 3D scene appear-
ance, 2006). As illustrated in Figure 11, the result of this is that both the front and back of
the letter E can be seen even after it has been rotated.
By changing CULL_NONE to CULL_FRONT in line 21 in the code segment of Figure
10, Java 3D will only render the polygons on the front of the letter E. Since the polygons at the
back are not rendered, a black screen will result after rotation, as illustrated in Figure 12.
Similarly, by using CULL_BACK instead, only the polygons at the back will be ren-
dered. As illustrated in Figure 13, it is the other side of the letter E that can be seen as it
is rotated now.
Having discussed the issue of culling, we will now illustrate the use of POLYGON_
POINT to render just the vertices of the object. The code segment is shown in Figure 14,
and is basically the same as that in Figure 10. However, an additional line of code (line
20) has been added to define the polygon mode. In this example, the PolygonMode is set
Search WWH ::