14 int numq = *numPolys-numt;
15 int verts = numt*3+numq*4;
16 for (
int i = 0;
i < verts; ++
i) {
35 static vector< GFXVertexList* >vlists[4];
36 int which = (Insideout ? 1 : 0)+(reverse_normals ? 2 : 0);
37 while ( (
unsigned int) detail >= vlists[which].size() )
38 vlists[which].insert( vlists[which].end(), 1+detail-vlists[which].size(), NULL );
39 if (vlists[which][detail] == 0) {
41 int stacks = slices = detail;
49 float rho_max = 3.1415926536;
51 float theta_min = 0.0;
52 float theta_max = 2*3.1415926536;
53 float rho, drho, theta, dtheta;
57 float nsign = Insideout ? -1.0 : 1.0;
58 float normalscale = reverse_normals ? -1.0 : 1.0;
62 drho = (rho_max-rho_min)/(
float) stacks;
63 dtheta = (theta_max-theta_min)/(
float) slices;
72 int numQuadstrips = stacks;
74 int *QSOffsets =
new int[numQuadstrips];
77 int numvertex = stacks*(slices+1)*2;
85 for (i = imin; i < imax; i++) {
86 GFXVertex *vertexlist = vl+(i*(slices+1)*2);
90 for (j = 0; j <= slices; j++) {
92 x = -
sin( theta )*
sin( rho );
93 y =
cos( theta )*
sin( rho );
96 vertexlist[j*2+fir].i = x*normalscale;
97 vertexlist[j*2+fir].k = -y*normalscale;
98 vertexlist[j*2+fir].j = z*normalscale;
99 #define GetS( theta, theta_min, theta_max ) ( 1-(theta-theta_min)/(theta_max-theta_min) )
100 #define GetT( rho, rho_min, rho_max ) ( 1-(rho-rho_min)/(rho_max-rho_min) )
102 vertexlist[j*2+fir].s =
GetS( theta, theta_min, theta_max );
103 vertexlist[j*2+fir].t =
GetT( rho, rho_min, rho_max );
104 vertexlist[j*2+fir].x = x*
radius;
105 vertexlist[j*2+fir].z = -y*
radius;
106 vertexlist[j*2+fir].y = z*
radius;
108 x = -
sin( theta )*
sin( rho+drho );
109 y =
cos( theta )*
sin( rho+drho );
110 z = nsign*
cos( rho+drho );
112 vertexlist[j*2+sec].i = x*normalscale;
113 vertexlist[j*2+sec].k = -y*normalscale;
114 vertexlist[j*2+sec].j = z*normalscale;
115 vertexlist[j*2+sec].s =
GetS( theta, theta_min, theta_max );
116 vertexlist[j*2+sec].t =
GetT( rho+drho, rho_min, rho_max );
117 vertexlist[j*2+sec].x = x*
radius;
118 vertexlist[j*2+sec].z = -y*
radius;
119 vertexlist[j*2+sec].y = z*
radius;
125 QSOffsets[i] = (slices+1)*2;
128 vlists[which][detail] =
new GFXVertexList( modes, numvertex, vertexlist, numQuadstrips, QSOffsets );
130 sphere = vlists[which][detail];