# X File

## Recommended Posts

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;

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[i]=tMats[i].MatD3D;
houseMats[i].Ambient=houseMats[i].Diffuse;
sprintf(texPath,"models\\%s",tMats[i].pTextureFilename);
if(FAILED(D3DXCreateTextureFromFile(dev,texPath,&houseTexs[i])))
{
houseTexs[i]=NULL;
}
}


for rendering the model I have used following code
for(DWORD i=0;i<dwNumMats;i++)
{
dev->SetMaterial(&houseMats[i]);
if(houseTexs[i]!=NULL)
dev->SetTexture(0,houseTexs[i]);
home->DrawSubset(i);
}


What should I do while designing the model so that the material will get loaded?

##### Share on other sites
Quote:
 Original post by sachingoradeI 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.
Is the loading failing, or is the model not using the textures? Does the model work in the X File Viewer that comes with the SDK? Are there any errors or warnings from the Debug Runtimes? How do you know the materials aren't applied, or are you assuming they're not because the model is showing up untextured?

##### Share on other sites
By reading some posts and tutorials I think I need to load the effects also to
Can you give me any simple example or code to load effect from the .x file?
While exporting the model I have selected the option
1. Include .fx file
2. Include .fx parameters
I have no idea about effect files.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628316
• Total Posts
2982032

• 9
• 9
• 13
• 11
• 14