|
The LineArray© Justin Couch 2000
The line array presents a collection of single segment lines to the screen.
Apart from the ConstructionAs the line array is a very simple primitive the constructor does not change from the basicGeometry class. We supply the number of
vertices and the flags indicating the sort of information to be supplied.
int format = GeometryArray.COORDINATE |
GeometryArray.COLOR_3;
LineArray lines = new LineArray(4, format);
The number of vertices supplied must always be a multiple of two. Why? Each
line consists of a vertex for each end of it. No two lines share the same
vertex information unless you create two verticies with the same values.
This is illustrated in Figure 4. Note that while vertices 3 and 8 share the
same position in space (the lines look like they join here), they are
actually two independent entities.
![]() Figure 4: A line array showing the vertex numbering
float[] vertices =
{
0, 0, 0, // v1
0, 2, 0, // v2
1, 5, -3, // v3
-1, 2, -8, // v4
};
Note that the provided array is a flat, one-dimensional array with each
three values providing the three coordinates of each vertex.
To set the vertex array you now use one of the
lines.setCoordinates(0, vertices);
The first parameter is the position in the array to start setting values for.
Because we are starting with all of the vertex values, this index is zero. If
you wanted to set a sub-range of the values, then the index will be set
appropriately. However, make sure that the supplied array of vertex values is
the right length because one that is too big will cause Java3D to throw an
exception.
There are various other options available, depending on how you want to
set the coordinate values. For example, if you want to change just one item,
then use the When you set colour values, the interpretation is the same for colours as the vertex values. Each pair of colours is assigned to the corresponding end points of the line. In between, the renderer generates a colour gradient that smoothly blends from the colour on one vertex to the colour on the other. |
|
[ j3d.org ]
[ Aviatrix3D ]
[ Code Repository ]
[ Java3D ]
[ OpenGL ]
[ Books ]
[ Contact Us ]
Hosted by Yumetech Last Updated: $Date: 2006/04/18 18:20:11 $ |