MD2 File Loading Code 1.0 reviewDownload
Using only standard C++ libraries, theMD2 File Loading Code will load an MD2 model file and a PCX texture.
Using only standard C++ libraries, theMD2 File Loading Code will load an MD2 model file and a PCX texture. Surrouning code uses the MD2Model class and SDL to setup the application and OpenGL view and display the animated model.
I need code to load MD2 files to use in my game engine (under development) and when I saw that my copy of OpenGL Game Programming had a chapter on it, I was pretty stoked. I figured "hey, this ought to take only about what, 20 minutes to get working?" I was wrong. I ended up rewriting the entire file loading code, restructuring the class, renaming structures, removing functions, and organizing and abstracting the code better because the original code (sorry Kevin and Dave) just didn't work (endian issues which were a PITA to try to fix in their code) and didn't stand up to my rigorous standards of quality code.
The code in this project is really in three parts. Main.cpp is just along for the ride. It sets up the OpenGL view and handles input (using SDL). Object3D is a class designed to represent an object that animates (or doesn't). It's designed to contain more than one loaded MD2 model so that they can be treated as one object and be synchronized in state and animation. The MD2Model class (MD2.h/cpp, Texture.h/cpp) is used only to load the MD2 and texture (PCX only in this code) and to draw it. That's it. No state handling at all, because that's managed in the Object3D class.
Anyway, if you just need to get MD2 file loading working, just take the MD2.h/cpp and Texture.h/cpp files. That's all you need. The file loading is endian-aware so it should work on every platform, unlike all of the other code out there.
Completly freeware for non-commercial use.
MD2 File Loading Code 1.0 search tags