Hi All
I've created a character model in Blender 3D that I have exported to an .x file which displays fine using the X viewer from DirectX.
However I want to now import the model into my Direct3D program. I do already have working code that loads a model with textures (using texture map files (jpg, bmp, etc..).
My character model is just using colours, no texture files, how would I load the colours that character model is in?
Currently in my Direct3D program I just get white, how do I load the colours the character has got?
Current code to load character data
-----------------------------------
D3DXLoadMeshFromX(FLOOR_X_CHARACTER, D3DXMESH_SYSTEMMEM,deviceIn, NULL,&character_MaterialBuffer, NULL, &character_NumMaterials,&character_Mesh);
D3DXMATERIAL* character_Materials = (D3DXMATERIAL*)character_MaterialBuffer->GetBufferPointer();
//Loop for all materials and textures
for(DWORD i=0; i < character_NumMaterials; i++)
{
// Copy the material from the buffer to your array
character_MeshMaterials = character_Materials.MatD3D;
character_MeshMaterials.Ambient = character_MeshMaterials.Diffuse;
//Set the texture to NULL
character_MeshTextures = NULL;
if(character_Materials.pTextureFilename != NULL && lstrlen(character_Materials.pTextureFilename) > 0)
{
D3DXCreateTextureFromFile(deviceIn,character_Materials.pTextureFilename,&character_MeshTextures);
}
}
// Set the identity matrix for the character transform
D3DXMatrixIdentity(&matrix_Boogle);
D3DXMatrixIdentity(&matrix_Boogle_Rotate);
Current code to render / display character model
------------------------------------------------
for(DWORD i=0; i < character_NumMaterials; i++)
{
// Set the material and texture for this subset
deviceIn->SetMaterial(&character_MeshMaterials);
deviceIn->SetTexture(0, character_MeshTextures);
// Draw the mesh subset
character_Mesh->DrawSubset(i);
}
Any help appreciated and sorry for a bit of a long post.
The model of the character is displayed but its all in white. How do I get the character displayed in the colours I assigned it in Blender?
Thank you in advance.
Andrew
.x file colour loading
Do you have lighting* turned on? If so, did you set up a light (D3DLIGHT9 in DX9) and enable it?
*dev->SetRenderState(D3DRS_LIGHTING,TRUE);
*dev->SetRenderState(D3DRS_LIGHTING,TRUE);
Hi
I don't have lighting turned on, I'm just using the default lighting settings in Direct3D.
I can see colour with meshes which have actual textures applied but can only see white meshes when only colours have been used on the meshes.
It looks fine in the X viewer tool, just not in my program.
Is switching the lighting on and setting up an essential requirement for this?
Any idea why it works with textured meshes and not untextures meshes?
Thank you for your help and advice in advance.
Andrew
I don't have lighting turned on, I'm just using the default lighting settings in Direct3D.
I can see colour with meshes which have actual textures applied but can only see white meshes when only colours have been used on the meshes.
It looks fine in the X viewer tool, just not in my program.
Is switching the lighting on and setting up an essential requirement for this?
Any idea why it works with textured meshes and not untextures meshes?
Thank you for your help and advice in advance.
Andrew
Quote:I don't have lighting turned on
Actually, lighting ON should be the default, but you should check it. However, there are no appropriate lights defined by default.
What happened when you did setup a light? That should have fixed the problem.
Quote:Is switching the lighting on and setting up an essential requirement for this?
Yes, you need to have lighting on and a light defined to see shades of color, as you probably know by now. (I assume you tried that)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement