View previous topic :: View next topic |
Author |
Message |
Koobazaur Member
Joined: 08 Mar 2007 Posts: 22
|
Posted: Thu Mar 08, 2007 12:59 am Post subject: Loading an exported .x file with DirectX9 |
|
|
Hey,
I have created an .X file using Deled but I am having trouble loading it in my program. I am using the following function:
D3DXLoadMeshFromX("deled/scene.x",
D3DXMESH_MANAGED,
D3D9Device,
0, //no adjecency info
&MaterialBuffer,
0,
(DWORD*)(&MaterialCount),
&mesh );
but it returns and error. Works fine with my other mesh.
Help appreciated.
EDIT: just noticed this only happens when I insert the 88 prefab; otherwise it loads fine. |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Sat Mar 10, 2007 2:47 pm Post subject: |
|
|
Interesting how inserting the 88 prefab triggers the problem. Some quick questions:
1. Does inserting the 88 prefab always trigger the problem?
2. Does the error convey any specific message?
3. Does loading the file in the DirectX Viewer result in any such errors as well? If it does, that would be great, because it would save us from having to write a test application... |
|
Back to top |
|
|
Koobazaur Member
Joined: 08 Mar 2007 Posts: 22
|
Posted: Sun Mar 11, 2007 1:36 am Post subject: |
|
|
1. Yup, whether by itself or with other level geometry. Another one that causes it is 88 trailer. I have not tested ALL prefabs, but others that I looked at seemed to work fine.
2. Nope. I tested for D3DERR_INVALIDCALL and E_OUTOFMEMORY and neither of them are the case. I also updated to a 32bit indexing buffer, but same problem persists.
3. Unfortunately, I can't say, as the DX viewer crashes on my system when I try to load it. |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Sun Mar 11, 2007 8:05 pm Post subject: |
|
|
Ok, thanks, we'll take it from here! Once we figure out what's wrong we'll post our findings here, and hopefully release a new version of the exporter. |
|
Back to top |
|
|
Koobazaur Member
Joined: 08 Mar 2007 Posts: 22
|
Posted: Sun Mar 11, 2007 9:41 pm Post subject: |
|
|
Would you like the code I use for loading the model (it's pretty much standard DX9 stuff, though) ? |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Mon Mar 12, 2007 7:15 pm Post subject: |
|
|
Thanks, but we should be ok. Even though we are pretty much OpenGL geeks ourselves, so if we somehow get really really stuck on calling that function we might come calling for your help.
[edit]Well, the good news is that the problem is easy to reproduce. The bad news is that the exported file seems pretty much ok to the naked eye, and the .X importer loads it in without any problems. Perhaps the model is a big larger than most, but that shouldn't be too much of a problem... Downloading the full DirectX SDK as we speak, in the hope of pulling some more information from the DirectX debug dll... [/edit]. |
|
Back to top |
|
|
Koobazaur Member
Joined: 08 Mar 2007 Posts: 22
|
Posted: Tue Mar 13, 2007 6:26 am Post subject: |
|
|
The model being too big was the first thing that came to my mind but, as I said, I do not get the out of memory error. And if I am correct, the bike model is more complicated than the 88 and it loads fine. |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Wed Mar 14, 2007 2:34 pm Post subject: |
|
|
Yeah, you've got a good there! Back to the 'there must be something wrong with the file structure' then. I'll keep you posted! |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Wed Mar 14, 2007 7:55 pm Post subject: |
|
|
Ok, I figured it out. The 88 prefab (like any prefab that only has a number for a name) gets names like '1', '2', etc when you place it as a primitive into the scene. So far so good, but the exporter copies this name straight into the .X file as the mesh name, and mesh names are not allowed to start with a number. If you open the resulting .X file in notepad, and change the mesh name to 'test', or 'biggun', or 'whohoo', the .X file loads properly.
Quote: |
...
Material Floor02 {
1.000000;1.000000;1.000000;1.000000;;
0.000000;
0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;;
TextureFileName {
"Floor02.jpg";
}
}
Mesh [b]PutAnyNameHereThatDoesNotStartWithANumber/b] {
10096;
63.1025400;62.0000000;11.9426300;,
62.6025400;66.0000000;12.8086600;,
-30.0621800;71.0000000;-40.6913400;,
...
|
I'll now hand this over to Jeroen, he will decide how we want to handle this in the exporter. |
|
Back to top |
|
|
Koobazaur Member
Joined: 08 Mar 2007 Posts: 22
|
Posted: Thu Mar 15, 2007 6:28 am Post subject: |
|
|
Bugs--;
|
|
Back to top |
|
|
jwatte DeleD PRO user
Joined: 26 Apr 2006 Posts: 513
|
Posted: Tue Apr 24, 2007 3:43 am Post subject: |
|
|
Interesting. Does this happen with my .X exporter, too? |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Tue Apr 24, 2007 6:51 pm Post subject: |
|
|
I haven't tested it, but I see nothing in your code (kudos for open sourcing it!) to prevent it. Convert_name does not pay special attention to the first character. |
|
Back to top |
|
|
|