This tutorial will teach you how to import a custom model into Half Life 2 as a static prop.
Posted by King_of_Moose on Aug 8th, 2008
This tutorial will take you through process of importing custom created models in Half Life 2 Death Match. This tutorial is assuming that you are using 3D Studio Max 9 and you are familiar with basic terms in relation to 3D models and textures. This tutorial is also written in terms of importing a prop called “mailbox,” and saving the files into a root folder called “custom models.” For your own prop you’re using while following along, simply replace “mailbox” with whatever prop you’re using, and “custom models” with whatever folder name you prefer. Just make sure that you remember which folder houses your custom materials. Lastly, this tutorial is written only for importing models as static props.
In order to import your models into Half Life 2, you need to have specific folders set up in specific locations. You need to have the SMD Exporter for 3D Studio Max 9, a tool called studiomdl.exe, another called VTFEdit, and lastly, while not mandatory, you will want another tool called hlmv.exe.
Half of the tools you need you already have on your computer, it’s just a matter of knowing where to find them. In windows explorer, navigate to the following location:
A note, the only real difference in the path for you will be where it says “marriden.” This will be replaced by whatever your username is that you sign into Steam with. In this folder find studiomdl.exe, right click and copy it, then paste a shortcut onto your desktop. While in this same folder, find hlmv.exe and paste a shortcut onto the desktop for this tool as well. Creating the shortcuts onto the desktop will enable you to drag and drop your files onto the icons and perform the necessary functions towards importing your models.
The next tool that we’re going to acquire is VTFEdit.exe, and unfortunately, this tool is not found within your program files, you’ll have to obtain it from the internet. You can find it simply performing a Google search for VTFEdit, but here’s the direct link:
Download and run the installer and you will be ready to import your model’s texture files.
The last tool you need is the SMD Exporter plugin that will work with 3D Studio Max 9. Again you could find this through another Google search, but here’s the direct link in which you can download the files:
While this plugin is actually only a beta, it works fine for the purposes of this tutorial. Download and extract the files to your desktop. Please note that the author of this plugin has created the tool for 3D Studio Max 9, 2008, and 2009. Once the files have been extracted, open the Max 9 & 2008 folder, then the 32-bit folder, then drag and drop the SMDExporter.dle file into your 3D Studio Max 9 plugins folder. If you do not know how to get to that folder, here’s the path:
Now that you have all the required tools to successfully import your models into Half Life 2 Death Match, it’s time to set up the required folders that will house your models textures, and the actual model files. Create a folder called “custom models” and a folder within that folder called “mailbox” in the following locations:
The first location is going to hold all your models texture files while the second will hold the model files.
Create a folder on your desktop called “mailbox.” Open the model you want to import into Half Life 2 Death Match with 3D Studio Max 9 and make sure that everything you want is visible in the scene and hide everything else. Also ensure that the textures for your model are applied. Go to File > Export and save your file as “mailbox”, selecting Source SMD for Save as type into the “mailbox” folder you created on your desktop. Press Save As and you will be presented with the following:
As you are creating a static prop for Half Life 2 Death Match, the only option you need to worry about having selected is Export Reference SMD. The other options are pretty self explanatory as to what they’re for, Export Sequence SMD is for any animation that you may have on your model but that’s unnecessary for the purpose of this tutorial. Press OK and you’ll see a screen informing you that your file has been created successfully. If you look in your “mailbox” folder on the desktop, you’ll notice that “mailbox.smd” is there and is the first official piece towards importing your model. After confirming that your .smd has been created, close 3D Studio Max 9.
In Windows Explorer, navigate to where you have your .tga texture file and drag it onto VTFEdit where you’ll be presented with the following screen:
There’s no need to adjust anything, simply press OK and move on to see your models texture appear in the right hand window. Go to File > Save As and save your file as “mailbox” in the following location:
Please recall that you should have created an appropriate folder for this specific file, thus the “mailbox” at the end of the path. This file you just created is a .vtf which is essentially the graphical part of your texture, the next step is to create the data file which will tell Half Life 2 Death Match what texture to use and what that texture’s material is supposed to be.
With your texture still opened in VTFEdit, click on Tools > Create VMT File to get the following menu:
As you can see, the .vtf that you just created is being used as Base Texture 1, if you have any Bump Maps or Normal Maps, you can add those to the file by clicking on the buttons with the “…” in them. Since there’s no Normal Map to include at this point, click on the Options tab at the top:
Change Shader: to VertexlitGeneric, Surface 1: to whatever material your texture is supposed to be made of, and uncheck the Translucent checkbox unless your texture file has some translucency to it. Click Create and save this .vmt file in the same folder as your .vtf file. Close VTFEdit. For a quick explanation of what your .vmt file is doing, right click on the file and open it with notepad to see the following:
“VertexlitGeneric” is the shader being used for the file. “$basetexture” is which .vtf file is being used in the texture. You’ll notice that next to it the path starts with “custom models,” Half Life 2 Death Match already knows where to look for your file up until the “custom models” folder. “$surfaceprop” is telling Half Life 2 Death Match what type of material your texture is, in this case, Metal. If you’re going to use VTFEdit then you really don’t need to know what all this text does, but if you ever plan to write your own .vmt files, this is good basic information to know. There’s more information on different attributes you can include in .vmt files on Valve’s Developer Wiki.
Open Notepad and immediately save the file as “mailbox.qc” in the “mailbox” folder you created on your desktop. Copy and paste the following into the Notepad file changing the bold font to fit your specific model:
As with the .vmt, here’s a rundown of what each command is doing. “$modelname” is defining which directory and file name to look for, very similar to the example in the .vmt file above. “$body “Body”” defines the base model. “$cdmaterials” tells Half Life 2 Death Match where to look for the models texture files, do not put the actual material name at the end of this path, just the folder otherwise it wont work properly. “$staticprop” is defining this prop as a static prop. “$scale 1.0” determines how large your prop is, a value of 1.0 will be how it was modeled while a value of 1.5 and 2.0 will be one and a half times and two times larger respectively. This allows you to change the size of your model without actually having to resize it in 3D Studio Max 9. Also note you can input any number you wish here. “$surfaceprop” defines what kind of material the" model is, put the same thing here that you put in your .vmt file. “$sequence “idle”” since this prop doesn’t have an animation, it will remain “idle”. Both the “idle” and “fps 30” can be changed if you’re creating a prop with animation. “$collisionmodel” defines the collision detection in Half Life 2 Death Match, without it, players and gun fire will simply pass through the model. “$concave” tells studiomdl.exe to assume that the collision model is concave. For more information on .qc files, refer to either the Valve Developer Wiki or The SnarkPit.
Open the “mailbox” folder located on your desktop, right click on “mailbox.smd” and choose Open With selecting Wordpad. Wordpad should come standard on all Windows programs but if you don’t see the option to open the file with that program, click on your Start button and select Run. Type Wordpad into the text box and press OK to open the program.
In Wordpad, select File > Open and browse to “mailbox.smd” to open the file. When it opens you’ll see it’s a very large file with lots of numbers, but you’ll also notice that your models original texture file, “mailbox_diffuse.tga” in this case is located every few lines in the file. Navigate to your textures .vmt file and copy the name of the file, including the file extension. In Wordpad select Edit > Replace. In the Find what: text box enter “mailbox_diffuse.tga,” and in the Replace with: text box paste “mailbox.vmt" and press Replace All; close the dialog box:
Save and close “mailbox.smd.” The last step in the process is to drag your .smd file onto Shortcut to studiomdl.exe that’s on your desktop. Make sure that you’re currently running Steam or the program wont work. When you drag the file onto the shortcut, you’ll see a DOS Prompt window appear and after a few seconds it will close. Check your “mailbox folder” in the following location:
You’ll notice that all sorts of files now populate this folder, including your .mdl file.
Now, the whole reason for having a shortcut to hlmv.exe that was mentioned at the beginning of the tutorial. Again, while not a mandatory tool, it makes the testing process faster as it will show you if everything was imported properly. To view your file, select File > Load Model and browse to “custom models” where you’ll find “mailbox.mdl.” Open this file and the model will appear in the window fully textured. If any texture files are missing you’ll notice a purple and black checker pattern on the model:
There you have it, you’ll notice that everything on this model is good except for the handle which is missing its texture. The reason for this is the way in which it was modeled, the handle was attached as a separate object and does not share any real estate with the mailboxes texture map. The convenient thing about this is it illustrates the point that if you’re missing a texture file for your model, that area will render with a black and purple checker pattern. You can bet that if it looks like this in hlmv.exe then it will look like this in Half Life 2 Death Match. When you’re satisfied, close hlmv.exe, it’s time to test the prop in-game.
Open Hammer, create a small room with an info_player_deathmatch and a prop_static entity. Open the Object Properties for the prop_static and adjust the World_Model parameter by clicking the Browse button:
As you can see, the MDL Files main folder contains all the sub-folders that house all the models in Half Life 2 Death Match, you’ll also notice the folder you created for your custom models. In order to browse to them faster, just select this folder instead of using the filter option to find your model. After you insert your model into the test level, add some lighting including light_spot entities to see how your model will react with in-game lighting. Once everything is set up, save and compile your map to make sure the collision model works:
Perhaps one of the best ways to ensure that your prop has proper collision detection is to use the crossbow and fire a few bolts into the model. If they are sticking into mid-air, then you need to adjust you collision model. However, the way that the .qc file was created, this shouldn’t be an issue. As you can see, your model should work perfectly, casting shadows and all.
This tutorial just covers the basics of importing custom created models into Half Life 2 Death Match. There’s still the matter of importing models as prop_dynamic and prop_physics entities, not to mention importing models as characters, weapons, etc… however this tutorial should have given you a good foundation on which you can build off of to achieve those types of imports.