Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Efficient way to read .obj files in Visual Studio 2013


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Prot   Members   -  Reputation: 333

Like
0Likes
Like

Posted 22 August 2014 - 03:40 AM

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?



Sponsor:

#2 iwoplaza   Members   -  Reputation: 171

Like
1Likes
Like

Posted 22 August 2014 - 05:54 AM

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 :).



#3 belfegor   Crossbones+   -  Reputation: 2687

Like
0Likes
Like

Posted 22 August 2014 - 06:46 AM

^ +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.



#4 Prot   Members   -  Reputation: 333

Like
0Likes
Like

Posted 22 August 2014 - 07:27 AM

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?



#5 Buckeye   Crossbones+   -  Reputation: 5622

Like
2Likes
Like

Posted 22 August 2014 - 07:38 AM


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.


Edited by Buckeye, 22 August 2014 - 07:48 AM.

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


#6 Jan2go   Members   -  Reputation: 890

Like
1Likes
Like

Posted 22 August 2014 - 10:34 AM



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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS