X File

Started by
1 comment, last by sachingorade 14 years, 10 months ago
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?
Advertisement
Quote:Original post by sachingorade
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.
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?
Thank you for your reply.
By reading some posts and tutorials I think I need to load the effects also to
get material loaded.
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.

This topic is closed to new replies.

Advertisement