Hello,
I set up a quite simple scene including one textured cube. now when i add lightning i see no difference, there is no difference with a directional ligh or a ambient light nothing seems to work.
here are some codefragments plz ask for more if needed.
here is where i set up the render states
HRESULT createObject()
{
HRESULT hr;
IDirect3DTexture9 *p_Texture;
D3DMATERIAL9 material;
D3DXVECTOR3 norm(0,0,-1);
iVertex front[] =
{
{-0.5,-0.5,-0.5,norm,0xFFFFFFFF,0,1},
{-0.5,0.5,-0.5,norm,0xFFFFFFFF,0,0},
{0.5,-0.5,-0.5,norm,0xFFFFFFFF,1,1},
{0.5,0.5,-0.5,norm,0xFFFFFFFF,1,0}
};
norm = D3DXVECTOR3(1,0,0);
iVertex right[] =
{
{0.5,-0.5,-0.5,norm,0xFFFFFFFF,0,1},
{0.5,0.5,-0.5,norm,0xFFFFFFFF,0,0},
{0.5,-0.5,0.5,norm,0xFFFFFFFF,1,1},
{0.5,0.5,0.5,norm,0xFFFFFFFF,1,0}
};
norm = D3DXVECTOR3(0,0,1);
iVertex back[] =
{
{0.5,-0.5,0.5,norm,0xFFFFFFFF,0,1},
{0.5,0.5,0.5,norm,0xFFFFFFFF,0,0},
{-0.5,-0.5,0.5,norm,0xFFFFFFFF,1,1},
{-0.5,0.5,0.5,norm,0xFFFFFFFF,1,0}
};
norm = D3DXVECTOR3(-1,0,0);
iVertex left[] =
{
{-0.5,-0.5,0.5,norm,0xFFFFFFFF,0,1},
{-0.5,0.5,0.5,norm,0xFFFFFFFF,0,0},
{-0.5,-0.5,-0.5,norm,0xFFFFFFFF,1,1},
{-0.5,0.5,-0.5,norm,0xFFFFFFFF,1,0}
};
norm = D3DXVECTOR3(0,1,0);
iVertex top[] =
{
{-0.5,0.5,-0.5,norm,0xFF000000,0,1},
{-0.5,0.5,0.5,norm,0xFF000000,0,0},
{0.5,0.5,-0.5,norm,0x0F000000,1,1},
{0.5,0.5,0.5,norm,0x0F000000,1,0}
};
norm = D3DXVECTOR3(0,-1,0);
iVertex bottom[] =
{
{-0.5,-0.5,0.5,norm,0xFF000000,0,1},
{-0.5,-0.5,-0.5,norm,0xFF000000,0,0},
{0.5,-0.5,0.5,norm,0x0F000000,1,1},
{0.5,-0.5,-0.5,norm,0x0F000000,1,0}
};
object = new iObject();
hr = D3DXCreateTextureFromFile(gp_d3dDev, L".\\textures\\metal.jpg", &p_Texture);
if(FAILED(hr))
{
g_appRun = false;
g_exitCode = 110;
return(hr);
}
ZeroMemory(&material,sizeof(D3DMATERIAL9));
material.Diffuse.r = 1.0f; material.Ambient.r = 1.0f;
material.Diffuse.g = 1.0f; material.Ambient.g = 1.0f;
material.Diffuse.b = 1.0f; material.Ambient.b = 1.0f;
material.Diffuse.a = 1.0f; material.Ambient.a = 1.0f;
object->addPart(4,D3DPT_TRIANGLESTRIP,front,p_Texture,material);
object->addPart(4,D3DPT_TRIANGLESTRIP,right,p_Texture,material);
object->addPart(4,D3DPT_TRIANGLESTRIP,back,p_Texture,material);
object->addPart(4,D3DPT_TRIANGLESTRIP,left,p_Texture,material);
object->addPart(4,D3DPT_TRIANGLESTRIP,top,p_Texture,material);
object->addPart(4,D3DPT_TRIANGLESTRIP,bottom,p_Texture,material);
return(hr);
}
ok the cube renders and its rotating like it did before i added lightning.
do i need to recalculate lightning every frame using a command? or should this do? please help me out, its driving me mad.