-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplanetgenerator.java
More file actions
128 lines (106 loc) · 3.48 KB
/
Copy pathplanetgenerator.java
File metadata and controls
128 lines (106 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import java.util.* ;
public class planetgenerator
{
public static void main(String[] args)
{
// number of triangles in the mesh.
int NumberOfTriangles;
// loop counter for writing out the triangle data
int LoopCounter;
// planet object
TQtm Planet = new TQtm(342432, 0.35f);
// output fields
Vector Points = new Vector(0);
// create the mesh
Planet.Generate(4, Points);
// work out the number of triangles
NumberOfTriangles = (Points.size())/3;
// print out the header
System.out.println("#VRML V2.0 utf8");
// make the sky black
System.out.println("Background");
System.out.println("{");
System.out.println("skyColor [0.0 0.0 0.01]");
System.out.println("skyAngle [0.0]");
System.out.println("}");
// add a light
System.out.println("PointLight");
System.out.println("{");
System.out.println("on TRUE");
System.out.println("location -5.0 10.0 -10.0");
System.out.println("radius 2.0");
System.out.println("intensity 1.0");
System.out.println("ambientIntensity 0.0");
System.out.println("color 1.0 1.0 1.0");
System.out.println("attenuation 1.0 0.0 0.0");
System.out.println("}");
// planet data
System.out.println("Shape");
System.out.println("{");
System.out.println("appearance Appearance");
System.out.println("{");
System.out.println("material Material");
System.out.println("{");
System.out.println("}");
System.out.println("}");
System.out.println("geometry IndexedFaceSet");
System.out.println("{");
System.out.println("coord Coordinate");
System.out.println("{");
System.out.println("point");
System.out.println("[");
// dump out vector data
for (LoopCounter = 0; LoopCounter < NumberOfTriangles; LoopCounter++)
{
// write out one set of three vectors for a triangle.
// get the first vector
TVector3d temp = (TVector3d)Points.elementAt((LoopCounter * 3));
System.out.println(temp.X() + " " + temp.Y() + " " + temp.Z() + ",");
// get the second vector
temp = (TVector3d)Points.elementAt((LoopCounter*3)+1) ;
System.out.println(temp.X() + " " + temp.Y() + " " + temp.Z() + ",");
// get the third vector
temp = (TVector3d)Points.elementAt((LoopCounter*3)+2) ;
System.out.println(temp.X() + " " + temp.Y() + " " + temp.Z() + ",");
}
// more text
System.out.println("]");
System.out.println("}");
System.out.println("coordIndex");
System.out.println("[");
// dump order data
for (LoopCounter = 0; LoopCounter < NumberOfTriangles; LoopCounter++)
{
// write out one set of three vectors for a triangle.
System.out.println((LoopCounter * 3) + "," + ((LoopCounter * 3) + 1) + "," + ((LoopCounter * 3) + 2) + ",-1,");
}
// more text
System.out.println("]");
System.out.println("color Color");
System.out.println("{");
System.out.println("color");
System.out.println("[");
// set colour
System.out.println("0.6 0.6 0.7");
// more text
System.out.println("]") ;
System.out.println("}") ;
System.out.println("colorIndex");
System.out.println("[");
// loop for number of polygons
for (LoopCounter = 0; LoopCounter < (NumberOfTriangles - 1); LoopCounter++)
{
// write out one set of three vectors for a triangle.
System.out.println("0,");
}
System.out.println("0");
// more text
System.out.println("]");
System.out.println("colorPerVertex FALSE");
System.out.println("convex TRUE");
System.out.println("solid FALSE");
System.out.println("ccw FALSE");
System.out.println("creaseAngle 180.0");
System.out.println("}");
}
}