Ok, I'm writing a simple program with VC++ and DirectX. It's basically a working framework for 3D games, but all I need it to do right now is load a mesh and display it, and it is killing me. I've done this successfully before, I don't know why its not working now.
The function I use to load the .X file is Mesh::LoadFromX()
declared here:
int LoadFromX(char* filename);
defined here:
//Model::LoadFromX()
//Loads the model from a .X file
//Takes the filename of the model as a parameter
//Returns 1 on success, 0 on failure
//DOES NOT WORK
int Model::LoadFromX(char* filename)
{
ID3DXBuffer* matbuffer;
HRESULT result;
result = D3DXLoadMeshFromX(filename,D3DXMESH_SYSTEMMEM,d3ddev,NULL,&matbuffer,NULL,(DWORD*)&m_materialCount,&m_mesh);
if(result != D3D_OK)
{
switch(result)
{
case D3DERR_INVALIDCALL:
MessageBox(NULL,"D3DERR_INVALIDCALL from D3DXLoadMeshFromX() in Model::LoadFromX()","Error",MB_OK | MB_ICONERROR);
break;
case E_OUTOFMEMORY:
MessageBox(NULL,"E_OUTOFMEMORY from D3DXLoadMeshFromX() in Model::LoadFromX()","Error",MB_OK | MB_ICONERROR);
break;
case D3DXFERR_FILENOTFOUND:
MessageBox(NULL,"D3DXFERR_FILENOTFOUND from D3DXLoadMeshFromX() in Model::LoadFromX()","Error",MB_OK | MB_ICONERROR);
break;
default:
{
char error[1000];
sprintf(error,"Unknown error from D3DXLoadMeshFromX() in Model::LoadFromX(): %d",result);
MessageBox(NULL,error,"Error",MB_OK | MB_ICONERROR);
}
}
return 0;
}
D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)matbuffer->GetBufferPointer();
m_materials = new D3DMATERIAL9[m_materialCount];
m_textures = new IDirect3DTexture9*[m_materialCount];
for(int i = 0;i < m_materialCount;i++)
{
m_materials[i] = d3dxMaterials[i].MatD3D;
m_materials[i].Ambient = m_materials[i].Diffuse;
m_textures[i] = NULL;
if(d3dxMaterials[i].pTextureFilename != NULL && d3dxMaterials[i].pTextureFilename != "")
{
result = D3DXCreateTextureFromFile(d3ddev,d3dxMaterials[i].pTextureFilename,&m_textures[i]);
if(result != D3D_OK)
{
MessageBox(NULL,"Could not load proper texture file","Error loading model",MB_OK | MB_ICONERROR);
return 0;
}
}
}
matbuffer->Release();
return 1;
}
and called here:
house = new Model;
house->LoadFromX("fachwerk33T.x");
I keep getting D3DXFERR_FILENOTFOUND from the call to D3DXLoadMeshFromX().
The .X file is at C:\Documents and Settings\<user>\Desktop\Projects\3DGameFramework\3DGameFramework\fachwerk33T.x,the same directory all my source files are in. The computer recognizes it as a "DirectX X-File".
Anyone know why it isn't working?
Also, random other question: anyone know how to get the address bar to come up in windows explorer (like the one that says: C:\...,like it would in a web browser?). I tried View->Toolbars->Address Bar, but that just added a box saying "Address" to the top-right of windows explorer (you got to love windows).