Team Fortress 2 is the sequel to the game that put class-based, multiplayer team warfare on the map. It delivers new gametypes, a signature art style powered by Valve's next generation animation technology, persistent player statistics, and more.
This tutorial will teach you how to easily update a (.smd) model with new material names, and/or model export locations. It will also help and work for Mappers who've never compiled a model before, and are looking to do so without frustration.
Posted by nintentofu on May 19th, 2009
Intermediate Props Modelling.
It will also help and work for Mappers who've never compiled a model before, and are looking to do so without frustration.
This tutorial can assist ..
Q?
A!
This means you CANNOT rename a model, material file, or move a model/material file from its intended folder location, without errors occuring.
This can lead to some issues for mappers particularly, when trying to use custom models and content within a map.
For instance, Let's say a mapper finds a prop/model they'd like to use in their map; but it's already compiled to replace original game content, such as the rocket for Team Fortress 2. Normally if they just installed the custom model's 'materials' and 'models' folders and brought the prop into Hammer World Editor, they could use the model however they like, but it will also still be replacing the default rocket model because it was originally compiled with the model name and sometimes material names to do so.
But if he/she wants to use that model in a map as just a static prop, etc, WITHOUT wanting the custom prop to still replace default content, then it's impossible to do so without physically recompiling the model.
STEP ONE - DOWNLOAD
It will decompile model .mdl files into a workable set of files that we can recompile.
It will allow us to open the model .smd file into a text editor, to easily adjust file names.
For this tutorial, you will need (2) programs.
STEP TWO - INSTALL
Unzip the downloaded file and move the file within named "mdldecompiler.exe" into the following SDK Bin folder,
Because this program uses the HL2 .dll files, the file "mdldecompiler.exe" MUST be in the proper directory to work.
Next, try launching the program and see if it opens correctly. If so, close the program for now. If the program doesn't launch correctly, it it's either not in the right folder, or if you are missing MFC71.DLL check the linkbelow.
If needed, more info can be found at the Program's Home Page.
After it is done installing, it's recommended that you Restart your computer at this point just to be safe. It will then be a lot easier for us to use the NotePad++ file editing features.
STEP THREE - DECOMPILE
First we need something to decompile.
After you've downloaded the replacement model, unzip it somewhere you can relocate it (Preferably your desktop). Open the unzipped folder and inside create a new folder named decom for decompile. We will be decompiling the model into this folder, so we can make adjustments then recompile.
NOTENormally at this point, we would be able to decompile our model files by just launching the Decompiler, and choosing the correct locations. But since we are currently working on a TF2 model, we will have to make (1) mini adjustment to the model file using NotePad++. Otherwise, the Decompiler will not open the file.
Remember, this is only necessary when decompiling HL2:EP2 / TF2 models.
So, lets go to our downloaded "Koopa Shell Stickies" unzipped folder, and open up the tf \models \weapons \w_models\ folder where we will find our Sticky Bomb replacement models.
Right-Click the file "w_stickybomb.mdl" and we should see "Edit with NotePad++" on your drop-down. Click "Edit with NotePad++.
Once the .smd file is opened in NotePad++, you should see the first five characters as,
IDST0
We need to change this to
IDST,
So replace the 0 with a comma , and we're good to go. Click File, Save. And we're ready to decompile.
Then Click the ... to the Right of "Choose Output Directory" field, and go to the choose the "decom" folder that you created in the unzipped Koopa Stickies directory.
Make sure all the Check-Boxes below are NOT checked, then click the "Extract" button.
Now that we've fixed the .mdl file for decompiling, Launch CannonFodder's Model Decompiler.
If everything works, you should get a "Loaded Model.." alert-window, then a "Completed Dumping Model!" alert-window.
We should now have a set of extracted files within the "decom" folder.
STEP FOUR - ADJUST MATERIAL & MODEL NAMES + LOCATIONS
In the following steps, we will be able to choose and rename our wanted final material & model file names + directory locations of choice.
NOTEWhen a .SMD file is created from a 3D Modeling Program, the exported file will contain Material File Name(s) for each UV Mapped surface of every Poly within the model.
We will use NotePad++ to easily change this material name without having to use a 3D Modeling Program.

*Level of Detail models are used in-game to help minimize poly counts. The LOD model changes depending on how far the player is away from the model. This info is included here because many models usually contain LOD models as well.
So for this tutorial, we should have adjusted the following .smd files, in order for our new compile to properly work.
When finished adjusting texture filenames, Save, then close NotePad++.
From inside the "decom" folder, you should have a file named "mdldecompiler.qc". Open this up in Notepad by Right-Clicking the file and Choose, 'Open With' from the drop-down. Then choose Notepad. You can also edit this file in NotePad++ if you like, but usually I prefer Windows Notepad for .qc file editing.
Inside the file you will see all the settings that were originally used to compile the model. We will only be adjusting the highlighted ones below.
Here, you should see the material name "w_stickybomb_red.bmp" starting from about the 10th line, and every other fourth line or so. Select the whole first line that has this material name by clicking and dragging over the filename, then continue below.
Next, for this tutorial we will be renaming EVERY "w_stickybomb_red.bmp" to "koopa_shell.tga" by clicking Search, Replace, from the Top-Menu. Or press ( Control + H ) for the hot key.

If highlighting the filename w_stickybomb_red.bmp before clicking Replace, we should see that "phrase" in our current "Find What" text-box field.
If not, simply write it in.
Find What = w_stickybomb_red.bmp
Underneath that in the "Replace With" text-box, we can choose a new texture name that we'd like to recompile our model to. For this tutorial it will be "koopa_shell.tga".
Replace with = koopa_shell.tga
When filled in, click "Replace All"
Next, since we are recompiling a model that has Level of Detail (LOD) models* included, we will need to open up each LOD .smd model in NotePad++ and do the same to each. Replace each texture filename for each .smd model. Note that animation .smd files do not contain texture filenames, so you don't have to worry about editing them. Also the Physics .smd file doesn't need to be adjusted.
We now have our material filenames fixed, so our final step before compiling is to quickly adjust our .QC text file.
Since we do not want the model to replace any default content, we need to change at least the model name. But it's important to keep models organized so we always want to change the folder path as well.
So, change this line to..
$modelname "my_props\nintendo\koopa_shell.mdl"
$mass 5.0
$inertia 1.00
$damping 0.00
$rotdamping 0.00
}
"mdldecompiler.qc"
It's also important to know that during the compile, this command will not create any folders or files, it will only compile the model with information on where to find it's materials.
So, change this line to..
$cdmaterials "\models\my_props\nintendo\"
Note- These file names must be exact to what our new Material file names will be.
So, change this line to..
{ "koopa_shell.vmt" }
{ "koopa_shell_blue.vmt" }
If you like, change the lines to
// Model uses material "koopa_shell.vmt"
// Model uses material "koopa_shell_blue.vmt"
STEP FIVE - COMPILE
This is important because the compile tool will automatically compile to our selected "Source SDK" engine and game.
If you are following this tutorial without ever using the Source SDK tools, you will need to first install it before we can compile. To Install the Source SDK, Launch Steam, Login, Click the "Tools" tab, then double-click "Source SDK". This will install the tools needed to map, and compile. It also has a Model Viewer that we can use to view our finished model.
Open a new Windows Explorer (Keyboard Shortcut = Windows Start Button + E") and go to your Steam directory, usually in C:\Program Files\Steam. Then we need to go to "\steamapps\YOUR_STEAM_ID\sourcesdk\bin\ep1\bin\" folder. Inside this folder you should see a file named "studiomdl.exe".
STEP SIX - FINISH UP
So for the "koopa_shell.vmt" file, we must update the commands to,
And for the "koopa_shell_blue.vmt" file, we must update the commands to,
The last thing you will need to do is manually rename and place the original downloaded Material (.vtf) files and corresponding .vmt files to the location we chose for our new model. In this case, the files need to be placed into the following directory..
Then, the following files,
Should be renamed to..
Last, we need to open each .vmt file and adjust the following highlighted lines,
"koopa_shell.vmt"
The $basetexture command must be updated to match the correct folder location of the texture file, and also must have the corresponding name of its matching .vtf file. Though you do not need to use a .vtf extension.
The $bumbmap command must also be updated to match the correct folder location of the texture file, and also must have the corresponding name of its matching "normal" .vtf file. More information on Bump Maps can be found here.
Finally after all the above steps have been completed, you should now have a new model file that you can import into Hammer that won't replace a default prop model or texture.
To check out your new compile, Launch Source SDK, then the Model Viewer. Go to File, Load Model, and go to Models, My Props, Nintendo, then you should see a "koopa_shell.mdl" file. Open it, and hopefully you will see the working textures!
That is the end of this tutorial. I will be updating this as time goes by, with more cross-linking and perhaps more detailed information on certain steps. If there is anything you see that I can or should work on, please let me know.
If there are any problems with this tutorial, as in broken links, etc. Please feel free to contact me and I will gladly make updates.
I don't know about broken links, but the presentation is all over the place. Lists aren't useful here: go with headings instead.
Very nice thanks for that.