Archived

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

VyvyanBasterd

Directional Lights in DX7...

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