Directional Lights in DX7...
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
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
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
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
James
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
- WitchLord
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement