Java Reference
In-Depth Information
Figure 13. Fourth code segment and result of
91. look.setColoringAttributes(ca);
92. look.setPolygonAttributes(pa);
93. look.setLineAttributes(la);
95. return look;
96. }// end of App method
98. } // end of class House
these vertices. A new QuadArray object, named House_Struct, is then instantiated in line
69, with a vertexFormat corresponding to coordinates.
The setCoordinates method of the GeometryArray class is used to set the coordinates
for defining the various faces of House_Struct in line 72. The first argument of 0 dictates
that the coordinates will be assigned starting from vertex 0. The second argument is simply
the array which storing the coordinates.
Instead of rendering objects based on four-sided quadrilaterals, three-sided triangles can
also be used. Figures 14 to 16 give an example where an octahedron is constructed using 8
different triangles. Since each triangle requires 3 vertices, a total of 24 vertices would have to
be specified to create the octahedron, even though many vertices are actually identical.
The global variable in line 3 specifies the number of vertices for each triangle, while
lines 5 to 18 give the constructor for the Diamond class. In this example, every triangle is
created using its own method, which includes the creation of a new TriangleArray object
after specifying its coordinators using setCoordinate(). As mentioned, the rendering of,
say, triangle 1 and 2 requires some common vertices to be specified twice.
Search WWH ::

Custom Search