Efficient way to read .obj files in Visual Studio 2013

Started by
4 comments, last by Jan2go 9 years, 8 months ago

Hi there,

so I started out exploring the world of OpenGL using VS 2013,

When it came to reading .obj-files my plan was to open it as a filestream, read it linewise....In order to do so I wanted to Drag and Drop the file into the solution explorer. But then I accidentally dropped it somewhere else and then I had a serious DUFUQ moment.

It seems that VS is able not only to interpret .obj files but also to visualize them in a manner, like Autodesk's tools do. This leads me to the following question.

Does that mean that there are some libraries, prebuilt methods or something like this that would make it needless to write custom methods in order to let's say reading the vertex data?

What are those "libraries"? Where do I find them? And most important can I use them for my own purposes?

Advertisement

There probably are, but writing your own .obj file loader is a good challenge :). I wrote my own some time ago, and I even have my own model format now xD.

I used stdio's FILE to load the file line by line, and then check if the line starts with "v" (for the verticies), and if yes, it used fscanf to get the rest of the data in the line :).

^ +1

Usually obj, 3ds, fbx... are used as "interchange" formats so you can easily transfer/edit across multiple programs since they are well known/supported for import/export, but for your project/game you want to use your own binary format structured in a way that holds only data relevant for your needs, you can even merge multiple models/textures/whatever files in one file to reduce disk I/O count and make it even faster on load.

While stating the obvious you do not seem to provide awnsers but to raise even more questions biggrin.png

I assume AAA titles also use formats of their own. However I wonder how they create them. I mean do they write plugnis for Autodesk's tools? I am pretty sure they use Autodesk, I mean writing their own modeling tools would produce a huge and unnecessary overhead, wouldn't it?


I am pretty sure they use Autodesk, I mean writing their own modeling tools would produce a huge and unnecessary overhead, wouldn't it?

It isn't a choice between Autodesk and nothing! smile.png Many modeling programs support import and export plugins. But, as you suspect, it's likely that the application's import routine is more efficient with a custom format that supports the internal loading or data storage requirements.

With regard to overhead (producing your own tools): if you haven't coded file loading routines before, and the OBJ format meets your needs, writing an import routine for that format is the best route as the format is relatively straight-forward, and the exercise will provide you with good IO coding experience.

Note that, in the future, you may need to import modeling data that OBJ does not support (e.g., animation). Another choice, then, is to select a more complex format that supports both static and animated models.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

What are those "libraries"? Where do I find them? And most important can I use them for my own purposes?

As no one aswered to this part yet, I guess I'll have to do it. :D

Of course there are libraries available allow you to load OBJs (and lots of other formats as well). Assimp and the FBX SDK just to name a few.

You still have to create your buffers but these libraries allow you to easily access the vertex data.

This topic is closed to new replies.

Advertisement