Tutorial: Source Modelling Setup Last edited 2 months ago2024-09-20 03:24:39 UTC

You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date. Click here to see the current revision of this page.
This tutorial will take you step-by-step through setting up your computer to generate and compile models for use in HL2 maps. This is not a modelling tutorial - you won't learn how to create the model itself here. However, you will find out the things you must know to get a model into Hammer for HL2 mapping.

Getting Started

The first thing you need is the Source SDK. SDK stands for 'software development kit,' by the way.
  1. Start Steam
  2. Press the Play Games button
  3. Scroll down to the Tools section and press the Source SDK button
  4. Follow instructions and don't do anything while the files are downloading and installing.
Better yet, you could just click here.
Steam Games listSteam Games list
Once the SDK has been installed, you should have a desktop icon to launch the Source SDK programs, similar to your Steam launch icon. When you double-click the icon, a menu with several programs will pop up.
SDK LauncherSDK Launcher
You're going to need a modelling program that will export SMD (Source Model Description) files, at least reference SMDs. Preferably it will export reference, skeletal and physics box SMDs.

There are several available good modellers available for free (XSI EXP v4.2, Blender) and several other shareware and you-must-buy-it programs (3ds, Milkshape). Blender is good for basic modeling program. XSI is a very complete modeler and model animator. Milkshape appears similar to XSI. I've never used 3Ds. I think all the programs mentioned require some sort of addon to export (or import) SMD files.

Blender is available for download from blender.org. You'll need the SMD export addon which you can get from here. Copy the .py file and put it in the folder C:\Blender Foundation\Blender\.blenderscripts which should have been created when you installed Blender. More information about Blender and HL2 modeling can be found at the Valve wiki.

XSI EXP v4.2 is a very complete program available at softimage.com. If you interested in XSI:
  1. Download XSI EXP v4.2 from here or download from the official page if you don't mind the hassle of Fileplanet or Fileshack.
  2. Install XSI and run it. Before you do anything in XSI, click on File/Save in the menu to start the online registration window. Get your activation key form softimage (via email I believe). You have to register, but it's free and it's an excellent program.
  3. Activate XSI with your activation key.
  4. Download and install the ValveSource addon from the softimage downloads page mentioned above.
  5. Download and install the XSI documentation from the softimage downloads page mentioned above.
I think that XSI v4.2 is well worth the trouble to download and install. With the ValveSource addon, it can export all three types of SMD files you'll need to create for animated models.

Texturing

You'll need a basic graphics program for making textures. A okay editor aimed at gaming textures is Wally. You can download it here. GIMPshop is another good freeware image editor. You can also use Adobe Photoshop or other image editor.

Setup the VPROJECT environment variable

To make life very simple when compiling textures or models, the Source SDK software checks for an environment variable to place compiled files in the directory system. If you don't know what an environment variable is, it's ok. Just follow the instructions.
  1. Locate the "My Computer" icon on your computer.
  2. Right-click on the icon and select "Properties" from the menu.
  3. In the properties dialog, click the Advanced tab and press the Environment Variables button
  4. Under the System Variables table, click New
  5. Enter the Variable Name: VPROJECT
  6. Enter the Value: C:\Program Files\Valve\Steam\SteamApps\[your steam logon]\half-life\hl2
  7. Press OK buttons until you're back to your desktop
The Value entered for the VPROJECT variable above is the path to your Steam Halflife 2 folder. If yours differs, change the Value to suit.
System Variables dialogSystem Variables dialog
Setup a folder system for HL2 Modeling

I'm going to define a term called [steam-logon] to simply this section. [steam-logon] is the directory path to your Steam logon folder. It should be something like "C:\Program Files\Valve\Steam\SteamApps\[your steam logon name]".

If you're not sure about it, open up Windows Explorer and look in the SteamApps folder in the path above. You should see a folder named with your steam logon. That's the folder I'm going to call [steam-logon].

Get into Windows Explorer and navigate to [steam-logon]. Notice that there's a half-life 2 folder, a sourcesdk folder and a sourcesdk_content folder. You'll be using those extensively while modeling for HL2.
Game directory treeGame directory tree
SDK directory treeSDK directory tree
Create folders or check they exist:
  1. [steam-logon]\half-life 2\hl2\models
  2. [steam-logon]\half-life 2\hl2\materials\models
  3. [steam-logon]\sourcesdk_content\hl2\modelsrc\models
  4. [steam-logon]\sourcesdk_content\hl2\materialsrc\models
You're going to be storing the files you create (model and texture) in the modelsrc and materialsrc directories. You'll use source SDK programs to convert them to HL2 models and textures in the models and materials directories.

You don't need to create the individual model folders yet. But, for every new model with the name [model-name] you fashion, you should:
  1. Create a new folder: [steam-logon]\sourcesdk_content\hl2\modelsrc\models\[model-name]
  2. Create a new folder: [steam-logon]\sourcesdk_content\hl2\materialsrc\models\[model-name]
  3. Create a new folder: [steam-logon]\half-life 2\hl2\models\[model-name]
  4. Create a new folder: [steam-logon]\half-life 2\hl2\materials\models\[model-name]
Notes on Creating HL2 Textures When you've created a texture for your model, save it to the folder: [steam-logon]\sourcesdk_content\hl2\materialsrc\models\[model-name]

If you've setup folders as recommended above, you can compile the texture for use by Source engine as follows:
  1. Open up Windows Explorer to the texture folder: [steam-logon]\sourcesdk_content\hl2\materialsrc\models\[model-name]
  2. Open up another Windows Explorer to the SDK programs folder: [steam-logon]\sourcesdk\bin
  3. Click and drag the texture file [new texture].tga from the texture folder and drop it onto the program vtex.exe in the bin folder.
Compiling texturesCompiling textures
  1. A DOS window should open up, give you some information on your texture file and give you a "Hit Key to Continue" prompt.
  2. For a successful texture compile, that information should not contain any "could not find.." or "could not open.." errors.
  3. If successful, you should have a [new texture].vtf file in the folder: [steam-logon]\half-life 2\hl2\materials\models\[model-name].
  4. There will also be a [new texture].txt file in the materialsrc folder. It can be ignored. It's used for more advanced texturing.
For the Source engine to use the texture, it needs some information on how the texture is to be used. Open up Notepad or some text editor and create a file with the following text in it. Don't add any filename extensions. Include the quotation marks.
"VertexLitGeneric"
 {
    "$baseTexture" "models/[model-name]/[new texture]"
    "$model" 1
 }
Save the file as [new texture].vmt to the folder: [steam-logon]\half-file 2\hl2\materials\models\[model-name] where the [new texture].vtf file resides.

For example, if you're creating a model named "mycrate" and you're texturing it with "crate_tex.tga," your vmt file will look like this:
"VertexLitGeneric"
{
    "$baseTexture" "models/mycrate/crate_tex"
    "$model" 1
}
You've created a texture file ready for use for texturing a model.

Compiling

You need to create three SMD-type files:
  1. A model reference file (e.g. [model_name]_ref.smd)
  2. A skeletal animation file (e.g. [model_name]_idle.smd)
  3. A collision box descriptor (e.g. [model_name]_physbox.smd)
For a prop_static model, only the reference file is needed (more on that later). For prop_dynamic and prop_physics models, all three files are needed.

Once you have created the model and textured it in your modeling program, save or export the SMD files. Your modeling program should support saving or exporting all three types of files if you want to create animated models.

The SMD files should be exported to or placed in the folder: [steam-logon]\sourcesdk_content\hl2\modelsrc\models\[model_name].

You must use a Source-compatible Targa (TGA) file to texture your model. The texture name is saved in the SMD file and that texture must be compiled as described above before the model can be used successfully.

Before you can compile your model, you have to create a .qc file to tell the compiler what parameters to use in the model. Using a text editor, create a file with contents similar to the following:
$modelname sec_cam/sec_cam.mdl
$cdmaterials models/sec_cam
$staticprop
$scale 1.0
$body studio "sec_cam_ref.smd"
$sequence idle "sec_cam_idle.smd" fps 1
$collisionmodel "sec_cam_phys.smd" {
    $Mass 20
}
Substitute the name of your model for 'sec_cam.' Save the text file as [model-name].qc in the folder: [steam-logon]\sourcesdk_content\hl2\modelsrc\models\[model-name] along with your SMD files.

To compile your model for use with the Source engine:
  1. Open Windows Explorer to the model folder: [steam-logon]\sourcesdk_content\hl2\modelsrc\models\[model-name]
  2. Open another copy of Windows Explorer to the SDK programs folder: [steam-logon]\sourcesdk\bin
  3. Click and drag the [model-name].qc file from the model folder and drop it onto the program studiomdl.exe in the bin folder.
  4. A DOS window should open up, give you some information on your model file and close.
  5. If successful, you should have a [model-name].mdl file (and a bunch of others) in the folder: [steam-logon]\half-life 2hl2models[model-name].
  6. Launch the model viewer (HLMV.exe) and take a look at your model.
Note: If your modeling program only exports reference SMDs, don't fret. You can still create prop_static models. Just change the .qc file to look like this:
$modelname sec_cam/sec_cam.mdl
$cdmaterials models/sec_cam
$staticprop
$scale 1.0
$body studio "sec_cam_ref.smd"
$sequence idle "sec_cam_ref.smd" fps 1
$collisionmodel "sec_cam_ref.smd" {
    $Mass 20
}
For a static prop, there's no movement so the "idle" model is the same as the reference model. And, because it doesn't move, the reference position can be used to calculate collisions.

Using your Model

Open up Hammer and create a room for your model. Be sure to include a info_player_start and a light.

Put a new prop_static entity somewhere in the room. In the entity's property box, go to World model in the Class Info tab and browse to your new model's folder. Double-click the folder and double-click on the icon for your model. Back in the property box, click apply.

You should actually be able to see your new model in the 3D textured window of Hammer. Compile your room, run it and admire your new model.

2 Comments

Commented 15 years ago2009-05-04 02:45:58 UTC Comment #100708
Wow , great tutorial. I used to compile using cannonfodders studio compiler. But seems like I does not work anymore. So I'll have a decent go at this one =]
Commented 9 years ago2015-01-16 00:16:41 UTC Comment #100709
Use Crowbar for decompiling and compiling Source engine .MDL model files ;)
https://developer.valvesoftware.com/wiki/Crowbar

You must log in to post a comment. You can login or register a new account.