Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

VyvyanBasterd

Directional Lights in DX7...

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

OK, I''m having a few problems with my directional light source under DX7. I want the light source to point in the same direction (at the ground), but what keeps happening is that the light source "follows" the camera movement! Do I need to multiply the direction by my world matrix every time the camera rotates? Should I put this code in before or after my call to BeginScene()? James

Share this post


Link to post
Share on other sites
Advertisement
I had the reverse problem before (the light didn´t want to follow the camera). Have you tried to set the lights direction every render lap? Like this:

D3DLIGHT7 light;
m_pD3DDev->GetLight(0, &light);

light.dvDirection.x = 0;
light.dvDirection.y = -1;
light.dvDirection.z = 0;
m_pD3DDev->SetLight(0, &light);

Gandalf the White

Share this post


Link to post
Share on other sites
Well, I was actually re-initializing it every game frame (i.e., filling in the light structure each time), not using the GetLight() function. Is the direction affected by the World Matrix?

James

Share this post


Link to post
Share on other sites
The Light sources are not affected by any transformation matrix and should always be defined in world coordinates. If the light never moves you only need to set it once.

- WitchLord

Share this post


Link to post
Share on other sites
OK...figured out my problem.

My problem was one of OVER "optimization". I was attempting to eliminate having to use the view matrix, by simply updating the world matrix. This was very fast, but as I showed, lighting was completely fubar''d. So the moral of the story is, don''t optimize until it works.

Thanks, WitchLord!

Vyvyan

Share this post


Link to post
Share on other sites

  • 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!