I have been reading the red book but i am confused about how to make a scene where the light is ‘attached’ to the camera point of view.
Let me breifly explain what is my simple setting.
I have an object in the middle and a camera that can pan, zoom and trackball rotate around the object.
The pseudocode is:
inside display() {
1 - gltranslate for zoom
2 - gltranslate for pan
3 - gltranslate back to put the camera away from the object
4 - push stack and load identity
5 - cumulate inside a matrix R (initialized to I at the beginning) the rotation matrix for the trackball rotation based on the new rotation coming from mouse dragging
6 - pop stack
7 - multiplicate by R
8 - geometry of the object down the pipeline (the object is centered on the origin)
I know that to make the light ‘fixed’ in relation to the object i need to put the light between 7 and 8.
I also thought that to make the light ‘attached’ to the viewpoint i had to put the light definition before 1, but i have tried and i got weird behavior coming (can’t explain exactly what is happening… it looks like it rotates in the opposite direction of the camera rotation, not sure though).
Can anybody give me a suggestion?
Thanks.
Note: 1+2+3 are equivalent to a gluLookAt
[This message has been edited by franz1999 (edited 04-01-2003).]