Hello there,
I am trying to create a screensaver using .x models.
I successfully loaded the model in my program but the materials that I used while designing that model is not getting loaded in my program?
Only textures get loaded and the part where material was used get displayed without any texture or material.
Here is the source code that I have used to load the model
LPD3DXBUFFER buf;
D3DXLoadMeshFromX("models\\home.x",
D3DXMESH_SYSTEMMEM,
dev,
NULL,
&buf,
NULL,
&dwNumMats,
&home);
D3DXMATERIAL *tMats=(D3DXMATERIAL*)buf->GetBufferPointer();
houseMats=new D3DMATERIAL9[dwNumMats];
houseTexs=new LPDIRECT3DTEXTURE9[dwNumMats];
for(DWORD i=0;i<dwNumMats;i++)
{
houseMats=tMats.MatD3D;
houseMats.Ambient=houseMats.Diffuse;
sprintf(texPath,"models\\%s",tMats.pTextureFilename);
if(FAILED(D3DXCreateTextureFromFile(dev,texPath,&houseTexs)))
{
houseTexs=NULL;
}
}
for rendering the model I have used following code
for(DWORD i=0;i<dwNumMats;i++)
{
dev->SetMaterial(&houseMats);
if(houseTexs!=NULL)
dev->SetTexture(0,houseTexs);
home->DrawSubset(i);
}
What should I do while designing the model so that the material will get loaded?