How to export models from Blender and compile them for GoldSRC

posted at April 11, 2013 in GoldSRC Tutorials

Hi there!

Since this has been asked I want to show you how to export and compile an *.mdl modelfile for GoldSRC from Blender, using the following tools:

BM SUV Toycar


Before we start:

Checking for the correct version of the Blender SMD Tools

The version of the Blender SMD Tools should be suitable for your Blender version. In case you dont know which Blender version your SMD Tools support, you can check this by opening the and looking for a line similar to the following:

	"blender": (2, 66, 0),
This should tell you which Blender version the SMD Tools support.

You can as well just try to install them in Blender an see if you can activate them. If not, they have most likely not the correct version.

A short summary on basic compile-conditions

Basically a model which you want to compile for the GoldSRC engine will need to fulfill the following conditions:

  1. a mesh with correctly aligned normals (faces might be visible in Blender but ingame they disappear due to inside out face normals)
  2. a proper UV map for the mesh (all faces should have proper UV coordinates)
  3. a material assigned to the faces in your modelling software (in Blender it will have to be named like the respective bmp file, e.g. body.bmp – Blender textures do not need any special naming though)
  4. at least one static animation sequence

    In case your model will just feature one static animation (where the model does not move at all) you can just export the so called “reference”-smd of the model without any armature or bones attached to it (why is that possible?).

    If you want your model to feature one or more animation sequences, you will need to fulfill the following conditions, too:
    1. an armature (Blenders skeleton system) and minimum 1 bone
    2. an action (animation) which is produced by keyframes (not just physics or constraints) in the timeline (for a proper preview choose a suitable framerate, e.g. “30″, in the render settings of your scene – this however will not affect the speed of an animation in-game, which is specified in the QC-file instead)

To export or not to export bones using Blender SMD Tools

In case you dont want any animation you can completely skip the skeleton/bone part and just export the model as an SMD. You will however need to have something like a blank idle.smd you can use for the most basic animation, which is mostly just the model in a static state.

A blank idle.smd may look like this:

version 1
0 "origin" -1
time 0
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

Using this empty idle.smd will only work for models that have no bones (or maximum ONE bone – bone “0″) attached to them in Blender, since the Blender SMD Tools are not made for exporting (fully) GoldSRC-compatible SMD files. This causes that all polys will be attached to bone “0″.

What this means for models with more than 1 bone I will explain later.

1. Getting the files

First of all you gonna need a model.

As an example I will use a model that already has some animations and one controller, a little toycar version of the Black Mesa SUV.
I am sure you have already seen it on top of this article.

1.1. Example-files Download

To make this tutorial more demonstrative you can (or rather should) download the project files here or on Mediafire.

These include the blend-file, the materials (PSD, truecolor and indexed), the QC-file (along with all so far exported SMD-files) and the final mdl-file “toycar_final.mdl”.

2. Exporting SMDs from Blender

When you open the project files directory you will find a number of subfolders, which divide the project files in a clean and well-arranged way.

You can of course choose your own way of arranging project files into subfolders. In any case: DO IT AT ALL (!), because it will become essentiall when there are a lot more different files and filetypes for complex models like those of NPC characters.

2.1. Open toycar.blend in Blender

Navigate to the blend directory and open the file toycar.blend in Blender (in case blend-files are not associated with your Blender yet, you should do that manually now).

2.2. Inspect the scene

When you have opened the file, this is what you will see (might differ when you told Blender to not load window configuration of blendfiles):

At the moment the only interesting objects for you are the skeleton “Armature” and the model “toycar“, which is already connected to the skeleton in 2 ways: an Armature-Deform-Modifier and by physically being parented to it. This was done by first selecting the toycar, then the Armature and then pressing CTRL+P and choosing Armature Deform-With Empty Groups.

How this is done in detail I will cover in a separate tutorial.

a) Find the toycar-mesh

If you havent already done that, press the small (+) button left of the armature in your scene navigator to see the underlying objects.

b) Select the armature

If you select the armature you can also see that there is already an animation sequence associated with the armature. As you will see later, there are even more sequences.

c) Look at the current animation sequence

You can already play the current animation by moving along the timeline with the right mouse button pressed.

d) Look how the toycar mesh is parented to the armature

If you want to see how the toycar mesh is parented to the armature, you can navigate to the Object-Modifier tab in the middle of the Properties-panel:

Try to turn off the Armature-Modifier by either unchecking “Bind to: Vertex Groups” or pressing the little eye-button in the armature-header area, then move the armature around (select it, press G and drag).

You will see that the toycar is still following the transformation of the armature-object. This is because it is still bonded to the armature physically by being parented to it.

You could dissolve this relationship by selecting the toycar and then pressing ALT+P Clear Parent.

In the navigator the toycar will then not underlie the armature object anymore.

If you want to redo the relationship between these two objects, first select the toycar, then the armature and then press CTRL+P-Object (considered you still have the Armature-Modifier added to the toycar, if not: choose With Empty Groups).

e) Discover the rest of the animation sequences

To see all of the associated animation sequences of the armature, you will have to create a new window (or rather create one out of another).

For this navigate to the bottom left corner of your timeline until your mouse cursor changes into a little cross.

Grab and drag this cross to create a new window. You will probably have to resize both of them.

Turn the new window into a Dopesheet.

Where it says Dopesheet in the menu bar of the Dopesheet window, choose Action Editor instead.

You can now flip through the various actions of the armature and watch them by moving the timeline.

2.3. The SMD Tools

So far so good, but now you probably want to learn something about the relevant stuff.

With every new version the SMD Tools have changed a bit, both in their features and interface, so if you are using another version than 1.6.5. you will probably have to translate the following steps to your version.

Once again:

The Blender SMD Tools are made for exporting Blender files into the Source SMD file format. However the Source and the GoldSRC smd format are pretty close to each other, so it is still possible to export smds for simple models (e.g. without animation or only 1 bone) without any further steps (as I explained above).

Differences between Source and GoldSRC reference SMD-files

What does this mean for our example toycar model? Maybe it gets a bit more clear if we look at the difference between these two formats.

Here are some lines of the reference-SMD file of our toycar in Source format (as it will be exported by the Blender SMD Tools):

0 1.000000 -1.362009 1.847306 0.163518 -0.346416 0.923704 0.231964 0.684915 1 1 1.000000
0 1.239749 -1.346065 1.771808 0.856990 -0.159764 0.489914 0.230389 0.651338 1 1 1.000000
0 1.031438 -0.038912 2.795163 0.690054 -0.216895 0.690451 0.450439 0.675454 1 1 1.000000

These are the same lines, just that they are now compatible to GoldSRC:

1 1.000000 -1.362009 1.847306 0.163518 -0.346416 0.923704 0.231964 0.684915
1 1.239749 -1.346065 1.771808 0.856990 -0.159764 0.489914 0.230389 0.651338
1 1.031438 -0.038912 2.795163 0.690054 -0.216895 0.690451 0.450439 0.675454

The most important difference (which makes a Source SMD file useless for us in the first place) is, that all triangles are assigned to bone zero (the first number of each line), instead to the correct bone number.

Instead you will find the bone and weight information for the Source format at the end of the line, where it is usually ignored by common GoldSRC model compiler.

How we will overcome this issue, I will tell you in one of the next steps.

2.4. Setting up the SMD Tools

a) Navigate to the Scene properties in your Properties panel…

… and scroll down to the bottom. Here you will find the settings of the SMD Tools.

b) The export buttons

The SMD Tools will let you export seperated objects (e.g. “toycar.smd”) as well as the whole scene (which means that all available meshes and actions will be exported unless you say otherwise) by pressing one of the first two main export buttons.

c) How to export actions only

If you just want to export the actions of a selected armature, you can either choose to export only the action that is currently shown in the timeline (or NLA) or all actions of the armature, by choosing the Action Filter option.

The export button will then say something like “All actions (4)”.

In our case, choose Action Filter, to export all actions that are associated with the armature.

d) How to choose objects that are going to be exported when pressing “Scene export”

To define wether objects are exported by the Scene export-button or not, just check or uncheck those objects at the Source Engine Exportables section. Usually you will just want to export your final model meshes and its animation.

In this case there are just two objects shown, the armature (actions) and the toycar-mesh and we want both to be exported.

e) Define an output folder

This is what we probably should have done in the first step (remember to slap me for that). If you dont specify an output folder, the SMD files will be exported to the root of your current working directory, since Blender uses relative paths a lot (what I like a lot by the way).

We want our “smd”-folder to be the output folder in this case.

You can as well just type in something like that:


This is a relative path to the SMD folder as recognized by many other windows programs (as I suppose). It says “from the current root folder (//) move one directory back (..\) and then enter the smd-folder (smd\)” (I just put two and two together here, dont take me too serious).

By the way, by default, animations will be exported to a seperate folder called “anims”. As I realized it before, there is no way around this (but its not so bad either).

2.5. Exporting the Scene

a) Get ready to export the scene

Since I have gone a lot into detail and messed up your mind, let me recap the steps for exporting our toycar-scene again:

  1. specify an output folder (“//..\smd\“)
  2. at “Source Engine Exportables”:
    1. choose the Action Filter while having selected idle1.smd in the objects list
    2. check idle1.smd and toycar.smd in the file export list
    3. in case its checked, uncheck the Impicit motionless bone option at the “Armature Properties”

b) Export the scene

Press Scene export now.

c) Inspect the exported files

In case the smd export was sucessfull, you should now find several new files inside your smd folder:


Most of these files can already be used to compile your final model with, but, as I explained earlier, there is one exception.

Because of the Source format we will now have to convert the reference-smd (toycar.smd) into a GoldSRC compatible smd format.

3. Converting Source SMD files using Milkshape

As there is no other (practical) method I know about, I will now tell you how to convert your Source SMD file into a GoldSRC compatible version by using Milkshape 3D.

Basically its as simple as just importing your reference-smd into an empty MS scene and then exporting it again under the same name (maybe into another folder, e.g. “..\smd\fixed\“).

But just to be sure, once again:

a) Open Milkshape

b) Open a new file

In the menu choose File-New to reset the scene.

c) Import the toycar.smd

In the menu choose File-Import-Half-Life SMD while leaving all settings checked (Triangles, Skeleton and Rename Bones, even though I consider the last one is not doing any difference).

d) Export the scene

Now just export the scene again File-Export-Half-Life SMD using the settings Reference (but no Vertex Weights)

And that was the whole process of converting a Source SMD into a GoldSRC SMD.

You can now move on to creating a QC-file.

4. Creating a QC file

QC files define the properties of the compiled model and put together everything, that has been created so far – your model (the reference smd files), its animation (the animation smd files) and its materials.

Additionally you can specify things like bone-controller (e.g. for controllabe heads and mouths), body-groups, texture-groups, advanced settings for animation sequences and attachments (e.g. for sprites like muzzleflashes or the gargantua eye glow). You can also specify Hitboxes, the position of the entities eyes and even more stuff I dont remember right now (I am not a brainman, you know).

For now, we will be satisfied with setting up a simple QC file, where we define some paths, the animation sequences and one controller.

For more detailed informations about setting up QC files, please google for any Half-Life SDK (2.3 seems to be the latest). It will contain a doc-file similar to “Modelling for Half-Life.doc”.

Basically I can tell you, that the qc file contains information in the form of commands that begin with a $-sign. Dont get scared and associate this with coding though!

a) Creating a QC-file

In the root project folder create a textfile and rename it to something like “built.qc“.

b) Specifying compile-paths using $cd and $cdtexture

The following lines are more or less important for the compiling process to be successful. Put those into your qc-file:

$cd smd
$cdtexture mat_index

Paths can be absolute or relative. Relative paths are relative to the position of the qc file.

Absolute paths should look like this:

$modelname D:/Modelling/blender_smd_tutorial/toycar.mdl
//or (in case folder names contain spaces):
$modelname "D:/Modelling Projects/blender_smd_tutorial/toycar.mdl"

Relative paths can look like this:

$modelname toycar.mdl
$cd smd

Note: If you dont have any subfolders, you can as well completely leave out $cd and $cdtexture.

Note: $cd will be the base for all further paths where smd files are involved (e.g. those of $body and $sequence).

c) Specifying your final modelname using $modelname

$modelname toycar.mdl

d) Specifying the scale of your model using $scale

$scale 4.0

Usually, if the models scale is already matching the final ingame size, you can skip this command.

e) Specifying the main body-mesh using $body

$body studio "fixed/toycar"

Here you just place the path and name of the reference-smd that contains the models mesh.

Note: Any declaration of files (except $modelname) happens without adding the file-extension! Thats why “toycar” is not “toycar.smd” and sequence-paths are specified like “anims/walk” and not “anims/walk.smd“.

f) Specifying sequences using $sequence

This is where it gets a bit more confusing and complex, even without having a complex character model.

$sequence static "anims/static" fps 10
$sequence idle1 "anims/idle1" fps 30 LOOP ACT_IDLE 1
$sequence driveslow "anims/walk" fps 30 LX loop ACT_WALK 1
$sequence drivefast "anims/run" fps 30 LX loop ACT_RUN 1

I would also recommend that you take a closer look at existing qc-files (which can be generated out of any compiled models by decompiling them, e.g. using the MDL decompiler by Jed, OR you just look at those that are shipped with the Half-Life SDKs).

Just to explain this one a bit closer:

$sequence driveslow "anims/walk" fps 30 LX loop ACT_WALK 1
  1. driveslow – This is the name of the sequence that is visible in the final mdl-file. This name can also be used by various entities in hammer, like the scripted_sequence.
  2. "anims/walk" – This is the name and the path of the animation-smd for this sequence.
  3. fps 30 – This is of course the framerate for this sequence (here it finally gets specified – remember that specifying FPS in Blender hasnt any effect on the exported animation).
  4. LX – This short value defines, that the transformations of the model during these sequence are affecting the characters actual location and rotation in-game, which is important for a lot of animation-sequences where the character covers a distance (e.g. a simple walkcycle).
  5. loop – This indicates, that the animation is an endless cycle (e.g. like an idle-animation).
  6. ACT_WALK 1 – When you use this on a sequence, the characters AI will be able to use this sequence for its usual in-game behaviour, like walking, turning around, getting hit and attack. The last number specifies the possibility for playing the sequence.

Simplified a $sequence command can as well look like this:

$sequence idle1 "anims/idle1"

g) Specifying bone-controller using $controller

And at last there will be a controller for the little Black Mesa logo on top of the SUV. Controller are named like the correspondent bone and put into groups, in case one controller controls more than 1 bone:

$controller 0 "logo" YR -90 90
  • 0 is the controller ID (0 – 3 are possible)
  • logo is the name of the correspondent bone, which will then get controlled
  • YR says that this controller controls the rotation of the Y-axis of this bone (X, Y, Z)
  • -90 90 – these are the minimum and maximum limits of rotation

5. Compiling the model using GUI StudioMDL

When you have set up your qc-file so far, you can finally give it a shot and compile the model. If there is still anything wrong at this point, GUI StudioMDL will hopefully tell you what, so you can fix it.

But for this to happen (or not to happen, depends) you will first have to install GUI StudioMDL. When done, just navigate to your project folder, where you created the qc-file, and run it (that is, if qc files are associated with GUI yet. If not – try it manually).

6. The final model

If the compile process was successful, you can now open the toycar.mdl.

You can try using it in-game.

I went a bit further and replaced my barney.mdl with this and it worked just fine. The game even uses the logo-controller for Barneys head-movements.

7. What else?

Well, I know I have left out a lot of information, but think about it. I can hardly put all the details into one tutorial, that would be insane :)

I hope I was able to show you the principle of the process and even give you a bit background information.

Information about QC-files

If you need more informations about QC-file setup, look for the Half-Life SDK on the internet, it will be there, anywhere.

For example here.

Blender Tutorials

If you want to learn more about Blender, look for Blender tutorials on the internet, its not that hard. Video tutorials are good for people who learn stuff better by seeing it (like me).

The site Blendercookie features a lot of free video tutorials and there are a lot of good Blogs like and

Is there any alternative to Milkshape?

I am afraid this is a question where I dont know a good answer for. I thought of building a script that does the same as Milkshape, but I am not a coder of course. Unfortunately the author of the Blender SMD Tools doesn’t seem to find it necessary to built in this little feature (maybe hes just not aware of it?!).

If somebody knows a good alternative or way to do this, please leave me a message and my special thanks goes to you!


7 comments on “How to export models from Blender and compile them for GoldSRC
  1. Hi,
    first i have really appreciate your tutorial, very helpful! Great job!

    I am making a sentry for TF2, but for now i want to import it in Source Film Maker. I can get a .mdl who work. But i don’t know how i can import my rig.
    I have create a really simple rig for now with two bones, my sentry is attached to it. The sentry is one model and i have used vertex group to move the two parts.
    If i export i have two folder my model.smd and a folder anim which contain my action created in the dopesheet in smd. But when i export i still have no bone (just the rootTransform default bone when something have no armature…).
    Here is my .blend with the settings:
    My .QC contain: $sequence turn “anims/spinning.smd” loop fps 30 ACT_IDLE 1
    The name of the spin animation.

    Please help, i am stuck since several days, i can’t upload my sentry on the workshop because of that. :(
    Thanks in advance.

    • Hi and thanks :)

      This tutorial is written for Goldsource, so I cant say how far it is compatible with the working process of a Source model. Also your linked file ( seems to be down at the moment.

      Your sequence line contains the file extension “.smd” which might be a problem, better remove it.

      So far I cant tell you the exact problem. Either sent me the blend and QC or post the settings you used, but you would be better off posting this problem in a Source modding forum since I am not a Source expert :)

  2. Excellent. Nobody really covers the controller setup and sequence attributes like you did in this segment. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

QR Code Business Card