Original Post
Ok, I'm curious as to why my terrain is not being lit by the ambient light? Currently the terrain just gets drawn completly black. Is it that the verticies need a normal to display ambient lighting? I don't beleive so, because one of my models is not being lit either and I know that it has normals.
Here's the relevent parts of my code.
//constants
#define D3DFVF_CUSTOMVERTEX ( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 )
//structures
typedef struct D3DVERTEX
{
float fX, fY, fZ;
DWORD dwColor;
FLOAT tu, tv; // The texture coordinates
} D3DVERTEX;
//the init part
mlpD3dDevice->SetRenderState( D3DRS_LIGHTING, true );
mlpD3dDevice->SetRenderState( D3DRS_AMBIENT,RGB(255,255,255));
//the colour of each vertex is set as
pVertexData[index].dwColor = 0xffaaaaaa; //color
//the render part
void CMap::Draw(void)
{
D3DXMATRIXA16 matWorld;
D3DXMatrixIdentity(&matWorld);
mlpD3DDevice->SetTransform( D3DTS_WORLD, &matWorld);
mlpD3DDevice->SetTexture( 0, mlpTexture );
mlpD3DDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
mlpD3DDevice->SetStreamSource(0,m_pTerrainVB,0,sizeof(D3DVERTEX));
mlpD3DDevice->SetIndices(m_pTerrainIB);
mlpD3DDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_dwTerrainVertices, 0, m_dwTerrainPrimitives);
}
Thanks for any help.
Edit: typo
[edited by - SiliconMunky on November 21, 2003 2:43:09 AM]