Now that I’ve got my laptop back, though, I’ve been working on updating my mesh file format. Previously, I was using C# to read Collada-format files and turn them into my own internal format. It was hard to extend because I was just querying the XML directly, and Collada is actually a pretty complex format to parse, so I wanted something easier to use.
And that something turned out to be the Open Asset Import Library. It supports not only Collada, but a whole host of other formats as well. It also performs a bunch of post-processing to triangulate, optimize and rearrange the mesh, it’s great!
Another thing I wanted to do was write a tool for viewing meshes with various different options for changing the view and so on. This was mostly for debugging so that I didn’t have to start a whole new game just to see whether a mesh could be loaded properly.
So that’s why I wrote the tool you see on the right. This is the “mesh viewer” tool and it’s a standalone tool that lets you load .wwmesh files and view them with various different options. You can view them in wireframe mode, change the base colour, show/hide the ground and so on (actually, that’s all you can do at the moment, but I’ll be including more options in the future)
One of the things I had to do in order to allow this is I had to split up the game into “framework” (or “engine") and “game” code. I had already written the game such that there was a special “framework” directory which included things like my Direct3D interfaces, sound processing, etc - all the generic stuff that can be reused in another game - but I just had to make it into a static library so that I could use it for the mesh viewer tool as well.
I split it into a static library that is linked directly with each executable. I suppose I could’ve made it a DLL which was dynamically linked with the executable, which might’ve saved a bit of disk space (since I’d only have one copy of that code) but in the end, it would’ve meant quite a few changes to the build process, and to be honest I don’t think the benefit was all that great. So static library it is!
The new .wwmesh file format that I’ve written is a binary format. I designed it so that reading in the data consists, basically, of a couple of calls to fread() and not much else - the data is already in the “native” format that I send directly to the GPU so it should be really efficient. Currently, it only supports the same features as the old .wwmesh format (which isn’t many) but I’m planning to add animation to it in the near future.
One little feature that I’ll mention is the “base colour” of the mesh. Basically, when designing the texture for the mesh, if you leave parts of the mesh with a non-1.0 alpha value, the pixel shader combines it with the “base colour". This is how I plan to implement different coloured units for different players. In the screenshot above, you can see the checkmark in the “red” colour and the mesh itself is also red. In other screenshots, you can see what different colours look like. In the future, I was thinking I could extend this so you actually supply a base texture and so you can have patterned units, but that probably won’t make it into the initial release.
So anyway, the next step, as I say, is animation support. That might take a while, because my previous experience with animation has been pretty limited. We’ll see how it goes anyway!