Sign in to follow this  
AndyGeers

.X vertex colours / FFP materials

Recommended Posts

AndyGeers    132
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?

Share this post


Link to post
Share on other sites
theunicorn    140
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
the unicorn might be right. try put material.diffuse = material.ambient

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this