N definise teslaciju, tj. stepen aproksimacije
v je pointer na strukturu
vec3 pos; // vec3 <=> float x,y,z;
float tu, tv;
(imas for free i sfericno mapiranu teksturu, osim koordinata vertexa). Kako mi se cini zelis da koristis quad-ove iz OpenGL za iscrtavanje -- ako je tako obrati paznju sa na redosledi, mozda v[2] i v[3] treba da zamene uloge (najverovatnije)
Code:
for ( int i = 0; i < N; ++i )
{
for ( int j = 0; j < N; ++j )
{
float npsi0 = i/float(N);
float npsi1 = ( i + 1 )/float(N);
float ntheta0 = j/float(N);
float ntheta1 = ( j + 1 )/float(N);
float psi0 = npsi0*2.0f*D3DX_PI;
float psi1 = npsi1*2.0f*D3DX_PI;
float theta0 = ntheta0*D3DX_PI;
float theta1 = ntheta1*D3DX_PI;
v[0].pos.Set( a*sinf( theta0 )*cosf( psi0 ), b*cos( theta0 ), c*sinf( theta0 )*sinf( psi0 ) );
v[0].tu = npsi0; pv[0].tv = ntheta0;
v[1].pos.Set( a*sinf( theta0 )*cosf( psi1 ), b*cos( theta0 ), c*sinf( theta0 )*sinf( psi1 ) );
v[1].tu = npsi1; pv[1].tv = ntheta0;
v[2].pos.Set( a*sinf( theta1 )*cosf( psi0 ), b*cos( theta1 ), c*sinf( theta1 )*sinf( psi0 ) );
v[2].tu = npsi0; pv[2].tv = ntheta1;
v[3].pos.Set( a*sinf( theta1 )*cosf( psi1 ), b*cos( theta1 ), c*sinf( theta1 )*sinf( psi1 ) );
v[3].tu = npsi1; pv[5].tv = ntheta1;
v += 4;
}
}