Sign in to follow this  
sachingorade

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;

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[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 this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this