Original Post
Basically I have verticies and texture coordinates, but I need to find the normals. This is what I have so far: The texture buffer and vertex buffer get filled earlier, but I was wondering if there was a way to compute the normals and have them stored into the normals buffer. Thanks, -Chris
IDirect3DIndexBuffer9* IB;
IDirect3DVertexBuffer9* VertexVB;
IDirect3DVertexBuffer9* NormalsVB;
IDirect3DVertexBuffer9* TextureVB;
IDirect3DVertexDeclaration9* Decl;
D3DVERTEXELEMENT9 ModelEl[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{1, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
{2, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
D3DDECL_END();)
};
D3DDevice->CreateVertexDeclaration( ModelEl, &Decl );
//Render
D3DDevice->SetVertexDeclaration(Decl);
D3DDevice->SetIndices(IB);
D3DDevice->SetStreamSource(0,VertexVB,0,sizeof(POSITION_VERTEX));
D3DDevice->SetStreamSource(1,NormalsVB,0,sizeof(POSITION_VERTEX));
D3DDevice->SetStreamSource(2,TextureVB,0,sizeof(TEXTURE_VERTEX));
D3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, NumVert, 0, NumTri);