Jump to content
  • Advertisement
Sign in to follow this  
Jungletoe

OpenGL Loading .OBJ

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

I know this has been discussed thoroughly, but I still haven't found a library or code that supports the loading of the .OBJ files. I would write one on my own, but to be honest I don't know enough C++ to make one. My goal when I decided to learn OpenGL was to learn it alongside C++ (I already knew all the basics like pointers, arrays, stacks, etc) so that I could examine source code and add onto it, but I've found that any type of file loader is extremely extensive and hard to make (at least judging by the code I've seen so far).

I tried looking at some source from a video tutorial series I had been following, but when I tried compiling Visual Studio gave me the typical "invalid or corrupt file: cannot read at 0xECD" error (it is referencing my .OBJ file). The source I used can be found here, here, and here.

What do you suggest that I do at this point? Go back and learn more about pointers (since apparently loaders require a lot of them) and make my own OBJ loader, or should I fix this one up even though I have no idea about where to even begin debugging?

Thanks,
Brady

Share this post


Link to post
Share on other sites
Advertisement
The OBJ format is actually pretty simple - you can look it up on wikipedia. I've written a converter which can extract the vertex data, I can send it to you if you like.

Bear in mind the normals might not be normalised - this caused my some confusion.

Otherwise here and especially here.

All the best.

[Edit] Pointers are useful. Maybe you could learn about them by getting an OBJ loader working! :wink:

Share this post


Link to post
Share on other sites

The OBJ format is actually pretty simple - you can look it up on wikipedia. I've written a converter which can extract the vertex data, I can send it to you if you like.

Bear in mind the normals might not be normalised - this caused my some confusion.

Otherwise here and especially here.

All the best.

[Edit] Pointers are useful. Maybe you could learn about them by getting an OBJ loader working! :wink:


Thanks bro! I'll be sure to post any other problems I have.

Share this post


Link to post
Share on other sites
You can also try the AssImp-library to load an Obj-File. Assimp offers various model loaders and a common data structure to access the data. You can also find some easy to understand examples in the repository as well. Just look here to learn more.

Kimmi

Share this post


Link to post
Share on other sites

You can also try the AssImp-library to load an Obj-File. Assimp offers various model loaders and a common data structure to access the data. You can also find some easy to understand examples in the repository as well. Just look here to learn more.

Kimmi


I'm afraid that it isn't cross platform :/

I'm looking for libraries that can port over to Linux. Sorry for not being clear.

Share this post


Link to post
Share on other sites

I'm afraid that it isn't cross platform :/

I'm looking for libraries that can port over to Linux. Sorry for not being clear.
Of course it is, you just have to drop it into a compiler, and I haven't checked but they probably include a Makefile too. There are even Ubuntu packages.

Share this post


Link to post
Share on other sites
Right, you can use our makefile or generate a workspace for your IDE like eclipe or something else if cmake supports this. And we are part of the unstable branch of Ubuntu biggrin.gif

Kimmi

Share this post


Link to post
Share on other sites

[quote name='Jungletoe' timestamp='1323396548' post='4892031']
I'm afraid that it isn't cross platform :/

I'm looking for libraries that can port over to Linux. Sorry for not being clear.
Of course it is, you just have to drop it into a compiler, and I haven't checked but they probably include a Makefile too. There are even Ubuntu packages.
[/quote]


Woops, sorry about that! Thanks!

Share this post


Link to post
Share on other sites
After experimenting for a while, I still can't figure out how to use ASSIMP with OpenGL. I really can't find any documentation that shows you how to actually use it with OpenGL to create a mesh. Hell, I'm even starting to wonder why I'm using this thing when I don't even care about the other model formats.I thought this would be generally easy going into it considering .OBJ is such a simple file type. The models I want to render are just some simple voxel .OBJs made in Sproxel.

Any other ideas? All I really need is something easy, simple, and quick to implement, not some full blown C++ library that I have to integrate OpenGL with. And I still can't figure out why the code I originally posted isn't working...

Share this post


Link to post
Share on other sites
Dropping your current code, and trading it for something else you copy-pasted off someone else might work, but what did you learn in the end?

I recommend you go back to your OBJ loader, and take it as an exercise on how to use a debugger, to hunt down what the problem is with your loader. What is the attitude with first spending several days of trying to write your own OBJ loader, then hitting a problem, realizing "oh, I guess this isn't gonna work.", and dropping it altogether to evade the real issue.

In any serious piece of code you write, especially in C++, you will have crash bugs again and again. Sounds like what you need is someone to tell you to get a hold of yourself, pick up that goddamn debugger, and start stepping through the code. Figure out where it crashes, what causes the crash, and why. Then fix it up. Because that is what you will always be doing as a programmer, and you have to learn to do it without dying inside.

If you are not willing to do that, do not want to learn C++, or file I/O, or pointers, but still want to do games, then I recommend stepping back and trying to learn a higher-level engine. For example, Unity3D is very popular nowadays.

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!