Spoiler: What is an IQM?
IQM stands for "Inter-Quake Model". It is often used as a file that can be used between various Quake derived games. So what is so special about this format?
IQM is a skeletal format (the first one to come to GZDoom). The intention of the format is to serve as a replacement for MD5 and SMD (though at some point those may also come to GZDoom). IQM is a binary format, but it does have a companion format called IQE which is an ASCII format and it is pretty easy to read.
If you want specifications on IQM format, check here.
While in the past, models with skeletons would have needed to be converted to a vertex-based format such as MD3, that is no longer the case with IQM. As a result, IQM has smoother, better animations, and takes up much, much less space and memory.
Without further ado, let's get started!
Spoiler: Conversion Methods
There are a few known ways to convert a model to IQM. We will be starting from the easiest to the hardest. I will be very, very descriptive in my conversion processes.
Noesis is a multi function tool for converting a model to IQM.
2) The IQM Compiler
- You're gonna need a model that can actually be read by Noesis. A lot of formats can, but if your model isn't supported, try getting it to something like an FBX or SMD.
- Open your model in Noesis. You see this button the green arrow is pointing to with the red skeleton? If that button does not appear, your model is not a skeletal model and will not even work in GZDoom, at all. Not even if it is an attachment model. If your model is not supposed to be a skeletal one, then I'd refer you to a vertex animation format such as MD3. Once a model is converted to a vertex-based format, you cannot convert it back to a skeletal format, you will have to go back to the original file before it was converted to a vertex-based format. If you don't have the skeletal model file, then you're up the creek.
- Convert your model. Hit "Export" like the above screenshot.
- A menu has popped up! You must now change the format to IQM, then hit export.
- Open your new model, wherever you saved it to. You see the red lines on the model and the white dots? Those represent the skeleton. If you see those and/or the red skeleton button still, then that means you exported your model correctly. If you're just looking to make a quick conversion, then congratulations, you can move onto the next section, "Application in GZDoom". Otherwise, you'll need to try a different method.
For further methods, download the development kit here.
Truthfully I am not as experienced with this method. If that changes I will edit this tutorial.
The IQM.exe file from the devkit is a command line tool with a few parameters for quick conversion of the companion IQE files or formats such as FBX and OBJ. For most use cases you are probably better off just using Noesis, but if you want to make a quick adjustment to an IQM file you could use these tools to decompile to an IQE, then recompile back to an IQM.
Oh boy, this is the fun one! If you're looking for more control of your IQMs, you will want to use this method. Because I like being helpful, I will do what most tutorials won't do and show you how to use Blender to export your model to an IQM.
- You first need to download a version of Blender. If there is a plugin version from the IQM devkit that matches the one you intend to download, good, go ahead and download that version of Blender. Otherwise, there is no guarantee the plugin will work. I will not link you to a version of Blender.
- You will now have to install the plugin for your Blender. Navigate to your installation of Blender, and go through the folders blender version (i.e 2.74) -> scripts -> addons.
- You must now drop the python script file into that folder (should be titled iqm_export.py, if it's not, you got the wrong file).
- You will now open Blender. I will be using 2.79b as that is the version I am most comfortable with. At the top left, you will navigate the menu as such:
- You will now have to enable the plugin. If you do not see the plugin above the tool tip, you did not install it correctly. If it is grayed out, tick the checkbox, and press "Save User Settings". This process should be largely similar for Blender 2.8+.
- You now either need to import a Blend, or import an applicable model format from Blender. An easy one to import is SMD, as unlike FBX animations, SMD animations will automatically append to your mesh. If you don't have the plugins. For 2.79 you can download them here. Then you just install them the same way as IQM. (Or you can use the button to install from a ZIP in this case). Again, the process is largely similar as 2.8+.
- Navigate a model file to import, the options for import are more or less out of the scope of this tutorial. Just press "Import SMD" to the right.
- It's Lucifer from Painkiller. Isn't this a beautiful model? To do a quick conversion, you need to select each group. See those spheres? Those are bones. They have no actual geometry, what you see is just how they are represented in Blender. Just select the mesh in this panel with left mouse or right click it in the 3d window. In that scene panel? You should set the default framerate to 30. Do not set it to anything else unless you know what you are doing.
Also, take note of the orientation of the model. If you want to avoid any transformations in modeldef, make sure the model is facing this way.
- One at a time, I am gonna change the texture of each surface, so you will know how to change those and make them appear without the "Skin" property. I will use this fire texture I found online because Luficer doesn't actually have a texture in painkiller, he uses fire effects binded to each bone and that isn't supported yet. This process is different for 2.8 and frankly I do not know how to do it.
- Oh no! His walk animation moves the model during the animation. We don't want that! Let's add a modifier to clamp the location. There is probably a better way to do this, but this keeps him from moving forward. This is a root bone and has no other transformations to it.
- Now you are ready to import animations. You do this the same way you imported the mesh, except you import the animation clip. A format like FBX is not very good for doing this. You can import as many animation clips as you want, and they will be stored inside the Blend file.
While I would generally recommend keeping animations separate from your meshes, Blender's IQM exporter necessitates at least 1 triangle
- It is time to export your model. Because this tutorial will be teaching you about attachments, I will only select the body.
You need to select the meshes you want to export, or you exported as good as nothing!
- By default the exporter will guess your desired IQM file name. That's fine. You can untick bounding boxes as it takes a lot longer to export and GZDoom doesn't really use 'em.
List your animation names as a comma separated list. They will export in that order.
- We will now export the sword as an attachment. I will now select the sword. You export it like you did the body, but change the file name and clear the animations field.
- Now let's check Noesis. As you can see, these are indeed skeletal models, and a correct export looks like this. If the model is facing you, that means you won't need to rotate the model in modeldef. See the sword? Even though it has no animations, it still shares the same armature, and has joint data.
Spoiler: Application in GZDoom
In IQM's infancy, it behaves a lot like previous model formats have. However, there are a few tricks introduced to help you, the modder, use IQM to it's full potential. This list will only continue to grow.
Using in GZDoom
- In Modeldef
Model definitions for an IQM is very much similar to what you would define for a model such as an MD3, and it accepts the same flags and parameters as an MD3 does. In general, if you simply converted your models to an IQM instead of an MD3, (correctly of course), what worked for MD3 will work for IQM. But there are a couple features to take advantage of:
- Animations - the "Animation" property in modeldef functions identically to "Model" or "Skin" except that the function allows a specific model index to access an external IQM file for animations. But be careful! If your model does not have the same amount of bones or bone order, unpredictable results may occur. If your model is distorted when using this property, most likely your armatures are not the same.
- MODELSAREATTACHMENTS - This is a modeldef flag. This flag only matters for IQM models (or other skeletal formats). If you have, say, a character model made up of multiple parts like the body, head, weapon, hat, etc, then it is strongly recommended that you use this flag, provided each model you provided by index uses the same armature. You can not use this flag, but in the future, any bone manipulations made on an actor would have to be on a per-index basis. Furthermore, using this flag should be used for performance reasons, as there is a lot that goes on behind the scenes that has to be done on a per-model-index basis. This flag tells the engine to just treat any model indices past 0 as the same armature.
Let's see how this actor has turned out:
- From the example of converting a model, I will show the product in GZDoom. Remember that sword I exported separately. We do not need to define that here. We will however use "MODELSAREATTACHMENTS" to make it so the sword will automatically attach to the armature at index 0.
- Now, in a ZScript file, we are going to append the sword. This is the easiest way to add attachments.
I have attached a pk3 as a sample.
Spoiler: More questions
I'm not all that active on the forums. I may check here once in awhile but if you have any urgent questions, it's better to reach me on my Discord. I use the same name on the ZDoom Discord as I do here, so just send me a DM. If you don't use Discord, you can also send me a private message here.