I'm building a little game from scratch and I've decided to use .x files for my objects... so I need an .x file parser. I'm going to use maya 6.0 to model the objects in my game, and I have installed and exported a simple cube... just to check if things are working.
First question... if the cube has a shader or a texture.. isn't it supposed to show up in the directX viewer? becaus mine is all gray. Allso.. the texture file name is not in the .x file. Does anyone have any experience exporting .x files from Maya?
I think I've got everything set up ok, but nothing is rendering!?
Loading the file and looping through to get the materials:
//Load the mesh from the file
HRESULT hr=D3DXLoadMeshFromX( cFileName,
&m_matBuffer, NULL, &m_numMat,
D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)m_matBuffer->GetBufferPointer();
m_meshMaterials = new D3DMATERIAL9[m_numMat];
m_meshTextures = new LPDIRECT3DTEXTURE9[m_numMat];
for(DWORD i = 0; i < m_numMat; i++)
//copy the material
m_meshMaterials = d3dxMaterials.MatD3D;
m_meshMaterials.Ambient = m_meshMaterials.Diffuse;
//Create the texture if it exists
m_meshTextures = NULL;
hr comes to 0 and the file seems to be loaded into memory. m_numMat becomes 2 etc.
And then to render it:
D3DXMatrixTranslation(&m_mWorldMatrix, 0.0f, 0.0f, 0.0f);
for (DWORD i=0; i<m_numMat; i++)
// Set the material and texture for this subset
// Draw the mesh subset
m_mesh->DrawSubset( i );