Thursday, December 18, 2008

Progress on the Wavefront OBJ Loader

As you can see, I've done a little more work on the Wavefront OBJ loader. The individual components (groups) of the model now get loaded and displayed separately, and each group gets drawn with its correct surface properties. Textures still aren't supported, and I haven't done the normals yet either, so the objects still look flat, but this was an important step, and a more difficult one than I anticipated. Next, I'll tackle the normals so we can start playing with lighting, and then will finally move on to texture mapping.



You can find the current version here.

You'll notice a delay after the program launches. That's from loading the plane, which has several thousand polygon (3745 vertices, 7446 faces). Based on that, I can see why Apple creates header files with their model data - doing so is quite a bit faster than loading objects from traditional 3D files. Object loaders like this are probably fine for many purposes, but for complex data, you're probably better off generating header files for your 3D data. I'm going to continue working on this class because I'm learning a lot by doing it, but I'm thinking that it may be too slow for use in most production apps, especially games. Then again, for a game that's going to run on a 320x480 screen, there's absolutely no need for a model with 7000+ faces.

The data loading right now is double-loading the face indices - I wanted to make sure the new version was working before I removed the old code (that lumped all the indices together), but I'll remove that in the next version, which should improve loading performance some.



4 comments:

riq said...

Nice work Jeff!

I would like to include the wavefront obj loader as part of an iphone game engine that I'm developing (cocos2d: http://code.google.com/p/cocos2d-iphone)

What's the license of your code ?
thanks,

Jeff LaMarche said...

riq:

It's not done yet, but when it's done, it'll probably be MIT license.. or the BSD license - definitely something non-viral, and if I select something that's not compatible with what you've chosen, just ping me via e-mail (my first name underscore my last name at mac dot com) and I'm sure we can come to an agreement.

Jeff

riq said...

Ok, thank you Jeff

Sara Reid said...

The system that I wrote ended up being a lot like a primitive OpenGL. Ever since then I've been fascinated by 3D graphics. During my life as a Java/IT consultant I never had time to pursue it. Now that I'm an iPhone developer and not constrained by stuff that an IT department want's to pay for I've decided to spend some time investing in getting my brain wrapped around OpenGL.

carte sdhc 8gb