qmdl v0.5 by Preach (andrew.denner@btinernet.com)
http://tomeofpreach.wordpress.com/qmdl/

        About

qmdl is a python module for reading and writing .mdl format files. It can decode a valid .mdl file into a python object. You can then modify the model's values directly in python, or use some of the helper functions to change the more prickly parts. Finally the module will export the modified object back into .mdl format with your changes reflected.

     Installation

qmdl is developed in Python 3.3, other version of Python have not been tested (please send me some feedback if you are brave enough to do so!). To install, extract the "qmdl" subfolder from this zip into your python "site-packages" folder. If you want to use the append_skin method in the Helper module, you must install the Python Image Library. At time of writing, the best option is the Pillow fork found at:

https://pypi.python.org/pypi/Pillow/

Note that as of v0.3, the Helper module will load without an error if you don't have the library, and you can perform non-skin operations freely. Handy if you can't get PIL for your version of Python.

        Usage

The "helper" module is the easiest way to make use of the library, and inspecting the module's code serves as a guide of how to use the "mdl" module. There follows a short example of using the helper:

#import and setup a helper model
from qmdl.helper import Helper
knight = Helper()

#load an existing model file
knight.load("dbaron.mdl")

#rename the frames
knight.rename_frames(
    [
        ("stand",10),
        ("walk",20),
        ("run", 8),
        ("swing", 14),
        ("smash", 15),
        ("cast", 25),
        ("pain", 6),
        ("longpain", 14),
        ("die", 10)
    ])

#make the stand animation a framegroup
knight.group_frames(0,9,"stand")

#import an alternate skin from a file
knight.append_skin("green_armour.bmp")

#modify the underlying model object to set flags
knight.mdl.flags = 4

#save the changes
knight.save()

		Changelog
	v0.5
Several fixes included to improve compatibility of models with winquake:

* onseam flag uses the value 32 instead of 1 to prevent visual corruption in winquake
* added helper functions to correct bbox_maxd and bbox_min values for frame to prevent
a crash in winquake
* added recalculate_header function to calculate correct values for boundingradius and
average_size fields, improving rendering in winquake.

The helper object has been enhanced to automatically run these helper functions on the mdl file before each save.

	v0.4
Support for Md3 format added in new module. Same principle as the existing Mdl module. Also an example script (to be expanded on) which performs conversion from Md3 to Mdl format.

Two new methods added to the Mdl module for dealing with models that mix framegroups and frames or skingroups and skins. The basic_frames member is a generator which iterates over all the poses of the model - i.e. returning the individual frames one at a time when encountering a framegroup. basic_skins works the same for skins.

Various tweaks to the rest of the code to make it more "pythonic".

	v0.3
Adds merge_vertices method to the Helper object. This function merges together vertices which can be combined without changing the model visually (optionally the method will disregard vertex normals for this calculation). Most helpfully it will create seam vertices, so it can restore a traditional skinmap to a classic quake model which has the original mapping stored in "complex skinmap" format. mdl -> md3 -> mdl conversions can now be more-or-less lossless.

The main Mdl modules have various improvements which came out of developing this method - some functions have been added to the core Mdl object, and the code for calculating vertex normals has been optimised so merge_vertices runs faster.

Helper module no longer requires the Python Image Library until you try and use the skin methods.

	v0.2
Added Helper module to perform simple editing tasks, particularly the kind of tweaks needed to turn the output of md3tomdl into a finished model.
Updated the Mdl module so the functions have proper docstrings.

	v0.1
Initial release for loading and saving valid .mdl files.