Java Reference
In-Depth Information
Figure 48. Code segment for Artefact()
1.
private Geometry Artefact()
2.
{
3.
IndexedTriangleFanArray Indexedtfa;
4.
int N = 17; int totalN = 4*(N+1); int stripCounts[] = {N+1,N+1,N+1,N+1};
5.
Point3f coords[] = new Point3f[totalN];
6.
float r = 0.6f; int n,m; double a; float x, y; int i,j;
7.
8.
Indexedtfa = new IndexedTriangleFanArray
9.
(20, IndexedTriangleFanArray.COORDINATES,totalN,stripCounts);
10.
11.
// set the central points for four triangle fan strips
12.
Indexedtfa.setCoordinate (16,new Point3f(0.0f, 0.0f, 0.8f));
13.
Indexedtfa.setCoordinate (17,new Point3f(0.0f, 0.0f, 0.5f));
14.
Indexedtfa.setCoordinate (18,new Point3f(0.0f, 0.0f, 0.2f));
15.
Indexedtfa.setCoordinate (19,new Point3f(0.0f, 0.0f, -0.1f));
16.
17.
//to avoid repeating the last vertice as vertice no 16 is the same as zero
18.
for(a = 0,n = 0,m=0; n < 17 && m < 16; a = 2.0*Math.PI/(N-1) * ++n,m++)
19.
{
20.
x = (float) (r * Math.cos(a)); y = (float) (r * Math.sin(a));
21.
Indexedtfa.setCoordinate (m,new Point3f(x,y,w));
22.
}
23.
24.
Indexedtfa.setCoordinateIndex( 0, 16); Indexedtfa.setCoordinateIndex( 17, 0);
25.
for ( i=1; i<17; i++) Indexedtfa.setCoordinateIndex( i, i-1);
26.
27.
Indexedtfa.setCoordinateIndex( 18, 17); Indexedtfa.setCoordinateIndex( 35, 0);
28.
for ( i=1, j=19; j<35; i++,j++) Indexedtfa.setCoordinateIndex( j, i-1);
29.
30.
Indexedtfa.setCoordinateIndex( 36, 18); Indexedtfa.setCoordinateIndex( 53, 0);
31.
for ( i=1, j=37; j<53; i++,j++) Indexedtfa.setCoordinateIndex( j, i-1);
32.
33.
Indexedtfa.setCoordinateIndex( 54, 19); Indexedtfa.setCoordinateIndex( 71, 0);
34.
for ( i=1, j=55; j<71; i++,j++) Indexedtfa.setCoordinateIndex( j, i-1);
35.
36.
return Indexedtfa;
37.
38. }//end of Artefact method
summary
We have introduced and discussed several basic geometry classes that can be used to
specify the geometry of visual objects in Java 3D. PointArray, LineArray, TriangleArray,
Search WWH ::

Custom Search