Tuesday, April 6, 2010

Rolling a custom model format

The first significant change I made to my engine after the launch of Virtual Table Tennis 3D was the implementation of a custom model format. This would speed up the loading of model assets since I wouldn't have to decode an MD2 file at runtime. My goal was to create a format that stored data in such a way that it could be passed to GL unmodified. This way I would be able to take a pointer to the file data and pass it directly into a glBufferData call. I also wanted all the other information that GL vertex buffer objects expect to be contained in the format (e.g. # vertices, # position components, etc). I named the format "Embedded Model Format" or "EMF" (what an imaginative name!).

I also added a conversion stage to my asset tool that would automatically turn all MD2 files into EMF files before being copying the asset to each platform's output folder.

Here is a screenshot of the format spec taken directly from my source code.

No comments:

Post a Comment