Java Reference
In-Depth Information
Figure 26. Code segment and result of Hourglass1.java after setting PolygonAttributes
1.
private Appearance app()
2.
{
3.
Appearance look = new Appearance();
4.
PolygonAttributes polyAttrib = new PolygonAttributes();
5.
//polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_LINE);
6.
7.
//to make both sides of the face appear
8.
polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
9.
10.
look.setPolygonAttributes(polyAttrib);
11.
12.
return look;
13. }
define a few generic geometries and then have these appropriately added in an iterative or
recursive manner.
trianglefanarray
As shown in Figure 17, TriangleFanArray uses a set of vertices to produce a set of triangles
fanning from a center. Specifically, triangles are drawn by using the current and previous
vertices together with the first vertex.
The usage of the TriangleFanArray constructor is similar to that of LineStripArray and
TriangleStripArray, and is illustrated in the simple example shown in Figure 29, where
the combination of a number of fanning triangles of the same size gives rise to a circle
eventually as the number of vertices is increased.
Obviously, TranigleFanArray is useful and efficient to construct objects that radiate
from a central vertex. Two simple examples further illustrating this are given in Figures
30 and 31, where a two-pole speaker and a laser display are constructed.
Search WWH ::




Custom Search