Download horror.zip

This is a flying monster, vaguely based on the description of a Gaunt. The model comes with hovering, flying, death, pain and melee animations. The mdo file is also included so you can tweak the animations. But beware, as you will be afflicted with a terrible curse if you do! Let me weave a tale of this model’s history and how only the mighty Python can lift the curse…

I made this model back in 2004. At that time I didn’t have some of the tools that quake benefits from now, like reliable conversion of md3 models to mdl. This model got converted via md2 instead. In order to fool QME into saving it as a mdl file I split every vertex in the model. I then spent a long time merging just enough of them back together to get under the 1000 vertex limit. This worked, and so I went ahead and released the model – it even got into Prydon Gate!

Many years later I’ve come back to this model and the vertex problem bothered me for two reasons. One is that it was pretty messy to have all these loose vertices which weren’t merged. The other was that in the meantime I’ve discovered quake supports vertex normals, so the split vertices actually appear different than if they were merged. Unfortunately, I didn’t have a lovely version animated in a model editor (other than QME) to just export using the 2012 pipeline. What to do?

In the end I decided to use it as a chance to show off the power of qmdl – the python module for mdl format

Included in the zip is:
horror_original.mdl – the model that you get by saving the horror.mdo file as a mdl
horror.py – a python script which will transform that model into one with better merged vertices and repaired normals

The python script contains lots of comments to try and explain what is going on, but it’s not a good introduction to the qmdl module because the algorithm is quite complicated. The essence of it is:

  1. Split the vertices into groups we want to merge, and define a ‘key function’ which outputs a unique ‘key value’ for each group, when given any vertex from that group.
  2. Create a dictionary, and store each vertex in a list under their ‘key value’ in that dictionary.
  3. Average the vertex normals of each group, and apply the new normal to every vertex in that group
  4. Repeat steps 1 and 2 using a slightly different ‘key function’
  5. This time merge all the vertices in each group

Step 5 is the hardest to understand, you need a very good grasp of how mdl format is stored internally. To understand the step involving the triangles of the model, you need to know that we are running through the ‘merge groups’ in the order they appear in the dictionary. Because each group is going to become a single vertex, we need to use the index of each group in the list as the vertex number for the triangles. Phew! The vertex and frame code is simpler: since all the vertices in each group are identical (as far as we care) we just take the first one from each group and insert it into a new list. The critical thing is that we run through the groups in the same order each time, so that all the parts match up.


2 thoughts on “Horror

    • That’s pretty cool, although I’m not sure I understand where the rendered images come from. As far as I can see the code he links to does more or less the same thing as qmdl, create a python object representing a mdl file. There’s no room for a renderer in the file, so I don’t know if it relates to the pictures.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.