i'm lost rotating a light source...

Started by
0 comments, last by fc6rk 20 years, 1 month ago
I''m trying to have a light on an object, but when I rotate the object the light moves because it isn''t rotating. I know this must seem simple for you guys, but can somebody show me how to pass a light source through the rotation matrix so it stays on the same spot of my model? Thanks
Advertisement
when you call glLightfv(GL_LIGHTx,GL_POSITION,...); the position you pass in will be multiplied by the current modelview matrix. So the place where you call glLight is critical (and therefor you must call it at least once a frame. So. the best place to make the call is usually right after you setup your camera. But if you want to move around with your model, then you should set the lights position either right after you do the glMultMatrix/glRotate/glWhatever for setting your model position (and then just set the light pos as if it were a vertex on the model) - but this means everything rendererd before the model will have a potentially wrong light position (out by one frame) - so, it''s better in this case to manually mult the light position you want by the matrix of the model (or just do the rotations again) and set the position after you set the camera.
The same thing applies to pretty much everything you can set a position/direction to in GL.

I have 999 posts. hmm.

| - My project website - | - email me - |

This topic is closed to new replies.

Advertisement