Moving lights..

Started by
1 comment, last by Tjacvkman 20 years, 4 months ago
When adding a point light to a device in which space does it end up? If i set the postion of the light and set it each frame like this: m_pLight.Position = m_vecBalltranslation; m_pd3dDevice->SetLight(1,&m_pLight); m_vecBalltranslation is a position vector. Nothing happens, so i figured that i have to translate some matrix somewhere but i can''t figure out which one. What i want to do is to make a point light follw a sphere much like in the LightningVS sample in the SDK. In the sample, as i understand, they move the world around the light. I want to move the light around in the world as if the light is a mesh. Since i am new to DirectX there is a great possiblity that i have missunderstood the entire lights concept, but i any help is appriciated. /Tjackman.
Advertisement
There''s a function that applies a matrix to a vector. That''s what you want. I think the functions D3DXVec3Transform.

Apply the same matrix to a vector and store the result all the time or keep building a new matrix that''s rotated a bit more and apply that to the start point.

Hope that helps

matt
I had the same problem before. To fix it you can do this:

m_pLight.Position = m_vecBalltranslation;
m_pd3dDevice->LightEnable(1, false);
m_pd3dDevice->SetLight(1,&m_pLight);
m_pd3dDevice->LightEnable(1, true);

Now you are turning off that light, updating its position and turning it on again. But I don''t know why you have to do it this way, maybe someone else can answer it.

Hope that helps.

James.

This topic is closed to new replies.

Advertisement