The Social Geek

A never ending story of a never stopping idiot!

OBJ Loader in OpenGL

February10

Our CG Course teacher Sir Fawad gave us an assignment for creating an OBJ File Reader in OpenGL. The OBJ format is an ASCII file format that represents 3D geometry. I was able to code a beautifully working OBJ Loader in a rather short time, showing a 25k+ faced tree model. It took some time to study how the OBJ Format is generally laid out and once I was done with that, that was just a matter of having to knock my brain and ask for some attention to C/C++ coding.

So, you can grab the OBJ Loader here (source file included):

http://www.thesocialgeek.com/ObjLoader.zip

Once I did that and emailed to Sir Fawad, he immediately replied back and appreciated what I did. But he asked if I can alter the code and implement the silhouette edges in this OBJ Loader. I made some use of my brain again to come up with the silhouette edges implementation of the same OBJ Loader:

http://www.thesocialgeek.com/ObjLoaderSilhouetteEdges.zip

* Please note that this second link only contains EXE and CPP file. The required OpenGL and OBJ files are in the first download link above.

I’m posting it here for some people might like to learn from it or heck use it for their own assignments straight away.

Cheers,
Kami

P.S. I’ve used GLUT as the windowing toolkit and C/C++ as the language. Sane troopers may use their skills to tailor it to other environments.

5 Comments to

“OBJ Loader in OpenGL”

  1. On March 9th, 2008 at 3:23 am MrPickle Says:

    Nice, this helped me out.

    BTW, When you close the program, it stops responding.
    I think that’s because you’re not deleting *fp.

  2. On March 9th, 2008 at 9:41 am Kamran Says:

    MrPickle: Ummm, I haven’t experienced the ‘not responding’ issue with me here at my side. Some other guys in my class have used this code and they don’t experience it as well.

    And yes, I’m closing the *fp (you’d find the fclose(fp) call in the source files).

    Wonder what’s causing this problem at your end, sorry =(

  3. On March 28th, 2008 at 8:23 pm Greatful Says:

    This is a nice bit of code, would be nice to see how you achieved your texture loading, but never the less a very succesful attempt

  4. On March 28th, 2008 at 8:35 pm Kamran Says:

    Hey Greatful, i’m greatful for the nice comments ;) I might try texture loading some day if i feel motivated, thanks =)

  5. On July 7th, 2008 at 9:07 pm thanks Says:

    Thanks man

Email will not be published

Website example

Your Comment: