I spent the last few days exchanging the graphics engine in Daggerfall Scout from Irrlicht to Ogre. This came with enough surprises and frustrations to last me a few weeks.
To paraphrase one of the best quotes I’ve read while comparing these two engines: “Irrlicht quickly lets you get your project to the point where you need Ogre to complete it.” That certainly was the case DF Scout. Irrlicht required very little investment in time to get up and running, but poor mesh loading times and limited support for dynamic content were starting to be a drag.
Fortunately DF Scout talks to an engine wrapper that handles all the dirty work. I should just be able to swap in a new wrapper and everything will be peachy, right? The initial work was easy, and before long I had a new Ogre wrapper happily chugging coloured pixels into a viewport.
The next step was to build .mesh and .material exporters into the Cache Manager to change all that Daggerfall content into a format the engine could load and render. This required a few changes to DFLib to break meshes down into named submeshes rather than use attribute buffers (which is more common in D3D). Again, not so hard. I’ll even go so far as to say I enjoyed it.
Problems started when I loaded my first city and everything was back to front. All the meshes were in the right place, but they were flipped. Imagine looking a sign and the letters are back to front, and then imagine a whole building flipped that way. The effect was a little unsettling.
The root cause was that my old engines, and more recently Irrlicht, happened to use a left-handed coordinate system. This coordinate handedness is ubiquitous in my code (and my thinking). I use left-handed coordinates everywhere in DFLib, in DF Scout, in the content builders, in the scene files. Now in comes Ogre with its fancy right-handed coordinate system making my buildings look peculiar.
Of course, I didn’t work this out right away and spent a lot of time trying to fix my mesh builders, assuming I did something wrong in the new submesh breakdowns. When the penny finally dropped (with a clang), I just kind of sat there stunned thinking “how the hell am I gonna fix this, I use left-handed coordinates everywhere.”
After a quick cup of coffee and wishing I was a smoker – or that my girlfriend who is a smoker was home so I could at least get a passive hit – things didn’t seem so bad. In the end, all I had to do was change face index ordering in the mesh builder, and teach the engine wrapper how to deal with the conversion (a quick sign inversion of the Z axis). Of course this isn’t ideal. While it’s easy enough to fix handedness in the engine wrapper, the engine itself is still right-handed while the content builders are left-handed. This will probably lead to confusion down the road, and the confused person will probably be me.
And the results? Well, they’re awesome. Ogre loads its native mesh format incredibly quickly – even the largest cities fly into the scene almost instantly. The material system is excellent, far more power than required to render Daggerfall’s old content. This should give me some interesting tools as my experience with Ogre grows. Overall, the work has been worth it.
The downside is that I’ve spent a few days gutting DF Scout and more or less getting back to where I started. Oh well, back to the fun stuff.