If you've downloaded any of the OpenGL-related sample code from Apple, like GLGravity or TouchFighter, you may have noticed that instead of using OBJ, MD2, or Maya files, they tend to store the 3D data in C header files that contain a vertex array, a normal array, an index of faces, and a count of faces. Pretty much the same approached I used in porting the NeHe lessons, just with a lot more vertices.
There's something to be said for this approach - it's efficient because the data is already in the format OpenGL needs. But how did they create those header files?
Well, I don't know for sure what tool they used, but what they might have used is this Perl script written by Margeret Geroch It will take an OBJ file and convert it into a C header file that you can feed directly to OpenGL without having to do messy conversion work. For the impatient, here's a direct link to the script.
One thing this script doesn't do, however, is convert the texture coordinates, so if anybody out there knows of a similar tool that also handles texture mapping, please let me know.
I've started working on converting the normals for the OBJ loader, and hope to post it within a few days. If your models are going to be complex, you probably want to look at the header file approach, as it will probably be faster.
Monday, December 15, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment