Jump to content
  • Advertisement
Sign in to follow this  
deus.ex.nova

[DirectX11] "Hit or Miss" loading problem

This topic is 2589 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

Hey GameDev,

I've been reading the book, Beginning DirectX11 Game Programming, and the last chapter gave a tutorial on manually loading .OBJ model files into the environment. The code makes sense, but for some reason I can't load some .obj files I've downloaded/exported. Could this be indicative of a problem with the parsing code, or just bad .OBJ files? I've even tried loading them with the example code from the book website. Has anyone else experienced this problem?

Thanks in advance.

*EDIT* Wow, sorry I forgot to put "model" in the title.

Share this post


Link to post
Share on other sites
Advertisement

The obj format is very simple. Read the file specification to set your expectations, and test your model loader with a debugger to see where things go wrong.

http://en.wikipedia....front_.obj_file

A common issue in obj loaders is that they only handle absolute geometry indices when defining faces.


[font=sans-serif][size=2]"OBJ files, due to their list structure, are able to reference vertices, normals, etc. either by their absolute (1-indexed) list position, or relatively by using negative indices and counting backwards. However, not all software supports the latter approach, and conversely some software inherently writes only the latter form (due to the convenience of appending elements without needing to recalculate vertex offsets, etc.), leading to occasional incompatibilities." - Wiki\[/font]
[font=sans-serif][size=2]
[/font]
[font=sans-serif][size=2]Are you saying that many obj loaders are not coded to do the second method mentioned in the wiki quote? If so, what exactly does it mean by "using negative indices and counting backwards"?[/font]

Share this post


Link to post
Share on other sites
Relative indexing mean that the offsets to the geometry tables are calculated relative to the last calculated offset, as opposed to specifying the absolute table offset for each vertex of each face. Negative offsets simply mean that the offset gets an offset (no pun intended) that points on the vertex data before (as opposed to after) the last fetch.

Relative indexing can save memory because if you have actually sequential vertices and faces, the offsets are very trivial to store and process. It's not that this itself causes compatibility problems, but that there are two choices (and absolute mode is easier to implement).

Remember, I'm not saying that this is the only problem you may have. Please study the files that your logic fails to load; the format is simple enough so that you can verify it against the specification manually.

Share this post


Link to post
Share on other sites
I see. Do you know of any opensource/free model loaders for DirectX 11 that are already proven to be reliable? The model loader seems to be the biggest snag for me at the moment, and I could be using the time figuring out how to effectively load OBJ files for other parts of my project. I wouldn't mind returning to this problem, since it's a great learning experience, but for the time being it's not desirable. sad.gif

Share this post


Link to post
Share on other sites
I believe the MeshConvert utility that comes with the SDK can convert from .obj to .X or .sdkmesh. There's also a D3D10 sample (MeshFromObj10) that loads in .obj files.

You could also take a look at assimp.

Share this post


Link to post
Share on other sites

I believe the MeshConvert utility that comes with the SDK can convert from .obj to .X or .sdkmesh. There's also a D3D10 sample (MeshFromObj10) that loads in .obj files.

You could also take a look at assimp.


Thanks a bunch. I'll check out all of those options. smile.gif

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!