Java Reference
In-Depth Information
Figure 29. Code segment and result of Circle1.java
1.
int vertex =100;
//change accordingly
2.
int StripCount[] = new int [1];
3.
StripCount[0] = vertex;
//single strip is being used
4.
5. TriangleFanArray Circle = new TriangleFanArray(vertex,
6. TriangleFanArray.COORDINATES|TriangleFanArray.COLOR_3, StripCount);
8.
9. for (n =0, a=0; n < vertex;a = 2.0*Math.PI/(vertex) * ++n)
10. {
11.
x = (float) (r * Math.cos(a));
12.
y = (float) (r * Math.sin(a));
13.
Circle.setCoordinate(n, new Point3f(x, y, 0.0f));
14.
Circle.setColor(n, red);
15. }
16.
Figure 30. Code segment and result of Speaker1.java
1.
TriangleFanArray speaker = new TriangleFanArray(vertex,
2.
TriangleFanArray.COORDINATES|TriangleFanArray.COLOR_3, StripCount);
3. speaker.setCoordinate(0, new Point3f(0.0f, 0.0f, 0.0f));
4. speaker.setCoordinate(1, new Point3f(0.5f, 0.0f, 0.25f));
5. speaker.setCoordinate(2, new Point3f(0.5f, 0.0f, -0.25f));
6. speaker.setCoordinate(3, new Point3f(0.25f, 0.25f, -0.25f));
7. speaker.setCoordinate(4, new Point3f(0.25f, 0.25f, 0.25f));
8. speaker.setCoordinate(5, new Point3f(0.5f, 0.0f, 0.25f));
9. speaker.setCoordinate(6, new Point3f(-0.5f, 0.0f, -0.25f));
10. speaker.setCoordinate(7, new Point3f(-0.25f, 0.25f, -0.25f));
11. speaker.setCoordinate(8, new Point3f(-0.25f, 0.25f, 0.25f));
12. speaker.setCoordinate(9, new Point3f(-0.5f, 0.0f, 0.25f));
13.
14. speaker.setColor(0, red);
15. speaker.setColor(1, green);
16. speaker.setColor(2, blue);
17. speaker.setColor(3, white);
18. speaker.setColor(4, red);
19. speaker.setColor(5, blue);
20. speaker.setColor(6, red);
21. speaker.setColor(7, green);
22. speaker.setColor(8, blue);
23. speaker.setColor(9, white);
Search WWH ::

Custom Search