PDA

View Full Version : rotate with fixed lighting



zslevi
10-13-2009, 11:18 AM
I have 2 triangles and I'm rotating them. It seemed as if the lightsource didn't rotate with them, so I rotated it explicitly, but still it looks weird. The upper triangle brightens up just before turning backward.

Here's a video about it: http://www.youtube.com/watch?v=Dgc0k_hUcIY

The code I tried:



void update(){
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); //Reset the camera

gluLookAt
(sin(angle)*3,cos(angle)*3,0.4,
0.0,0.0,0.0,
0.0,0.0,1.0);


GLfloat lightPos0[] = {sin(angle+80.0), cos(angle+80.0), 0.1f, 1.0f};
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);

angle = angle + 0.03;
glutPostRedisplay();
}

zslevi
10-13-2009, 11:20 AM
So basically my question is: should I rotate the lights explicitely?

punky
10-13-2009, 11:21 AM
sorry didnt read your post cearfully before so i deleted my post

zslevi
10-18-2009, 06:42 AM
I just write a reply to move it up in activity list.