Java Reference
In-Depth Information
After creating the IndexedLineStripArray object, the vertex coordinators and index-
ing arrays are then defined and passed to the object for rendering in the remaining lines
of the code segment.
Figure 42 gives another example of using IndexedLineStripArray to create a wedge
shape object. The assignment of the indices for the various vertices is also shown together
with the result of the program. Specifically, the object has six vertices and is drawn using
four strips. The first strip draws the bottom of the object and this involves four vertices and
five indices to draw four line segments. Two line segments each are drawn by the second
Figure 42. Code segment and result of IndexedLineArray.java
5
4
3
2
1
0
1. public Shape1()
2. {
3. axisBG = new BranchGroup();
4. int[] counts = {5, 3, 3, 2};
5. IndexedLineStripArray Lines = new
6. IndexedLineStripArray(6, GeometryArray.COORDINATES, 5+3+3+2, counts);
7. axisBG.addChild(new Shape3D(Lines));
8.
9. Lines.setCoordinate( 0, new Point3f(0.6f, 0.0f, 0.5f));
10. Lines.setCoordinate( 1, new Point3f(0.0f, 0.0f, 0.5f));
11. Lines.setCoordinate( 2, new Point3f(0.0f, 0.0f, 0.0f));
12. Lines.setCoordinate( 3, new Point3f(0.6f, 0.0f, 0.0f));
13. Lines.setCoordinate( 4, new Point3f(0.0f, 0.3f, 0.3f));
14. Lines.setCoordinate( 5, new Point3f(0.6f, 0.3f, 0.3f));
15.
16. Lines.setCoordinateIndex(0, 0); Lines.setCoordinateIndex(1, 1);
Lines.setCoordinateIndex(2, 2);
17. Lines.setCoordinateIndex(3, 3); Lines.setCoordinateIndex(4, 0);
18.
19. Lines.setCoordinateIndex(5, 0); Lines.setCoordinateIndex(6, 5);
Lines.setCoordinateIndex(7, 3);
20.
21. Lines.setCoordinateIndex(8, 1); Lines.setCoordinateIndex(9, 4);
Lines.setCoordinateIndex(10, 2);
22.
23.
Lines.setCoordinateIndex(11, 4); Lines.setCoordinateIndex(12, 5);
24. }
Search WWH ::




Custom Search