Java Reference
In-Depth Information
Figure 18. Typical application graphics generated using LineStripArray, TriangleStripAr-
ray and TriangleFanArray
We will now discuss the LineStripArray class in this section, before moving onto the other
two more complicated classes in the next two sections. As illustrated in Figure 17, a LineS-
tripArray object gives rise to a linked set of line segments drawn from an array of vertices.
Figure 20 shows how a colored trapezium can be created by invoking LineStripArray.
Note that, before specifying the exact geometry of the trapezium, a Trapezium class is
created by extending the Shape3D superclass in lines 6 and 7 in Figure 20.
The coordinators and color of vertices of the trapezium are then specified. Note also
that while the trapezium has only four vertices, LineStripArray is supplied with five coor-
dinates. This is because two points are needed to draw a line and so the starting point has
to be included twice to form a closed trapezium.
Figure 21shows how the code segment in Figure 20 can be easily extended to create a 3D
trapezoidal structure. In addition to the starting point, some physical vertices of the visual
object will be visited more than once in building the structure using LineStripArray which
draws lines between consecutive points. In this example, while the physical structure only
has eight vertices, the number of vertices that need to be given to LineStripArray is 18.
Figure 19. Specifying the vertices and format of a LineStripArray object
LineStripArray line1= new LineStripArray (vertexCount, vertexFormat, stripVertexCounts)
// The number of vertices in a particular array is given by vertexCount and the format of // the pre-vertex data is given by VertexFormat.
Search WWH ::

Custom Search