Java Reference
In-Depth Information
However, note that the ordering of the stored indices in the indexing array is associ-
ated with a certain sense of direction on whether the defined triangle will point towards
one or the opposite direction. This corresponds to the use of the right hand rule and is also
indicated in Figure 38. As an example, the indices 1, 2, 3 are associated with Surface A
pointing outwards, while the indices 1, 3, 2 is associated with Surface A pointing inwards
and forming an internal surface. For Surface A or its normal to be facing or pointing
outward or forming an external surface, the indices have to be listed in an anti-clockwise
manner as indicated.
After specifying the physical geometry, the color of the faces can be declared. This is
done by creating a Color3f array for the colors and using an integer array to list down the
color indices for the vertices in groups of three.
Figure 39 shows another example where IndexedTriangleArray is used to create a
diamond shaped object. The code first specifies the coordinates of the six vertices of the
object, and then creates and initiates an indexing array for building the eight faces of the
diamond using eight triangles. Comparing with the program segment in Figures 14 to 16
for creating the same object using TriangleArray with 24 vertices, note that the use of
IndexedTriangleArray only requires six vertices to be specified.
The usage of IndexedQuadArray is very similar to that of IndexedTriangleArray, apart from
the fact that the basic shape is changed from a 3-sided triangle to a 4-sided quadrilateral.
Figure 40 gives an example where a solid trapezoidal object is rendered.
Note that the number of vertices for the object is eight and the object has six faces, each
formed from a quadrilateral. Thus, the index count used is 24 when the IndexedQuadArray
array is first declared.
Since the basic shape is now a quadrilateral, the indexing array for specifying the
physical geometry is provided in groups of four. Also, as for IndexedTriangleArray, each
group of indices is associated with a certain sense of direction on the face created. This is
illustrated in Figure 40 and is again associated with the use of the right hand rule. Thus,
the use of 1, 3, 4, 2 in the indexing array corresponds to Surface A facing outward, while
using 1, 2, 4, 3 will make it face inwards and will give rise to an internal surface.
Indexedstriparray
As with LineStripArray, the IndexedLineStripArray class is well suited to create complex
objects making up of line segments. Figure 17 shows the basic shape for LineStripArray
and its indirect access based indexing version, IndexedLineStripArray.
Search WWH ::

Custom Search