Cześć.
Chciałbym się dowiedzieć jak nałożyć teksturę na glutSolidSphere lub glutWireSphere?
Tekstura jest wczytana prawidłowo. Wygląda to teraz tak, że teksturowa nakładana jest na wszystkie planety.
O to kod:
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.0, 0.0, delrange);
glRotatef(90.0, 1.0, 0.0, 0.0);
glRotatef(tilt, 1.0, 0.0, 0.0); // tilt the solar system
glRotatef(sunrev, 0.0, 0.0, 1.0); // revolves the sun on its axis
glColor3ub(120, 120, 30); // yellow
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glutSolidSphere(0.3, 20, 20); // sun
glRotatef(planetorb, 0.0, 0.0, 1.0); // orbits the planet around the sue
glTranslatef(1.5, 0.0, 0.0); // sets the radius of the orbit
glRotatef(planetrev, 0.0, 0.0, 1.0); // revolves the planet on its axis
glColor3ub(30, 120, 30); // green
glutWireSphere(0.1, 20, 20); // planet
glRotatef(-moonorb, 0.0, 0.0, 1.0);
glTranslatef(0.25, 0.0, 0.0);
glRotatef(moonrev, 0.0, 0.0, 1.0);
glColor3ub(220, 30, 120); // magenta
glutWireSphere(0.05, 12, 12); // moon
glLoadIdentity();
glPopMatrix();
glPushMatrix();
glTranslatef(0.0, 0.0, delrange);
glRotatef(90.0, 1.0, 0.0, 0.0);
glRotatef(tilt, 1.0, 0.0, 0.0); // tilt the solar system
glRotatef(planet2orb, 0.0, 0.0, 1.0); // orbits the planet around the sue
glTranslatef(0.85, 0.0, 0.0); // sets the radius of the orbit
glRotatef(planet2rev, 0.0, 0.0, 1.0); // revolves the planet on its axis
glColor3ub(30, 120, 120); // cyan
glutSolidSphere(0.13, 20, 20); // planet
glPopMatrix();
// transformacja obserwacji
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// umiejscowienie kamery w odleglym miejscu
glTranslatef(pivot_x, pivot_y, -z_dist);
glRotatef(pivot_vert_angle, 1, 0, 0);
glRotatef(pivot_horiz_angle, 0, 0, 1);
glutSwapBuffers();
}
Dziękuje.