PDA

View Full Version : 3d rotation



dutchstud
02-13-2002, 07:13 PM
I found an example for 3d. you can rotate it at free will, but when i add light, the light rotates with it. any ideas? i want the light to stay in one spot but the box to rotate.

02-13-2002, 07:52 PM
Lights pass through the modelview matrix just as vertices do. Thus, they are moved by commands such as glRotatef() or glTranslatef. If you don't want the light to move your drawing code might look like this:

glLoadIdentity();
glPushMatrix();
drawScene();
glPopMatrix();
glLightfv(GL_LIGHT0, GL_POSITION, light_position);

where drawScene() contains drawing code and matrix transformations.
In this way, the Modelview maxtrix is restored before you put the light back into the scene.

dutchstud
02-14-2002, 04:30 AM
thanks!