Lightning "Logic"

Hi!
I am rendering a landscape via heightfield.
When the “camera-rotation” is done with an angle of 0°, the left side of a hill isenlighted and the right side is dark. When Now I let the camera rotate by 180°. Then the the lighting is opposite, the right side is enlighted by my light and the left is dark…but isn´t that wrong???
When you stand on a mountain and look at a hill and then move your head, do you see the two sides of the hill in diffrent enlightments???

I think my problem is, that I let the “camera” rotate by glRotatef…and this rotates only my hieghtfield and not the lights with it…
How can I correct this??

Seems like I can handle this one … , you have to call
glLightfv(GL_LIGHT0, GL_POSITION, …) ;
for each frame, and this after having set your model/view matrix (ie rotating) by your call to gluLookAt or glRotate.
By setting the same position (means direction for a directionnal light) in each frame, your light will not move when you rotate the scene, as it will be transoframted like all the other objects in your scene (in fact it WILL move, but as the other objects, so it won’t move relatively to your objects)

    Lolo

As a matter of fact the light should not rotate.
Your original results are correct.

If you stand in a room with a light on your left and turn 180 degrees the light is now on your right.

The light position remains the same it is only your viewpoint that changes.

So the left hand side and right hand side lighting should swap over quite correct.

[This message has been edited by normanf (edited 01-11-2002).]

normanf, when you change the wiewpoint, the wall that was on the left is now on the right, as for the light. So if you rotate the wall, you have to rotate the light the same way.