.X vertex colours / FFP materials

Started by
1 comment, last by GameDev.net 18 years ago
I'm trying to write my own platform independent code to read .X files, and I've got pretty far - it's loading in all of the frames/meshes and materials properly. Now I'm working on actually rendering this stuff in Direct3D 9 (still the original release, I think) using the FFP, and it's rendering the shapes alright. The only problem is that everything is exactly the same colour. In my sample .X file, the colours seem to be represented by Material templates. My rendering code does something like this:

for (nMaterial = 0; nMaterial < nNumMaterials; nMaterial++)
{
	m_pDevice->SetMaterial(pMaterials[nMaterial].MatD3D);
	pMesh->DrawSubset(nMaterial);
}

The SetMaterial call seems to have no effect - even though the D3DMATERIAL9 object MatD3D has a diffuse component of {r=1.0f, g=0.0f, b=0.0f,a=1.0f} it's still being rendered in white. I've never had much success changing the rendered colour of a vertex in any way besides actually going into the vertex buffer and changing the diffuse component directly, but that doesn't seem to be practical with a mesh which shares vertices between multiple faces, which aren't necessarily using the same material. Am I doing something wrong, or would you expect SetMaterial to do the job?
Advertisement
First, let me tell you that I usually don't work with meshes without textures and therefore the result may be different with colours. Try checking the ambient colour of the object. Perhaps try to change that too.
the unicorn might be right. try put material.diffuse = material.ambient

This topic is closed to new replies.

Advertisement