Archived

This topic is now archived and is closed to further replies.

johnnyBravo

possible to use d3dfvf_diffuse and d3dfvf_normal at same time for vertices?

Recommended Posts

johnnyBravo    100
Hi with my vertices i want to use lighting aswell as being able to set the diffuse for my vertices. that is use d3dfvf_normal |d3dfvf_diffuse at the same time. When ive tried it the diffuse doesn''t show up heres some code showing my use of the fvf in settings (ignore this if u want , just to show what im doing)
void create(LPDIRECT3DDEVICE9 d3dDevice, int bufferArraySize)
{
	int vertexByteSize = bufferArraySize * sizeof(Vertex);	
	d3dDevice->CreateVertexBuffer(vertexByteSize, 0,
	(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_NORMAL|D3DFVF_TEX1) , 
			D3DPOOL_DEFAULT, &lp_VB, NULL ) ;
}

void select()
{
	LPDIRECT3DDEVICE9 d3dDevice;
	lp_VB->GetDevice(&d3dDevice);
	d3dDevice->SetStreamSource( 0, lp_VB, 0, sizeof(Vertex));
	d3dDevice->SetFVF((D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_NORMAL|D3DFVF_TEX1) );
}

//and part of my vertice class

class Vertex {
private:
	D3DXVECTOR3 point;
	DWORD diffuse;
	D3DXVECTOR3 normals;
	D3DXVECTOR2 textureCoords;
...
if its possibly to use the normal and diffuse fvf flags together, could you maybe hint towards how thanks,

Share this post


Link to post
Share on other sites
don    431
Swap the order of your normal vector and the diffuse color in your vertex class declaration, then read the description of D3DRS_COLORVERTEX in the SDK docs.

Share this post


Link to post
Share on other sites
johnnyBravo    100
Ok igot it all working like that now, but now i want to try and make the diffuse work with lighting.

is there a way to actually use diffuse with lighting?,
Thanks,

[edited by - johnnyBravo on March 27, 2004 10:44:55 PM]

Share this post


Link to post
Share on other sites
psykr    295
Hm, now that I think about it, you can put diffuse colors into the material. However, this way you can''t control the diffuse color as finely.

Share this post


Link to post
Share on other sites