Sign in to follow this  
birdkingz

DX9 Need help with .X File

Recommended Posts

Hi all, I'm facing a serious problem..I have exported a .X file from 3ds Max by using Pandasoft exporter. Now my problem is..when i draw the .X file in my program then all other objects which is not .X file has corrupted (all the vertices and textures has corrupted) Anyone know what's my problem is?? Please, I need urgent help :( //some of the sample codes D3DXMATRIX matTrans; D3DXMATRIX matSpaceshipWorld; D3DXMatrixIdentity(&matTrans); D3DXMatrixIdentity(&matSpaceshipWorld); D3DXMatrixScaling(&matTrans, 0.5f, 0.5f, 0.5f); D3DXMatrixMultiply(&matSpaceshipWorld, &matTrans, &matSpaceshipWorld); pd3dDevice->SetTransform(D3DTS_WORLD, &matSpaceshipWorld); spaceship->drawSpaceship(pd3dDevice); //this is to draw .X file // background matrix D3DXMATRIX matWorldBg; D3DXMatrixIdentity( &matWorldBg ); D3DXMATRIX matBgTrans; D3DXMatrixIdentity( &matBgTrans ); D3DXMatrixScaling(&matBgTrans, 200.0f, 200.0f, 200.0f); D3DXMatrixMultiply(&matWorldBg, &matWorldBg, &matBgTrans); D3DXMatrixTranslation(&matBgTrans, -100.0f, -10.0f, -100.0f); D3DXMatrixMultiply(&matWorldBg, &matWorldBg, &matBgTrans); //set background matrix pd3dDevice->SetTransform(D3DTS_WORLD, &matWorldBg); //set background texture and draw it out drawBg(); //this is to draw normal objects by using DrawPrimitive() only //Without rendering .X file, only the background //Problem, but the .X file is rendered correctly [Edited by - birdkingz on April 1, 2010 8:57:20 AM]

Share this post


Link to post
Share on other sites
Post the code for drawSpaceship() and drawBg() (using source tags - the FAQ has instructions).

Also, functions like D3DXMatrixScaling() completely initialize the matrix passed as an argument, so there's no need to initialize it to the identity matrix using D3DXMatrixIdentity().

Share this post


Link to post
Share on other sites

//function for drawing mesh Spaceship
void Spaceship::drawSpaceship(LPDIRECT3DDEVICE9 pd3dDevice)
{
for (DWORD i = 0; i < numSpaceshipMaterials; i++)
{
pd3dDevice->SetMaterial (&pd3dSpaceshipMaterial[i]);
pd3dDevice->SetTexture (0, pSpaceshipTextureList[i]);
pd3dMeshSpaceship->DrawSubset(i);
}
}





void drawBg()
{
pd3dDevice->SetTexture(0, pd3dTextureBg);
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 97, 2 );
}



Share this post


Link to post
Share on other sites
In drawBG(), you need to call SetStreamSource and SetFVF. That's because the DrawSubset calls in drawSpaceship have overwritten the values they set.

So basically, the call to DrawPrimitive is using the vertex buffer and vertex format of the mesh.

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