SURFIX
------
This is a utility made to fix some of the problems caused by Breeze
Designer specifically, and possibly other software packages.

When saving, these programs turn objects into a series of triangles.
The problem with this is that for Meddle and other programs to work
correctly, these triangles need to be arranged a specific way, so that
it's possible to tell which side is the 'surface' and which belongs
underneath.

The program works with the .RAW file format which is usable by Meddle,
a model editor for Quake.  To use it, try it like this:

surfix -i broken.raw -o fixed.raw -n

This will read in the file 'broken.raw', fix the triangles, and then
write out the results to 'fixed.raw'.

To do this, it starts with the first triangle in the file, and proceeds
by fixing every other triangle that the first shares an edge with;
then fixes every triangle that THOSE share an edge with ... etc etc.

Unfortunately, this assumes two things:

First, it assumes that your first triangle faces correctly.  If it
doesn't, it'll still work, but everything will end up backwards from
the way you want it.
To fix that, use surfix to flip the the surface inside-out, like so:

surfix -i fixed.raw -o fixed2.raw -f

Second, it assumes that everything is connected into one large object.
If you have two separate ones (for instance, a player and his gun),
try saving them as two separate .RAW files, fixing them, then joining
them back together.
(Once you've fixed a .RAW file, it should be safe it import it back
into whatever you want to use to edit it without having to fix it
every time.)

Other known problems:

When Meddle saves .RAW files, it writes the name of the frame to the
top of the file.  This'll prevent surfix from working; just use your
favourite text editor and cut it out.

As an aside, because of Breeze Designer's dismal 'snap' ability, you
can also use this to make all the points snap to a grid of a size you
specify.  Use like this:

surfix -i fixed2.raw -o fixed3.raw -s 0.5

to force all the points onto a 0.5 width snap grid.

All the flags, -n, -f, and -s, can be used in conjunction with each
other.

Any problems/questions/requests can be mailed to:
tlawson@acs.ucalgary.ca
Source code for this is (probably) available on request.
