Original Post
Howdy all,
I can't figure out how to get my spotlight to work correctly. I have a small cube spinning around the y-axis at the origin. I'm trying to setup a yellow spotlight to light up the front of my cube, which has a white material. However, I just can't get it to light correctly. The cube still looks white and it lights up the same way if I were using a point light instead. Here's part of my code:
I tried to fiddle around with all the properties, but can't seem to get anywere. Any suggestions would be great.
Thanks.
Eric
[edited by - codegod on April 19, 2002 2:19:51 PM]
// Set light data
ZeroMemory(&Light, sizeof(Light));
Light.Type = D3DLIGHT_SPOT;
Light.Diffuse.r = 1.0f;
Light.Diffuse.g = 1.0f;
Light.Diffuse.b = 0.0f;
Light.Ambient.r = 1.0f;
Light.Ambient.g = 1.0f;
Light.Ambient.b = 0.0f;
Light.Range = 1000.0f;
Light.Falloff = 1.0;
Light.Phi = 0.3488;
Light.Theta = 0.1744;
Light.Direction = D3DXVECTOR3(0.0f, 0.0f, 1.0f);
Light.Attenuation0 = 0.0f;
Light.Attenuation1 = 0.0f;
Light.Attenuation2 = 0.0f;
Light.Position.x = 0.0f;
Light.Position.y = 0.0f;
Light.Position.z = -100.0f;
// Set and enable the light
g_pD3DDevice->SetLight(0, &Light);
g_pD3DDevice->LightEnable(0, TRUE);
// Set material properties
ZeroMemory(&Material, sizeof(Material));
Material.Diffuse.r = 1.0f;
Material.Diffuse.g = 1.0f;
Material.Diffuse.b = 1.0f;
g_pD3DDevice->SetMaterial(&Material);