Hi!
I have a serius problem with rendering (or light) in Direct 3D8, please help! I´m not a beginner.
I have made a wall section with which contains 4x4 quads as a simple test (to fix the same problem in my bigger project). When I render these with DrawPrimitive as either triangle strip or triangle list, I can clearly see the triangels in the wall section.
The wall face negative z direction and each quad have these vertices and normal if "sz" is size and are created as triangle strip:
{-sz.x,-sz.y, sz.z},{-sz.x, sz.y, sz.z},{ sz.x,-sz.y, sz.z},{ sz.x, sz.y, sz.z},{ 0, 0,-1}
I render every quad with a separate call to DrawPrimitive (to enable exchange of textures):
for(int i=0; i<m_iPrimitives/2; i++)
{
device->SetTexture(0, CTextureBank::GetTexture(m_piTexture[i]));
device->DrawPrimitive( d3dprimtype, uiStartVertex, 2 );
uiStartVertex += 4;
}
When I switch off light and only use ambient light source the triangels stay invisible (as I want to). But I want to use point light!
Maybe I have set up my light wrong?
void CDirect3DWin::SetLight()
{
const float MAX_LIGHT = 200;
const float TIONDEL_DIV_MAX_LIGHT = 0.1f / MAX_LIGHT;
D3DLIGHT8 m_Light;
FLOAT m_LightValue = MAX_LIGHT;
ZeroMemory(&m_Light, sizeof(m_Light));
m_Light.Type = D3DLIGHT_POINT ;
m_Light.Diffuse.r = m_LightValue*1.0f;
m_Light.Diffuse.g = m_LightValue*1.0f;
m_Light.Diffuse.b = m_LightValue*1.0f;
m_Light.Range = m_LightValue/2;
m_Light.Attenuation2 = 0.55f;
m_Light.Attenuation1 = 0.55f;
m_Light.Attenuation0 = 0.55f/2;
m_Light.Position = m_BeholderPos;
m_Light.Direction = m_BeholderDir;
m_pd3dDevice->SetLight( 0, &m_Light );
m_pd3dDevice->LightEnable( 0, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT,
D3DCOLOR_COLORVALUE(0.1f, 0.1f, 0.1f, 1));
m_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE);
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
D3DMATERIAL8 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
mtrl.Diffuse.r = mtrl.Ambient.r = mtrl.Diffuse.g = mtrl.Ambient.g =
mtrl.Diffuse.b = mtrl.Ambient.b = TIONDEL_DIV_MAX_LIGHT*m_LightValue;
mtrl.Diffuse.a = mtrl.Ambient.a = 0.0f;
m_pd3dDevice->SetMaterial( &mtrl );
}
Please help me solve this problem! I can´t go any further if I not solve this problem!
Any help are much-appreciated!
Thanks,
Zeblar Nagrim, Lord of Chaos