•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Game Development section within the Software Development category of DaniWeb, a massive community of 422,408 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,922 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Game Development advertiser: Programming Forums
Views: 582 | Replies: 3 | Solved
![]() |
•
•
Join Date: Jan 2008
Location: USA East Cost
Posts: 389
Reputation:
Rep Power: 1
Solved Threads: 37
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:
defined here:
and called here:
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).
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).
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 954
Reputation:
Rep Power: 5
Solved Threads: 48
Did you try using a full path to specify the file? i.e:
Try this temporarily. The initial working directory of your application is not necessarily the folder where source files are located; you can normally set the application's working directory either from the IDE ( if appropriate ) or from a shortcut, etc.
The windows explorer addressbar thing; do View > Toolbars > Address Bar, and then right click the toolbar and uncheck "Lock the Toolbars".. you should then be able to move the address bar into the correct place ( from what you've said, it's showing but is too small/wrong place to see properly ).
CPP Syntax (Toggle Plain Text)
house->LoadFromX("C:\\Documents and Settings\\<user>\\Desktop\\Projects\\3DGameFramework\\3DGameFramework\\fachwerk33T.x");
The windows explorer addressbar thing; do View > Toolbars > Address Bar, and then right click the toolbar and uncheck "Lock the Toolbars".. you should then be able to move the address bar into the correct place ( from what you've said, it's showing but is too small/wrong place to see properly ).
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Jan 2008
Location: USA East Cost
Posts: 389
Reputation:
Rep Power: 1
Solved Threads: 37
I got it, but that wasn't it.
It was an issue with Windows Explorer. For some reason, it's set to not display file extensions on files (except DLLs, and maybe some other exceptions). The .X file was originally shown w/o a .X at the end, so that's the way I wrote it in C++, but in reality, the .X was part of the name. I then tried renaming it in Explorer to <modelname>.x, but that renamed it to <modelname>.x.x
So, now I have it to appear as just the model name w/o the extension in Explorer, but I include the extension in C++. Works.
It was an issue with Windows Explorer. For some reason, it's set to not display file extensions on files (except DLLs, and maybe some other exceptions). The .X file was originally shown w/o a .X at the end, so that's the way I wrote it in C++, but in reality, the .X was part of the name. I then tried renaming it in Explorer to <modelname>.x, but that renamed it to <modelname>.x.x
So, now I have it to appear as just the model name w/o the extension in Explorer, but I include the extension in C++. Works.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 954
Reputation:
Rep Power: 5
Solved Threads: 48
Heh.. "Hide Extensions for Known file types" is one of the first things I disable in a fresh Windows install.. =)
http://www.irchelp.org/irchelp/security/trojanext.html
http://www.irchelp.org/irchelp/security/trojanext.html
If it only works in Internet Explorer; it doesn't work.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Game Development Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the Game Development Forum
- Previous Thread: how to make tick-tack-toe game
- Next Thread: hey, any 1 interested in helping out for scripting


Linear Mode