• 11
• 14
• 12
• 10
• 11

# Problems in the X file exported by 3DSMAX7

This topic is 4491 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have exported a X file by 3DSMAX7, and Load it by Direct3D9, and render it. then I've got an access violation error at 0x00000000. who can tell me how to Load a X file exported by 3DSMAX7 correctly, thanks!

##### Share on other sites
Quote:
 Original post by infantry_haoI've got an access violation error at 0x00000000.

This is a pointer problem. Somewhere along the way, you're dereferencing a NULL pointer. Step through your code until you find the line that breaks. Check the return values of the D3D functions you call. Turn on the Debug Runtimes to help you track down bugs. If you're not sure what the Debug Runtime is, check the Forum FAQ.

neneboricua

##### Share on other sites
thank you. but i think i have to describe the problem in more details. when i load and render a x file from D3D samples, the code works fine. only if i load a x file exported by 3DSMAX7, the code crashed.

//the load process has no error:

L"D:\\works\\3DMAX7\\sphere.x", D3DXMESH_MANAGED, pd3dDevice,
);

if(SUCCEEDED(pd3dDevice->BeginScene()))
{
for(int i = 0; i < (int)g_Mtrls.size(); i++)
{
pd3dDevice->SetMaterial(&g_Mtrls);
pd3dDevice->SetTexture(0, g_Textures);

g_Mesh->DrawSubset(i);
}
V(pd3dDevice->EndScene());
}

......

//!!!!here goes the error!!!!!!
pd3dDevice->Present(NULL, NULL, NULL, NULL);

and another problem is, when the first time run at this line of code, it has passed. the error occurs when the second time comes.

##### Share on other sites
Up!!!!

who can tell me why?

##### Share on other sites
missing texture?
mesh doesn't have a texture?

i would have thought it would crash at drawsubset tho, not on present.
try stepping through the loader and see if anythings null.

##### Share on other sites
So the error occurs on Present() - which would seem to indicate that pd3dDevice is a NULL pointer. Have you confirmed this?

If it is a Direct3D related call the debug runtimes should be telling you what failed and why. Ramp up the debug output and see what it says.

However, if the error is only occuring with 3dsmax7 models then I think you need to examine your loading code further. Put OutputDebugString() calls in after every function to verify what each variable holds (e.g. the returned pointers, sizes, numbers of materials etc..) and see if there is something special about max7 files that's tripping up your code.

hth
Jack

##### Share on other sites
I use Panda DX Exporter to export my models from 3dsmax to .x...

I'll prensent here the code I usually use to load meshes in the .x format(Its for d3d8 but I think it runs ok for d3d9.If not, make some optimizations).....

//globalsLPDIRECT3DDEVICE8 d3dDevice = NULL;LPD3DXMESH Mesh = NULL;LPDIRECT3DTEXTURE8* Tex = NULL;D3DMATERIAL8* Mat = NULL;DWORD NMat = 0;...//d3dDevice was successfully initialized and its working correctly......//function to load the mesh...HRESULT LoadMesh(TCHAR* fileName){    HRESULT hr = S_OK;    LPD3DXBUFFER Buffer = NULL;    if(FAILED(hr = D3DXLoadMeshFromX(fileName, D3DXMESH_SYSTEMMEM, NULL, &Buffer, &NMat, &Mesh)))        return hr;    D3DXMATERIAL* d3dxMat = (D3DXMATERIAL*)Buffer->GetBufferPointer();    Mat = new D3DMATERIAL8[NMat];    Tex = new LPDIRECT3DTEXTURE8[NMat];    for(DWORD i = 0; i<NMat; i++)    {        Mat = d3dxMat.MatD3D;                if(FAILED(D3DXCreateTextureFromFile(d3dDevice, d3dxMat.pTextureFilename, &Tex)))            Tex = NULL;    }    Buffer->Release();    return hr;}

Not sure if there's any errors on the code...I just coded it right now :P.....I think it is correct...I have no problems when using it and Panda to work with .x files

I hope it helps.......

cya