|
The LineStripArray© Justin Couch 2000-2004
The
To do this, the ConstructionConstruction of a line strip array starts with the same basic setup as for line arrays, although with a different class name. You still need to tell it what data you're going to be providing, and how many vertices will be set. In addition to these basic requirements, a new parameter is added to the constructor forLineStripArray - an array of strip counts for
the individual lines. So, let's start with a simple example that creates a
single strip with two segments in it:
int format = GeometryArray.COORDINATE |
GeometryArray.COLOR_3;
int[] strip_counts = { 3 };
LineStripArray lines = new LineStripArray(8, format, strip_counts);
The strip_count variable is an array of ints that describe how
many vertices to use from the array for the given line. Since each line must
have at least a start and end vertex, the values in this array should always
be greater than or equal to 2. Each value in the array indicates a new line.
In the example above, we are telling Java3D to create a single line that has
three vertices - a start, end and a single intermediate point, which would
create a line that looked like Figure 10.
![]() Figure 9: A line strip array showing the vertex numbering for a single strip of 3 vertices setCoordinates() like you have for the others and you'll end up
with the lines appearing on screen.
float[] vertices =
{
0, 0, 0, // v1
0, 2, 0, // v2
1, 5, -3, // v3
};
lines.setCoordinates(0, vertices);
Just remember that the number of vertices provided must be at least equivalent
to the sum of the lengths of all the strips. For example, if you provided a
strip count array with the values { 3, 5, 2 } your coordinate array must have
at least 10 vertices declared. More than that really doesn't matter as Java3D
will ignore the extras, but it must have at least the minimum amount. Also, the
number of coordinates value provided to the constructor must have a value of
the same amount at least too. It's fine to tell Java3D that you have 12
coordinates in the constructor, provide the numStripCount array with a total of
10 vertices and then an array with 17 vertex values. In the end, all you'll
get are those 10 vertices from the strips, and nothing else.
|
|
[ j3d.org ]
[ Aviatrix3D ]
[ Code Repository ]
[ Java3D ]
[ OpenGL ]
[ Books ]
[ Contact Us ]
Hosted by Yumetech Last Updated: $Date: 2006/04/18 18:20:11 $ |