Loading .Obj into Opengl

Started by
5 comments, last by GameDev.net 17 years, 10 months ago
I think I have enough knowledge of opengl(on win32 platform) to write a very basic pong game and I wanted to be able to load my models.I've searched the web for many many hours and have come up with not much. What I am asking , please, is there anyone who can point me to a good .obj loader? my meshs are simple (I customized the paddles). Thank you who respond in advance.
Advertisement
OBJ file format:

http://www.royriggs.com/obj.html

If it's a simple pong game, do you really need models?

Anyway, I've been looking a bit, and can't really find anything good, so you should find the obj file specifications (just google it) and you should be able to find the documents on the way the obj format is laid out.

I haven't tried it myself, but I've heard that it's not particularly complicated, and if you're doing graphics, you should have had experience with file IO, so you should start writing a loader and then come to us with your questions.

Assuming you're talking about the text format and not the binary, here's something that might get you started: Fileformat.info: Wavefront OBJ
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Here is an old thread from this site that explains how to load OBJ files.
-----------------------------Play Stompy's Revenge! Now!
true Endar but it would be better in the long run. Thanks, I'll go through and check it out. Just in general, doesn't it seem wierd that there is no easy load library for objects in opengl or at least some agreed apon format like direct3d has .x format. Hmm oh well and thanks :)

[Edited by - Asem on June 11, 2006 10:45:25 AM]
GLM is a pretty good and stable library(from my experience). You're right that it's not easy to find OBJ loaders in the web, it took me almost an hour of googling to track it down.

You can build it as a .lib, but I usually just add all the files in the "/glm-0.3/glm" folder in my project, specify "/glm-0.3/glm" as an additional include directory and that's it. In case you need a quick start, an example:

//Loading the modelGLMModel* model;model=glmReadOBJ("c:/models/airplane.obj");glmVertexNormals(model,180.0,false);//Optional-recalculates and smooths the normals//Drawing the modelglPushMatrix();//transformations here...glmDraw(model,GLM_SMOOTH|GLM_TEXTURE|GLM_MATERIAL);glPopMatrix();


Beware: You need to use "/" and not "\\" when specifying the path for the .obj files. GLM only understands it this way.

Also, you can go and download 3DWin, which is a converter for many 3d formats, including Wavefront OBJ. So you can take a,say, .3ds file, convert it to .obj and load it using GLM.
Is there anything like GLM but for windows? I need to load obj models using openGL and I can not find something quick and easy on the web. Any help?

Thanks!

Edgar

This topic is closed to new replies.

Advertisement