• Advertisement
Sign in to follow this  

loading mulitple Mesh.x files at once

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am getting a crash problem with this code


void MeshX::LoadMultipleMeshs(LPDIRECT3DDEVICE9 d3ddev)
{
char *mesharray[] = {"models/mp5.x","models/mp5.x"};

for(int i = 0; i < sizeof(mesharray); i++)
{
hr = D3DXLoadMeshFromX(mesharray, // load this file
D3DXMESH_SYSTEMMEM, // load the mesh into system memory
d3ddev, // the Direct3D Device
NULL, // we aren't using adjacency
&bufShipMaterial2, // put the materials here
NULL, // we aren't using effect instances
&numMaterials2, // the number of materials in this model
&meshs); // put the mesh here , its crashing here

if(SUCCEEDED(hr))
{
MessageBox(NULL,mesharray,"loaded",0);
}
else
{
//MessageBox(NULL,"gun model not loaded","",0);
}

}
}


in the class .h i have


//multiple mesh data
LPD3DXMESH meshs[2]; // define the mesh pointer
LPD3DXBUFFER bufShipMaterial2[2];
D3DMATERIAL9* material2[2]; // define the material object
LPDIRECT3DTEXTURE9* texture2[2]; // a pointer to a texture
DWORD numMaterials2[2]; // stores the number

Share this post


Link to post
Share on other sites
Advertisement
sizeof(mesharray) is not the number of elements in the array. It's the size of the whole array in bytes. In this case it's probably 8 - the size of two char pointers.

To get the number of elements you can do this:

int size = sizeof(mesharray) / sizeof(mesharray[0]);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement