Java Reference
In-Depth Information
Lastly, the diamond implemented by using TriangleStripArray in Figure 28 can be easily
implemented by using TriangleFanArray as well. This is shown in Figure 32, where the top
and bottom parts of the object are implemented by using two strip arrays.
IndexedGeometryarray
In the same way as indirect addressing in computer systems, the IndexedGeometryArray
class renders objects from accessing the vertices of the objects in an indirect manner. From
this point of view, the various GeometryArray classes described in previous sections can
be regarded as equivalent to the use of direct addressing.
Using IndexedGeometryArray class, information on the vertices must still be provided
in arrays. However, these can be in any convenient order. Instead of accessing these directly
to render the object in the prescribed manner, they can be accessed in any order through
the use of additional integer arrays for indexing into the arrays of colors, normals, posi-
tion, and texture coordinates. In a certain sense, the indexing arrays provide information
on how vertices are connected in the rendering of the object.
The advantage of having indirect accessing capability is the possible reduction in the
number of repeating vertices that will be needed under direct accessing as when Geom-
etryArray class is used. However, the disadvantage is that time will have to be spent on
this indirect accessing process and the rendering process may become slower. Specifically,
using IndexedGeometryArray may save memory at the expense of speed.
The IndexedGeometryArray class includes the indexed versions of basically all the
classes under the GeometryArray class discussed in earlier sections. In the same manner,
our discussion of the IndexedGeometryArray class will start with the basic indexed classes
first in the next few sections before moving on to discuss more complicated classes toward
the end of the chapter.
Indexedpointarray
Figure 33 and 34 show the code segment and result on using IndexedPointArray to display a
few points in space. The usage is similar to PointArray. In this simple example where there
is no sharing of vertices, the vertex count is the number of points that will be displayed
and the index count equals the vertex count. Specifically, a new integer array of indices is
now declared to list down the sequence of vertices or points to be rendered.
Indexedlinearray
Figure 35 illustrates the use of IndexedLineArray to produce a trapezoidal object. Note
that the code segment does not use any polygon attribute, the object is defined by its eight
Search WWH ::




Custom Search