Курсовая работа: Модель трехмерной сцены и библиотека OpenGL
Фрагмент кода программы верхней части корпуса (полусферы)
M=30;
int iM=30;
double phi, psi;
q=0;
int i=0;
while (q<M)
{
while (i<iM)
{
glBindTexture(GL_TEXTURE_2D, texture2);
glBegin(GL_QUADS);
phi=(-(M_PI*(i))/iM); psi=((M_PI*(q))/M);
glNormal3f(-3*rFan*sin(phi),rFan*cos(phi)*sin(psi),rFan*cos(phi)*cos(psi));
glTexCoord2d((sin(phi)+1)/2,(cos(psi)+1)/2);
glVertex3d(*rFan*sin(phi)+bFan,rFan*cos(phi)*sin(psi), rFan*cos(phi)*cos(psi));
phi=(-(M_PI*(i+1))/iM); psi=((M_PI*(q))/M);
glNormal3f(-3*rFan*sin(phi),rFan*cos(phi)*sin(psi),rFan*cos(phi)*cos(psi));
glTexCoord2d((sin(phi)+1)/2,(cos(psi)+1)/2);
glVertex3d(*rFan*sin(phi)+bFan,rFan*cos(phi)*sin(psi), rFan*cos(phi)*cos(psi));
phi=(-(M_PI*(i+1))/iM); psi=((M_PI*(q+1))/M);
glNormal3f(-3*rFan*sin(phi),rFan*cos(phi)*sin(psi),rFan*cos(phi)*cos(psi));
glTexCoord2d((sin(phi)+1)/2,(cos(psi)+1)/2);
glVertex3d(*rFan*sin(phi)+bFan,rFan*cos(phi)*sin(psi), rFan*cos(phi)*cos(psi));
phi=(-(M_PI*(i))/iM); psi=((M_PI*(q+1))/M);
glNormal3f(-3*rFan*sin(phi),rFan*cos(phi)*sin(psi),rFan*cos(phi)*cos(psi));
glTexCoord2d((sin(phi)+1)/2,(cos(psi)+1)/2);
glVertex3d(*rFan*sin(phi)+bFan,rFan*cos(phi)*sin(psi), rFan*cos(phi)*cos(psi));
glEnd();