Jump to content
  • Advertisement
Sign in to follow this  
bigbrother2000

How do I change a lights position during runtime?

This topic is 5038 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

Hi, I have a light in my 3d scene, however i want it to remain at the players position, using variables such as playerx,playery,playerz when initialising the light i set it to these values, although i need to reposition the light each render which is why the light is not moving with the player, i tried adding these lines of code into the render loop but wasn't sucessful, any ideas? d3dLight.Position.x = playerx; d3dLight.Position.y = playery; d3dLight.Position.z = playerz;

Share this post


Link to post
Share on other sites
Advertisement
If I remember correctly, you must disable the light, update it, and then enable it again, Im sorry I cant give you an example, Im not in home right now.

Share this post


Link to post
Share on other sites
Thanks for your help, i made d3dlight2 global so they work in the render function now, although changing the values on the position doesn't seem to change the position of the light.


I tried this in response to your suggestion but with no effect.

m_pD3DDevice->LightEnable(1, FALSE);
d3dLight2.Position.x = 10.0;
d3dLight2.Position.y = 50.0;
d3dLight2.Position.z = 10.0;
m_pD3DDevice->LightEnable(1, TRUE);


Any ideas on how to get the light positioned by a variable that can change during render?

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!