Saturday, May 9, 2009

.NET Programming - A Quake WAD Editor

This isn't a serious project, but just something that I partially worked on while doing the most recent round of MHColour development. In order to best determine how textures should affect light colours, I needed a quick and easy way of getting at the data in the textures. Dumping them out to disk is the most obvious solution, but I was intrigued by the idea of seeing how much of a basic WAD Editor I could get up and running in a short time.

I have TexMex and MipDip, but I'm fairly dissatisifed with what I see as lacking functionality in both. The WorldCraft texture viewer is great for quick searches and filtering operations, but sometimes I just need to get at the exact specific amount of RGB in certain areas of a texture, and having all of this present in a single tool would have been a very useful thing indeed.

.NET is very much my "go to" platform for casual GUI work (although pure Win32 is a lot more of a viable option that one might think), and Visual C# 2005 Express is all I need to do anything (I've certainly never noticed any shortcomings in it). But one thing .NET seems to go out of it's way to make difficult is working with pure binary data. There is an underlying assumption that the data will come to the application in an already well-structured format (e.g. from a database), but when you have a raw binary stream to deal with, and you're formatting the data structures yourself, things get very awkward very fast.

The single biggest stumbling block is not being able to do arbitrary casts between pointers to different data types. There are ways around, but this is something that I've taken for granted for close on 20 years now, so it's a struggle every time. It's such a cool programming environment, and platform, that's otherwise simple, fun and a joy to use, that when one hits such a problem it's almost the equivalent of a kick in the face.

Anyway, in the end any further work on this proved to be unnecessary, as I had resolved the issues otherwise, so right now I just have a bunch of C# code for opening and reading a WAD file. But I'm still sufficiently intrigued by the whole thing that I might make it my next project after I release MHColour. I think there's a definite requirement for a cool WAD utility that lets you do interesting things with the texture data. But if I do write this, I think I'll be putting the heavy-lifting raw binary data code into a C++ DLL rather than going a pure .NET route.

0 comments: