Hello, I’m having trouble when trying to set a light from the camera’s point of view. I set the light only once at the initialization of the window, after the OpenGL rendering context is set with these parameters:
float ambient={ 0.1, 0.1, 0.1, 1.0};
float difusse={ 1.0, 1.0, 1.0, 1.0};
float shininess={ 1.0, 1.0, 1.0, 1.0};
float position={ 0.0, 0.0, 1.0, 0.0}; /w==0 direction/glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);glLightfv(GL_LIGHT0,GL_AMBIENT,ambient);
glLightfv(GL_LIGHT0,GL_DIFFUSE,difusse);
glLightfv(GL_LIGHT0,GL_SHININESS,shininess);glLightfv(GL_LIGHT0,GL_POSITION,position);
After that, I change the point of view with
gluLookAt(1000,1000,-1000,0,0,0,0,1,0);
Then I draw an horizontal plane and, after, an starship. The final render is:
Note that all the polygons are shaded with the same color, although they have different normal vectors. Changing the direction to
float position={ 0.0, 0.0, -1.0, 0.0};
leads to a weird representation where only exists a color:
If I set instead the light direction to
float position={ 1.0, 0.0, 0.0, 0.0};
the scene is correctly rendered, with the light coming from the right (positive X axis):
It also works correctly with the Y axis. I don’t know why it just doesn’t work with the Z axis, can anynone tell me?
Thanks in advance for your replies.
[This message has been edited by Azdo (edited 09-29-2002).]