lighting being transformed along with models?

Started by
2 comments, last by markr 18 years, 1 month ago
Hi, I have a game in progress and I have a problem with the lighting. This might be a simple problem to solve but bare with me please. I have a house rendered and a character in front of it. Lighting is fine but when I walk round the side of the house the light seems to move with the camera. To explain better, for example, if my house's side facing the camera at startup was in shadow, the face facing away from the camera would be in full brightness right? But when I move around the other side of the house it ends up that it is in shadow, in fact anything that is facing the camera ends up in shadow. this would not be a problem if I intended the game to be a model viewer and I was just spinning the house around but its not. I think it's down to how I have rotated and translated the model for the house. My render function goes something along the lines of: gluLookAt() pushMatrix() glTranslate() draw sky box popMatrix() pushMatrix() glTranslate() glRotate() render house popMatrix() pushMatrix() glTranslate() glRotate() render character popMatrix() // end rendering Am I doing these things in the right order? I was always taught to translate the world to move the character. Am I doing it wrong for games becasue it works for model viewers. Thanks for any help!
Advertisement
I think the easiest way for you to do that would be to have the call to set up the lighting within:

pushMatrix()
glTranslate()
glRotate()
render house
popMatrix()

So that the lights are positioned in accordance with the world (in this case the house).

I believe

hope it helps

so would I call glLight(GL_POSITION, pos) just before I render the house like so?

pushMatrix()
translate()
rotate()
glLight()
render house
popMatrix()
I think you're either doing things in the wrong order, or you're putting the viewpoint transformation into the projection matrix.

The projection matrix SHOULD be set up so that the camera appears at the origin. Then, set the camera position by translating the MODELVIEW matrix.

It's an easy mistake to make, and it feels right, but it isn't. :)

Mark

This topic is closed to new replies.

Advertisement