Jump to content
  • Advertisement
Sign in to follow this  
rpg_code_master

world and camera space

This topic is 4932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I have a simple app with a model at 0,0,0 and a spot light at 6,0,0 pointing -1,0,0. The problem is that when I move the camera, the light moves with it. How do I keep the light where it is? The effect I am getting is a torch in front of me. I do this (psudo):- Start the scene Update mouse and keyboard Set the camera Set the translation matrix to 0,0,0 Push Matrix Render Model Pop Matrix End Scene Thanks

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure where you have your lighting code now, but it is most likely in your render function. Basically you want to set up your light in some init() function where it is only set up ONCE. (Make sure the glLoadIdentity() is called before it).

Share this post


Link to post
Share on other sites
I setup the light in the init method. It's weird, when using a directional light and a rotating model, the light seems to move along a different path to the model. So when the model gets to a certian rotataion, it gets lite in a ceritan way as thgough the light is moving....

Share this post


Link to post
Share on other sites
If you're using OpenGL lighting, it's enough to just update light position and spot direction after you've positioned your camera (or anything that alters modelview matrix).

If you're using shaders, take a look at this (last few posts).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!