[TUTORIAL] Complete Guide to Adding Custom Objects to your TF2 Map

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Complete Guide to Adding Custom Objects to your TF2 Map

Is there something you want that you can't find among Team Fortress 2's included objects? Are you eager to put your own custom objects and textures into your latest map? Well, if you're like me , you realize now that the process of getting a custom model into a Source map is not automated or even convenient. In fact, this may be the fourth or fifth tutorial you've looked at, because most tutorials on importing objects (including Valve's own documentation) have various holes and sometimes unclear information.

The purpose of this tutorial is to make as complete a guide as possible to the process of getting a custom object into a Team Fortress 2 map. The same process will work for other games like Half Life 2 and Counterstrike, but it's about time you got a TF2-specific tutorial on this subject. And I want to help you skip the headaches I went through. Follow me as we go through the process.

Note: Thanks to 3DRyan for clarifications and corrections on a few points of this tutorial.
 
Last edited:

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Planning

So you've found something that your Team Fortress 2 map is desperately missing... Well, with a little know-how, it's possible for you to create that object. But the first thing you must know about that object will be its size and proportions. For this tutorial I'm going to walk you through the creation of a couch for my map cp_corporation.

If I want to put a couch into a map, I need to know what size to build it it. There are a few ways to do this:

- Knowing the exact measurements and making direct conversions
According to Valve's wiki, in Hammer, 16 units equal 1 foot. Unfortunately, using this conversion, making an object strictly by the numbers would make your object out of proportion... because if we follow that ratio, the Heavy Weapons Guy is 5'9". That doesn't sound right! Apparently TF2 uses a slightly different scale than Half Life 2 does. It's more like 15 Hammer units equal 1 foot. You could use this approximation to plan the size of the object, since one unit in Hammer equals one unit in XSI, Maya, and 3dsMax. Or you could use one of the following methods to be safe.

- Exporting a piece of your map and building the object right there on it.
Softimage XSI Mod Tool, which you'll become familiar with later in the tutorial, can import .VMF files. If you select pieces of your map (like a hallway, table, or building) and you export them as a .VMF file from Hammer, Mod Tool can import it. From there, Mod Tool can make it compatible with your favorite 3D package by converting it to an .OBJ file. Now you can build the object right there admidst your own map geometry (though it will have no textures). This method is a bit cumbersome because of its several steps. It also doesn't give you a direct comparison to the size of players.

- Making a quick mockup in Hammer.
This is my favorite method and the one I use most. Directly in your map you can build a simple version of your object out of brushes. You can even put in a player model to compare the size. This lets you visually size things up and get the right proportions.

mockup.jpg


After that, you can select each brush to look at its dimensions and make a quick drawing that lists the dimensions of the object.

diag.jpg


Use the dimensions in your sketch to build a rough model in your 3D package of choice that will eventually become your final model.
 
Last edited:

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Building

You can build your object in virtually any 3D package that will properly export an .OBJ file with UV maps intact. I choose Maya because it's what I know, but the choice is yours. If you know how to build and texture an object in XSI or XSI Mod Tool, you can save yourself a step because your model will end up in that package anyway.

While building your model, I think it's important to suggest that you try to keep your model and texture in the Team Fortress 2 style. Nobody likes an object that looks like it doesn't belong.

Here are the different versions of my couch that I modeled.

3couch.jpg


You can see I made three different versions.
1. The first is the full-resolution model. It has more polygons, beveled edges (rounded corners), and is made to look nice up-close.
2. The second is a low-res version of the model. This is what will show up when the player is far away from the object. This doesn't have beveled edges and has a lot fewer polygons. A low-res version of your model is not necessary, but it's good to have, and it's not hard to make. It's as easy as keeping a version of your model from before all the smoothing and beveling.
3. Third is The collision model. This model sets up the clipping for players. It also isn't absolutely necessary, but realize that any object you don't make a collision model for will not be solid in the game (unless you build clipping brushes for it). I recommend that you make a collision model. It will save you time in the long run. See my special section for collision models later in the tutorial.

Here are some special things to keep in mind as you create your objects:

- Make them all occupy the same space. They can't be sitting next to each other with different origin points. In my 3D package I can set them up to be in different layers that can be turned on and off.
- They must have the same origin point. In fact, if you can, make sure that origin point is floor-level, so when you place the object it's sitting neatly on the floor.
- All models must have UV maps. Yes, even the collision model. The collision model doesn't need to be nicely textured, or even have the right texture. It just needs to have a UV map.
- You may have more that two levels of detail for your model, but use your judgement. If the object doesn't have many polygons in the first place, then a lower level of detail is pointless. And you're eating up memory and processor power for no good reason if you include a lower-detail model that doesn't shave off many polygons.
- Make sure each seperate model is one complete merged object... except for the collision model. It should be in seperate pieces if more than one piece exists.

Export each of your models seperately as .OBJ files so that they can be opened up in Mod Tool (if you aren't in Mod Tool already).
 

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Texturing

Textures on the objects and brushes in a Source game use a special image format called .VTF. It probably stands for "Valve Texture File". You most likely made a .TGA or .TIF image for your texture, but whatever it was, it's going to need to be converted to a .VTF to be used in Team Fortress 2.

The Source SDK comes with a texture conversion tool called Vtex that is meant to turn your image file into the proper format, but I think tool is more trouble than it's worth. Instead, I use Nem's .VTF

Photoshop Plugin
, which immensely simplifies the process. For those who don't have Photoshop, I've heard that VTFedit is a very capable frontend that can do the trick and more.

tex.jpg


Here is the texture for my couch, albeit scaled down a bit to post in this tutorial. One thing most people know, but is important to note, is that all textures must be sized by square increments (for example: 256x256, 512x512, or 1024x1024). My original is 512x512. I also made a blue version of it in case I ever decide to put that couch on the blue side of the map. Models with multiple textures require some extra settings but we'll get to that later...

With my texture open in Photoshop, I choose "Save As..." and in the file format field I choose .VTF way down at the bottom. Give it a name and tell it to save, and it will open up the VTF Options.

vtfopt.jpg


There are actually a lot of different formats within the .VTF filetype. You can select these formats from the Format dropdown menu. BGRA888 is listed as a common format, and does not compress your texture. However, an uncompressed texture takes up a lot of space, especially if your image is large. On the other hand, DXT1 (also a common format) will compress your textures down to a MUCH more manageable size. And you know what? In-game I can't even tell the difference. I highly recommend DXT1.

If you're including an Alpha channel in your image to create transparency or areas that are self-illuminated (like a TV screen), you'll have to choose a format that allows an alpha channel. For compressed textures, DXT5 works, and for uncompressed you can use BGRA8888.

tex_spec.jpg


This is the Specular map for my couch. Specular maps in a Source game work just like they do in most 3D software packages. It's just a grayscale image with white representing reflectiveness and black representing matte. On my map you can see I made the couch's fabric unreflective, but the wood part is glossy. This image file must also be a .VTF and is subject to all the same rules as your main texture file.
NOTE: If your object has a normal map (like the one below), its alpha channel can be used to store the specular map. I think the Source Engine actually prefers this. Also, it requires a specific line of code that will be explained later in the Material Shader section.

tex_norm.jpg


Last of all, here's my normal map. I'm posting it at actual size so you can see the details. This will give my couch a sense of texture and bumpiness when viewed in the game. A normal map is easy to make if you use Nvidia's Normal Map plugin. It's as simple as creating a grayscale bumpmap file like you would for most 3D software packages, and use Nvidia's Photoshop plugin on it. Make sure that when you're using the plugin on a grayscale image, you have it work from "Average RGB" rather than "Alpha Channel" (unless of course you actually did use the Alpha Channel for your height information). As with the other images, this too must be a .VTF file. However, when you reach the VTF Options box while saving, make sure you check the "Normal Map" box.

NOTE: both the specular map and normal map are unnecessary, so you may leave them out if you don't need that extra level of shine and detail.

All of your texture image files should be placed in your SourceSDK_content folder. You should make a new folder for the textures of your model within the "materialsrc" folder of the "tf" folder, so the path looks similar to this:

C:\Program Files\Steam\steamapps\Yoursteamname\sourcesdk_content\tf\materialsrc\Yourmodelname\*.vtf
 
Last edited:

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Your Object's Material Shader

Once you have all the images made to texture and shade your object, you must write a shader for them. The Source engine gets your shader from a text file you create, and it's not very evident what your shader will look like until you're in the game, so it may take you some trial and error to get what you want. Here is the shader file for my couch:

---------------------------------------------
"VertexLitGeneric"
{
"$basetexture" "officecouch/officecouch"
"$model" 1
"$surfaceprop" "carpet"
"$envmap" "env_cubemap"
"$envmapmask" "officecouch/officecouch_spec"
"$envmaptint" "[0.5 0.5 0.5]"
"$envmapcontrast" .5
"$bumpmap" "officecouch/officecouch_normal"

}
---------------------------------------------


Now, let me explain each line so that you'll know what it's for and how you change it:

"VertexLitGeneric" - This is the lighting model Source uses for lighting objects. If you're making a material for an object (and you are) then this is what you must use.

"$basetexture" "directory/texturefile" - Here you place the path to your base texture file. Source already assumes you're in tf\materials directory, so you'll want to just list the subdirectory for your object's textures, followed by the name of the texture itself. Mine is pointing to tf\materials\officecouch\officecouch.vtf. HOWEVER, you must leave off the .VTF extension, since Source assumes it will be looking for a .VTF file. If you leave the extension on, it will look for texture.vtf.vtf, and of course it won't find it.

"$model" 1 - Tells Source that this texture is for an object, not a brush.

"$surfaceprop" "________" - This gives your entire model surface property which dictates how it sounds when stepped on, or what happens when it's shot. You can find a big list of different surface properties for your model right here, including things like metal and wood. I chose "carpet" so that the couch kicks up dust when shot.

"$envmap" "env_cubemap" - Tells source to use a nearby cubemap for the object's reflection. You use this line if your specular map is a separate file, and not the alpha layer of your normal map.

"$envmapmask" "directory/specular_texture" - sets the path to your specular map file. Use the same rules as you did for your base texture.

"$envmaptint" "[0.5 0.5 0.5]"
"$envmapcontrast" .5
- These two settings adjust the crispness of the shine on your object. Each number must be from 0 to 1, and you'll probably have to adjust them to get the look you want. In $envmaptint the three numbers are in RGB format, and rasing the green number would make the reflection appear more green, for example. Under most circumstances, you should make the three numbers equal.

"$bumpmap" "directory/normalmap" - designates the path to your normal map. It also uses the same rules as you did with your base texture. Remember to leave off the .VTF extension!

"$normalmapalphaenvmapmask" 1 - if you have both a normal map and a specular map on your model, this line designates that your specular map is the alpha layer of your normal map file. Use this line if that's what you did with your specular map.

You got all that? Save this file in the same directory as your texture files. It will be a .VMT file, and for the sake of organization, give it the same name as your object. So my file is called "officecouch.vmt" and it's in the \sourcesdk_content\tf\materialsrc\officecouch\ directory along with all my .VTF files. When you compile your model, your model files and material files will end up copied into your main Team Fortress 2 directory under \materials and \models. It's useful to note that even after your model is compiled, you can adjust the material settings in the Team Fortress 2\tf\materials directory without having to recompile anything.

Note - If you want your object to have multiple skins, like how I want to have a blue version of my couch, you must make a new .VMT file for the new skin. In this new file, the $basetexture line would point to a different texture file.

Also, just for the sake of reference, here is an example of a bare-bones .VMT file, in case you're doing a material that has no specularity or normal map. This is just the required stuff:

---------------------------------------------
"VertexLitGeneric"
{
"$basetexture" "officecouch/officecouch"
"$model" 1
"$surfaceprop" "carpet"
}
---------------------------------------------


If you've finished all of this, you're ready to move on to the conversion process for your model.
 
Last edited:

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Mod Tool

Softimage|XSI 6 Mod Tool is a crippled and buggy version of the popular 3D package Softimage. Mod tool can't do everything the full package can, but it's free and comes with tools made especially for Source Engine mods and assets.

Import your object models into Mod Tool by selecting File > Import > Obj File. You may import them all into the same scene if you like. This will actually make it easier to handle the textures and materials.*

inmodtool.jpg


If you want to change your view in the 3D viewport, move your mouse to that viewport, then hold the S button. While holding S, the left mouse button pans, the middle mouse button zooms, and the right mouse button rotates your view. You can turn on textures or shading by clicking on "Wireframe" in the upper-righthand corner of the viewport and changing it to your desired setting (like "Textured", for instance)

When you import an object into Mod Tool, the odds are good that the material settings you imported with it are not compatible with Mod Tool. If so, the object will show up black when you're in Textured mode. This was the case for me, coming from Maya. These broken materials mess up the compile process, so here is how to fix them:
1. Open up the Materials Manager by choosing View > Rendering/Texturing > Material Manager.

matman1.jpg


2. See those apples? Those are your materials. Click on and then delete any apple that isn't Scene_Material.

matman2.jpg


3. Now, in the top menu of the Material Manager, select Create > Lambert. It should create a new material for you. Double click it. This will open up your new material dialog box. Down near the bottom you'll see the "Diffuse" settings, with some color sliders and a little plug-in icon next to it. Click on that icon. A little menu will emerge and you should select "Image".

matman3.jpg


4. A new Image dialog box will pop up. In the "Image" field, choose "New" and select "New from file..." from the menu that pops up. Navigate your way to your texture (the .VTF file). Upon choosing it, you should see your texture appear in the Image dialog box. You may close the Image dialog box now.

5. That little apple in the Material Manager should now have your texture on it. Select your model, then right-click on the lambert material with your texture and choose "Assign to selection".
 

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
With your 3D view is in "Textured" mode, you should see the texture on your model. If it's too dark to tell, open up that little menu in the upper-righthand corner of your 3D window and choose "Headlight". That will light things up a bit. If your model's texture is distorted or not showing up, it's possible you messed up along the way or you didn't export an OBJ correctly.

inmodtool2.jpg



*If you import your main model, your low-res model, and your collision model into the same scene, you can delete all of their broken materials and assign them all the same fixed material, thus saving you time. Just make sure you can keep track of the different models, as they should all be in the same exact location. Also, you must be sure to export them from Mod Tool seperately.

If you know the texture is showing up correctly, it's time to export! Select your main full-res model, then in the top menu select ValveSource > Export SMD...

Navigate to your SourceSDK_content folder. You should make a new folder for your model within the "modelsrc" folder of the "tf" folder, so the path looks similar to this:

C:\Program Files\Steam\steamapps\Yoursteamname\sourcesdk_content\tf\modelsrc\Yourmodelname\model.smd

Export all of your models to that directory. I used this naming convention for my couch:
officecouch_1.smd - Full-res model
officecouch_2.smd - low-res model
officecouch_c.smd - collision model

Naturally, how you want to do your naming is your business. Go through the process and export your low-res model too, as well as any additional level-of-detail models. But stop once you get to the collision model. It's special.
 

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Collision Model

The collision model must be handled a bit differently than the other models. Not only does it designate how the player bumps into it, but also how it collides with other objects and the floor if it's a dynamic object. It also tells the game what parts block bullets and grenades, so it's important.

First of all, it should be very low-res. Make it have as little detail as you can manage... just the basics.

Second of all, it can only be made of convex shapes, just like brushes in Hammer. This means that there can't be holes or indentations. Cubes and cylinders are good examples of convex objects. This presents a challenge when you're making a model like my couch. After all, it has that bucket shape that allows players to sit down in it (if a TF2 player could sit). Your collision model can be made out of separate shapes to achieve the collision you want, as long as they are separate objects and each object is convex.

coll1.jpg

Here is my couch's collision. Notice how simplified it is. Also, it is made up of four seperate objects, all of them convex, with UV maps, and a material assigned to them.

When you compile your object, the collision model can end up in three different situations:
a) It works. The collision happens right where you want it to.
b) It doesn't work. An error happens and there is NO collision. Players walk through the object.
c) It decides that your model is not convex and creates a new shell around it. This shell is like a shrink-wrap that cuts off concave areas. The the case of my couch, it would make it so you can't sit down in it.

Your collision model may be simple and only require a cube. Or, that shrink-wrapped shell may be perfectly fine for your collision. If your collision model is one convex object, then just skip to the next section. But I'm going to show you how to make the proper collision work. Here are some examples on what happens with different settings:

cm_wonk.jpg

This is an example of a collision model made of one big concave shape. This is a bad example. It will result in an error when you compile (more on compiling later) and an improvised shrink-wrapped shell. Look closely at the couch with the red lines around it. Those red lines are showing the collision model. See that line stretching across the front of the couch like that? That means if a player jumps on top of the couch, they'll hover eerily above the couch rather than standing on top of the cushions.

cm_work.jpg

Here's the right way to do it. See how I have four different convex shapes? When you look at the computed collision model with the red lines, you can see that there is an open cavity through which players can fall into the couch.
 
Last edited:

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Properly exporting your collision model:

If your collision model consists of multiple ojbects, there's one more step you need before you export them from Mod Tool. Let's assume you've imported your collision model into Mod Tool, and you fixed its material. Once again, you don't need the UV map or texture to look good on the collision model, they simply must exist. NOW, you need to make sure each object has its own smoothing group.

What's a smoothing group? Well, when your computer shows a 3D object, it makes the shading on polygons blend together if the polygons are in the same smoothing group. Polygons that meet together but are in different smoothing groups look like a sharp corner. Mod Tool doesn't have smoothing groups. At least it doesn't call them that. But you can designate them so that your collision model works. I don't know how smoothing groups relate to objects that will become collision, but Valve has decided to make it a factor for some reason.

In Mod Tool they call it "Geometry Approximation". Select one of the objects. Then, find "Selection" in the upper-right side of the screen, somewhere underneath the big arrow. Click on it and choose "Geometry Approximation". Mod Tool will ask you if you want to make a local copy. Just say no.

geom.jpg

(if you don't see the same menu in my screenshot with the arrow, from the top menu select View > Layouts > Default.)

You should get a new settings box that pops up.

geom2.jpg


Choose the "Polygon Mesh" tab and uncheck Automatic, under Discontinuity. Do this for each object in your collision model.

You're ready to export your collision model now. Select all of the pieces by dragging a box around the enter scene, or shift-clicking each piece. From the top menu choose ValveSource > Export SMD... Export it to the same directory as your other models.
 

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Compiling

If you've followed all the steps so far, you should have a directory with at least a few .SMD files. There's your main model file, and your collision model, as well as any additional models for levels of detail if you made them. I ended up with three models total. A high-res, a low-res, and a collision model.

One last thing your model needs is a .QC file, which is a text file that designates how the compiler should put your model together.

Here's a plain and basic version of the .QC file for my couch:

Code:
/*
----------------
Officecouch QC
----------------
*/

 officecouch.mdl
 0 0 0 90
 1.0
 "Body" "officecouch_1.smd"

 "carpet"
 Z
 "officecouch/"

 "idle" "officecouch_1.smd" fps 30

 "officecouch_c2.smd"
{
    //Mass in kilograms
     20.0
    
}

That's just the bare necessities for a QC file. I'll show you some extras you can put in later.

Now, here's a rundown of what each line does, so you know what to change:
The first five lines are just a header to make it look nice, pretty much. It has no bearing on the actual object.
$modelname _________.mdl - this is the official name of your model.
$origin 0 0 0 90
$scale 1.0
- these two lines would allow you to change the size and origin point of the model, but you should do that on your own in your 3D pacakage beforehand.
$body "Body" "___________.smd" - In this line you designate the .SMD file that is your main, full-res model.
$staticprop - your object is a static prop. I'm sure if you're making a dynamic prop this line would be different.
$surfaceprop "_______" - as we did back when we made a material for the object, this lets you designate what the object is made out of. What does it sound like when you walk on it? What do the bullet holes look like? I don't know why we have to set this option in both places (or if we really even have to), but it's easy enough to do. Once again, here is that list of different surface properties you can have. You should see my couch getting shot with the "carpet" property. It's great.
$upaxis ___ - Important! Different 3D software packages choose different things for the "up" axis. 3dsMAX, Maya, XSI, and Mod Tool all use Z to denote height. HOWEVER, Hammer uses Y. What that means is if you don't correct it, your models will come in sideways. If you set the up axis to Z here, it will correct the model for you automatically when it's compiled.
$cdmaterials "__________" - This tells it where your objects materials are located (The .VTF and .VMT files). It assumes you're starting in the \materials directory, so since we're putting textures in their own subdirectory under the model name, your path will be "YourModelName/".
$sequence "idle" "___________.smd" fps 30 - If your model were to animate, this is where you would indicate an animated .SMD file. You'd even be able to designate several animation sequences besides "idle" if you wanted. But if your object doesn't animate, you just need the idle animtaion. You can get that from the main fell-res .SMD that you've entered previously. No animation required.

$collisionmodel "___________.smd" - as you may guess, you indicate the collision model in this line. But what follows in the braces is an estimation of the object's weight (in kilograms). I don't know what a couch weighs, so I just guessed 20. Metric weight units are both convenient and scary. $concave means that the collision model is made up of multiple
objects, so the compiler shouldn't just put one shrink-wrapped shell around the collision model.


That's it! That will give you the ability to compile a basic model. But wait, there are a few features you can add if they apply to your object.

What about level-of-detail models?
If you have a low-res model of your object like the one I made for my couch, you add this little section to your file:
Code:
 50
{
     replacemodel "officecouch_1" "officecouch_2"
}

Remember, officecouch_1 was my full-res model and officecouch_2 was my low-res model.
You can also set multiple levels of detail if you have multiple LOD models:

Code:
 66
{
     replacemodel "officecouch_1" "officecouch_2"
}
 33
{
     replacemodel "officecouch_1" "officecouch_3"
}


And also, what if your model has multiple textures, like a different color set?
When I want to add the blue version of my couch, I add a section immediately after the $body line:
Code:
 "Body" "officecouch_1.smd"
 skinfamilies
{
	{ "officecouch" }
	{ "officecouch_b" }
}

This sets up two skin families. The first is my default material, officecouch.vmt. The second is the blue version, officecouch_b.vmt

So for reference, here is the .QC file for my couch, with all the extras added:
Code:
/*
----------------
Officecouch QC
----------------
*/

 officecouch.mdl
 0 0 0 90
 1.0
 "Body" "officecouch_1.smd"
 skinfamilies
{
	{ "officecouch" }
	{ "officecouch_b" }
}

 "carpet"
 Z
 "officecouch/"

 "idle" "officecouch_1.smd" fps 30

 50
{
     replacemodel "officecouch_1" "officecouch_2"
}

 "officecouch_c2.smd"
{
    //Mass in kilograms
     20.0
    
}

Are you ready to compile?

Valve created a utility called studiomdl.exe that is run via commandline parameters. It's in the source_sdk\bin\oragebox\bin direcotry. If you don't have a guide or any kind of help for this utility, it can become a very frustrating kink in the pipeline. There are alternatives that create a frontend, but the ones I've tried are pre-OrangeBox and don't seem to work properly. I've worked out a system of creating a .BAT file to compile my models and it removes a great deal of the hassle.

In the direcorty with my .SMD files I create a batch file called "officecouch_compile.bat" that looks like this:

cd c:\Program Files\Steam\steamapps\YourSteamName\sourcesdk\bin\orangebox\bin\
studiomdl.exe -nop4 -game "c:\Program Files\Steam\steamapps\YourSteamName\team fortress 2\tf" "c:\Program Files\Steam\steamapps\YourSteamName\sourcesdk_content\tf\modelsrc\officecouch\officecouch.qc"
pause



See how that works?

The first line switches to the directory where studiomdl.exe is stored.

The second line executes it with these parameters:
-nop4 - disables functions that make Studiomdl think you're using Valve's asset-sharing network.
-game path - sets the path to your Team Fortress 2 directory where the game info is stored.
path - sets the path to the .QC file for your model
Remember, for those paths, you need to change the paths to reflect how the directories are set up on your machine. That "YourSteamName" will actually be your Steam login ID. And of course you won't put "officecouch" or "officecouch.qc" in your batch file, but change those to your new object and its directory.

The thrid line is just "pause". This keeps the DOS window from shutting down before you can look at the results of your compile.

Now, you can simply execute that batch file any time you want to recompile your model. It sure beats opening up a DOS window and typing all the crap over and over again.

EXECUTE IT! Compile your model! If you have all your files ready and in the correct directories, and if the paths are all correct, Studiomdl will begin to compile your model... and it shouldn't take long. When it's finished, you should be able to look through your compile log and check for any errors. If it worked, you'll be able to find your model files in the Team Fotress 2\tf\models directory.

Here's what files my couch resulted in:
officecouch.mdl
officecouch.phy
officecouch.vvd
officecouch.dx80.vtx
officecouch.dx90.vtx
officecouch.sw.vtx


You'll need to copy your material files over from your SourceSDK_content folder to your Team Fortress 2 folder. Put all those .VTF and .VMT folders in the Team Fortress 2\tf\Materials\Yourmodel\ directory.

Now, did your model work? There's one very convenient way to find out...
 
Last edited:

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Testing and Checking

Within the source_sdk\bin\oragebox\bin directory is a useful tool called hlmv.exe, or the "Half Life Model Viewer". Use this to load the .MDL of your object that was just created when you compiled. I just like to execute my .mdl file, and when Windows asks me what program to open it with, I navigate to hlmv.exe and have it ALWAYS open my .mdl files.

mdl.jpg


Looks like my couch worked! But hold on... What does the collision model look like? Under the Render tab, on the right, you'll see a checkbox for "Physics Model". Check it.

mdl2.jpg


Success! Those red lines are the collision model and they seem to work. Uncheck "Physics Model" now that we've seen it. So, does my extra Blue skin work? Click on the Model Tab. You'll see "Skin 1". If I change it to "Skin 2" I get this:

mdl3.jpg


Also a success. Last of all, does the lower-res model work? Also in the Model Tab, you'll see a box for "Auto LOD". Make sure it's unchecked, and change the "0" in the dropdown box to "1".

mdl4.jpg


It worked! Of course, if you didn't make any extra levels of detail, or if you made several, there will be a different amount of options to check out.


Now, A little troubleshooting for this stage:

My model isn't there! - it may not be in view. Try clicking in the view window and dragging with the left mouse button. This will swivel your view. Also try clicking and dragging with the right mouse button to zoom in and out.
My model has purple/black checkerboards on it! - your textures or .VMT file are not in the correct path. Recheck your paths based an what I've instructed you earlier. Wunderboy has create a great utlitiy called Source MDL Texture info that you can use on your .MDL file to have it show you the texture information. It will tell you where the model is expecting to find the textures.
My physics model is just a shrinkwrapped shell around my model! - there was a problem with your collision model. It probably had one or more concave parts to it. See the collision model section of this tutorial.
My physics model doesn't exist! - there was some other sort of problem with your collision model. It's possible that one or more of its shapes weren't enclosed, or other problems.
My model is sideways! - You didn't set the correct "up" axis in your .QC file. Go back and see the .QC section (in Compiling).

Buuuuuuuut.... if everything worked, you should feel very special. You now have an object that no other map has. Your map has something custom and all its own. And it sets your map apart from all those other maps that just get by with what Valve gave them. Feel good about yourself.

Now, let's put it in your map!

Open up Hammer and get your map open. You should hopefully already know how to place a static prop in your map. Once you've placed that red cube, double click on it and open up your model browser. You should be able to simply type in the name of your object and find it. And if the object looked right in in hlmv.exe, it should look right here. If the object isn't there at all, then either you don't have the model in the proper directory, or you haven't restarted Hammer since the model was put there. But if it shows up, place it where you want it and feel free to compile the level and test it out. Jump all over the object and enjoy it. You've earned it.
 
Last edited:

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
ingame.jpg


Embedding and Distribution
- I'll fill this last one out after a good night's rest when I'm not completely tired. It'll talk about how to embed your new object and textures into your map file with Pakrat for distribution. This will finish off the tutorial.



I want to make this tutorial as complete as possible, so I'm open to questions, complaints, and suggestions. If anything is unclear, please ask me about it.

Is this tutorial too long for a message board? I'm new at this, so let me know if I should change anything.
 

Snipergen

L13: Stunning Member
Nov 16, 2007
1,051
150
Incredible hawk. However, could you explain how the collision model works, since I only see a slight difference between the bad and the good collision model, and for some reason my collision models only work sometimes What are the rules for a perfect collision model?
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
Grand tutorial, now all we need is a guide to making the model itself :)
 

Rock

L2: Junior Member
Jan 18, 2008
51
5
Very well done tutorial. Seems like a lot of work for those extra props but I guess that's what makes the difference between a good map and a great map. ;)

Atomic-Rock-sig.png
 

Dox

L8: Fancy Shmancy Member
Oct 26, 2007
588
62
Dont bother adding in extra xsi tutorials, the guys at Iwannamap already made some great video tutorials for modeling with XSI.
But this was an amazing tutorial, hawk (another +1 :p ). It filled in alot of things for me that I didnt even realize I was doing wrong! Thanks!

http://i4.photobucket.com/albums/y111/ParadoxContemplation/evilpot.jpg
Omg I was going to unleash this to the general Public!!!
 
Last edited:

Deadeye2007

L2: Junior Member
Jan 6, 2008
52
0
From someone who has read pretty much every modelling guide out there for Source and STILL has yet to make a successful model, I thank you. Hopefully this will net me my first custom model and get me on the way to REALLY stellar custom mapping.

My modelling problems seem to be stemming from texturing and UV Mapping. The object itself I can make, but texturing (and properly completing the UV map in photoshop) are beyond me at this point.