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.

No comments:

Post a Comment