New material support is completed and in the engine. The screen shot below is a quick test of a model with multiple materials applied (and outlining turned on because I never get tired of the effect).
Model was created in Blender and exported with my export script, with zero tweaking of the data in the model file. I just load it into the engine and it works. I could get addicted to this kind of toolchain!
Whew, nothing like getting your code working well and then realizing that adding a new feature to it requires large amounts of refactoring to keep the code readable. I’ve started adding material support to Tsunami, but trying to work it into the mesh creation code was proving extremely difficult. Up until now I had been creating the mesh directly as I parsed the file, but adding materials gummed the works up to the point that I realized I had to throw the existing file parser away. Even if I managed to get it work, the whole thing would be so ugly that nobody else would be able to work with it at all, and I wouldn’t have wanted to.
So, I split the mesh file parsing and mesh construction/rendering code into two separate classes. It’s much, much easier to understand what is going on across the board now, much more robust, and it should also make porting the engine to other platforms (Direct3D, XNA) much simpler later on.
So far the output script for Blender has been modified to export mesh data and the file parsing code to get it into memory on the engine side of things have been completed. Those are the hard bits, too, so actually getting the data out of the parser and into the video card should be a snap.
I need to put some more art up too. The gallery just feels so neglected at the moment.
XVidcap isn’t capable of capturing OpenGL windows very well due to my oldish CPU, so sorry for the low resolution of the video. It was either that or slideshow.
As the video shows, Tsunami now has full skeleton-based skinning support.
And it’s pretty fast too. The screen shot on the right is 50 bugs clapping at the same time on a Turion clock-locked at 800Mhz and integrated video. 60FPS, 36% CPU usage. I should be able to halve that pretty easily by adding VBO support and tightening up some of the inner render loops a bit (along with the graphics on Level 3).
Last night I wrote a matrix class to handle skinned mesh transforms. I might move the PC version over to do the vertex weighting in shaders on the GPU later on, but while I’m still toying with the idea of ports to various portable systems (PSP, Wiz) I thought it prudent to design the engine to work primarily with software based bone transformations. Besides, its always good practice to go over the basics again.
Hopefully I can put the actual skinning code in place tonight.
Nothing really fancy going on here, just bog-standard extension of vertex positions along normals, flip the face culling mode and render solid black. I thought about doing it as a post-processing effect using a Sobel filter, but I like having the lines get smaller on the objects as they get farther away.
Sadly, it wrecks havoc with non-volume geometry, such as the antennae. Thankfully this is easy to work around by just modifying the model, but I might put an edge case in to handle this sort of thing later on, if I should really need it.