DX9 Need help with .X File

Started by
3 comments, last by birdkingz 14 years ago
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]
Seeking for Perfection
Advertisement
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().
//function for drawing mesh Spaceshipvoid Spaceship::drawSpaceship(LPDIRECT3DDEVICE9 pd3dDevice){	for (DWORD i = 0; i < numSpaceshipMaterials; i++)	{		pd3dDevice->SetMaterial (&pd3dSpaceshipMaterial);		pd3dDevice->SetTexture (0, pSpaceshipTextureList);		pd3dMeshSpaceship->DrawSubset(i);	}}


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


Seeking for Perfection
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.
WOW !!! It's WORK !!!!!
THANKS ALOT :D
Seeking for Perfection

This topic is closed to new replies.

Advertisement