Java Reference
In-Depth Information
Figure 49. Code segment for Glass_case()
1.
private Geometry Glass_case()
2.
{
3.
float c = 1.0f; float d = -0.7f; float e = 0.6f;
4.
5.
IndexedQuadArray qa = new IndexedQuadArray(8, QuadArray.COORDINATES, 16);
6.
7.
qa.setCoordinate(0,new Point3f(-e,e,c));
qa.setCoordinate(1,new Point3f(-e,-e,c));
8.
qa.setCoordinate(2,new Point3f(e,-e,c));
qa.setCoordinate(3,new Point3f(e,e,c));
9.
qa.setCoordinate(4,new Point3f(-e,e,d));
qa.setCoordinate(5,new Point3f(-e,-e,d));
10.
qa.setCoordinate(6,new Point3f(e,-e,d));
qa.setCoordinate(7,new Point3f(e,e,d));
11.
12.
//the front face and the back face using for loop
13.
for (int i=0; i<8;i++) qa.setCoordinateIndex(i,i);
14.
qa.setCoordinateIndex(8,5);
qa.setCoordinateIndex(9,6);
15.
qa.setCoordinateIndex(10,2);
qa.setCoordinateIndex(11,1);
16.
qa.setCoordinateIndex(12,4);
qa.setCoordinateIndex(13,0);
17.
qa.setCoordinateIndex(14,3);
qa.setCoordinateIndex(15,7);
18.
19.
return qa;
20.
21. }//end of Glass_case method
and QuadArray are useful for building objects using a series of points, lines, triangles and
quadrilaterals. For structures where the series of lines or triangles are adjacent to each other
in a certain manner, the use of LineStripArray, TriangleStripArray, and TriangleFanArray
may be more convenient and lead to faster rendering. The problem of requiring certain
vertices to be repeated when these basic classes are used can be overcome through using
their indexed versions, where the sequence of vertices can be supplied via some integer
indexing arrays. Complex objects can be created through appropriately combining objects
built from different classes. Also, simple geometrical shapes such as boxes, spheres, cones
or cylinders can be easily generated using the predefined utility classes in Java 3D.
references
Java 3D API specification. (2006). http://java.sun.com/products/java-media/3D/forDevelop-
ers/j3dguide/j3dTOC.doc.html.
Java3D geometry. (2006). http://viz.aset.psu.edu/jack/java3d/geom.html.
Search WWH ::




Custom Search