Things Named Veazie Places Named Veazie People Named Veazie The Site for All Things Veazie!

Setup to Do Half-Life 2 Modeling

This tutorial will teach you:
- what programs you will need to be able to create, texture and export Half-Life 2 smd files. smd files can be compiled into Half-Life 2 models which can be used as props in a Half-Life 2 map
- what programs you will need to create textures for models, to compile those textures
- how to setup a system (Windows) variable to make compiling of textures and models a simple drag-and-drop operation
- how to setup folders to simplify texture and model compilation
- how to use your model in Hammer as a prop_static
   
   
 
This tutorial will not teach you:
- how to subscribe to Steam (a Valve program for playing online games such as Half-Life 2, Counter-Strike, etc.). Goto http://www.steampowered.com/ for more information.
- how to create a texture for a model
- how to create geometry for a model or how to texture that model. Another tutorial is available on this site for creating and texturing models in Softimage XSI EXP v4.2 if you have that program.
- how to export smd files from a particular modeling program. You'll have to determine that for your individual modeling program. Another tutorial is available on this site for Softimage XSI EXP v4.2 which details exporting smd files from that program.
 

Index

Get the Source SDK
Setup the VPROJECT environment variable
Get a Modeling Program
Get a Texture Editing Program
Setup Folders for HL2 Modeling
Setting Up Folders for Your Model and Texture
Notes on Creating and Compiling HL2 Textures
Notes on Creating and Compiling HL2 Models
Using Your HL2 Model
Extracting and Converting HL2 Textures
 

Get the Source SDK

You will need the Source SDK (software development kit) to compile textures for models and compile smd files to create models for Half-Life 2.
Launch Steam by double-clicking the Steam interface icon. Click Play Games. Scroll down to the TOOLS section and click Source SDK.
Follow the directions you're given to download and install the Source SDK.
Note: some problems have been reported in the SDK installation process. Do not do anything in Windows other than following the installation instructions while Steam downloads and installs the SDK!
When the sdk has been installed, you should have a desktop icon to launch the Source SDK programs, similar to your Steam launch icon.
 

Setup the VPROJECT environment variable

Setting up this environment variable in Windows will allow you to drag-and-drop textures and models for compiling, provided you setup your material and model folders correctly.
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. This is the directory where the materials and models folders are for the game for which you're creating textures and models. The path shown here may not be correct for you. You may have to use Windows Explorer to determine the correct path for your setup.
7. press OK buttons until you're back to your desktop.
 

Get a Modeling Program

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 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 and a reference smd exporter is available. I haven't seen an exporter for skeletal or physbox smds. Blender is available for download from www.blender.org. You'll need the smd export addon which you can get from http://asrc.pjohnsen.com/downloads/smd_export.py. Copy the py file and put it in the folder c:\Blender Foundation\Blender\.blender\scripts which should have been created when you installed Blender. More information about Blender and HL2 modeling can be found at http://developer.valvesoftware.com/wiki/Modeling_props_with_Blender.
XSI EXP v4.2 is a very complete program available from softimage.com. I think that XSI v4.2 is well worth the trouble to download and install. If you interested in XSI:
1. Download XSI EXP v4.2 from http://downloads.zdnet.co.uk. Search for "softimage" and download XSI EXP v4.2.
  or
2. download from www.softimage.com/products/Mod/v42/downloads if you don't mind the hassle of fileplanet or fileshack.
3. 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 from Softimage (via email I believe). You have to register, but it's free and it's an excellent program.
4. Activate XSI with your activation key.
5. Download and install the ValveSource addon from the softimage downloads page. This addon allows you to export all the filetypes you'll need for static and animated props.
6. Download and install the XSI documentation from the softimage downloads page.
 

Get a Texture Editing Program

Strictly speaking, you don't need a texture editor if you have appropriate texture files available to texture your model with. However, Source requires Targa format images ( .tga extension) to compile into Source compatible texture files.

A good editor aimed at gaming textures is wally.exe. You can download it (free) from http://www.telefragged.com/wally/. Wally can export tga files.
IrfanView is a good program for modifying images and converting them among quite a few formats, including tga. You can download it (free) from http://www.irfanview.com.

You can also use Adobe Photoshop or other image editor.

GCFScape (download from http://nemesis.thewavelength.net/) is a good program to access texture files in Half-Life 2 content files (including textures).
 

Setup Folders for HL2 Modeling

Note: the various folder paths discussed in this tutorial are quite long, and many of them are very similar. Read them carefully!
I'm going to use 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 for a steamapps folder. In that folder you should see a folder named with your steam logon. The full path to that folder is what you need to use for [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.
Create the following 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
 
 

Setting Up Folders for Your Model and Texture

When you're ready to model, but before you startup your modeling program, create folders for your compiled texture, compiled model, texture (tga) file and your smd files. Create a separate set of folders for each model you create. "[model-name]" is a suitable name for the folder where your model files will be stored. If you're creating a streetlamp, call the folder streetlamp so it will be obvious when you browse for it in the model viewer or in the Hammer editor. Use the same [model-name] for all four folders below.
1. [steam-logon]\sourcesdk_content\hl2\modelsrc\models\[model-name]
2. [steam-logon]\sourcesdk_content\hl2\materialsrc\models\[model-name]
3. [steam-logon]\half-life 2\hl2\models\[model-name]
4. [steam-logon]\half-life 2\hl2\materials\models\[model-name]
 

Notes on Creating and Compiling HL2 Textures

Textures must be a power-of-2 number of pixels on each side. That is, each side of the texture must be 2, 4, 8, 16, 32, 64, 128, 256, 512 or 1024 pixels. Actually, it can be greater than 1024 pixels but now you're talkin' big texture.
The sides of the texture do not have to be the same length. You can have 256x256 or 16x512 sized textures.
The texture you create, ready for compiling, must be in tga (Targa) format.
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 [texture-name].tga from the texture folder and drop it onto the program vtex.exe in the bin folder.
4. A DOS window should open up, give you some information on your texture file and give you a "Hit Key to Continue" prompt.
5. For a successful texture compile, that information should not contain any "could not find.." or "could not open.." errors.
6. If successful, you should have a [texture-name].vtf file in the folder: [steam-logon]\half-life 2\hl2\materials\models\[model-name].
7. There will also be a [texture-name].txt file in the materialsrc folder. It can be ignored. It's used for more advanced texturing.

 

Shortcut: Right-click on vtex.exe and Send To->Desktop->shortcut. Then you can drag-and-drop your tga files onto the desktop vtex shortcut rather than using the second Windows Explorer as decribed above.

 

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 [texture-name].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
}

 

And you'll save the file as crate_tex.vmt in the folder [steam-logon]\half-life 2\hl2\materials\models\mycrate.
 

Notes on Creating and Compiling HL2 Models

You (usually) need to export 3 smd-type files from your modeling program:
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.

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 tga file to texture your model. The texture name is saved in the smd files and that texture must be compiled and located in the correct folder 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.
For models to be used as prop_static, you only need a "..._ref" smd file for compilation. Change "..._idle" and "..._phys" to "..._ref" in the qc file. Your file will now be similar to:

 

$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
}

Because prop_static entities don't move, the "idle" action is the same as the base model. Similarly, collisions with an entity that doesn't move is based simply on the base model.
For models to be used as prop_dynamic or prop_physics, omit the "$staticprop" line and change "fps 1" to "fps 15" ( or "fps 30" ) as needed for animation. You may have to experiment.
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. This is done similarly to the drap-and-drop texture compiling described above.
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 2\hl2\models\[model-name].
6. Launch the model viewer (HLMV.exe) from the Source SDK window (see picture under Using Your HL2 Model below) and take a look at your model.
 

Using Your HL2 Model

Open your Hammer editor using the SourceSDK window.
Insert a prop_static entity into your map.
In the properties dialog for the entity under the Class Info tab, click on the Browse button beside the World Model property.
Browse to your model folder, open the folder and double-click the icon for your model.
Your textured model should appear in the 3d textured window in Hammer.
Compile and run your map to examine your newly created model.
 

Extracting and Converting HL2 Textures

You can extract HL2 textures from HL2 content files for skinning your own models. HL2 stores textures in content files in a proprietary format with the extension .vtf which I assume stands for "Valve Texture File." Each vtf file is accompanied by a vmt file, which may stand for "Valve Material Texture."

The vtf file is a compiled targa format image file. The vmt file is a text file describing the use of the vtf file.
Download and install Gcfscape from http://nemesis.thewavelength.net/. It's an excellent program. You can use gcfscape to extract the vtf and vmt files from the HL2 content files.
Decide on the texture you want to extract by browsing throught the textures in the Hammer editor. In the texture browser, note the name of the texture and the folder in which it resides. E.g., models/props_pipes/pipemetal001a.
You won't be able to use gcfscape with any Steam applications open. Close down any Steam programs you have running - Steam, Source SDK, etc.
Open up gcfscape and click the Open Folder icon. If needed, browse to your Steamapps folder. You should see the gcf files listed in the window to the right. I assum gcf stands for Game Content File.
Open one of the gcf's (e.g., source materials.gcf).
In the left pane, browse (for example) to hl2/materials/Models/props_pipes.
In the right pane, select both pipemetal001.vtf and pipemetal001.vmt (click on the names with shift key pressed).
Right-click on the selected names and click extract.
In the dialog that pops up, select the folder where you want the extracted files to reside. I suggest you create a folder close to the root of your drive named "HL2Extracted" or something similar. It should be a folder that easy to navigate to when you're in a DOS prompt window (more on that in a moment).
Extract the files and exit gcfscape. Check that the Pipemetal001a.vft and Pipemetal001a.vmt files are in your HL2Extracted folder.
Open up Notepad and type in the following, substituting your_logon with the name of the folder corresponding to your Steam logon name. Include the quotation marks!
"c:\program files\valve\steam\steamapps\[your_logon]\sourcesdk\bin\vtf2tga.exe" -i %1 -o %2
Save the file as "convtga.bat" in your HL2Extracted folder. You'll need to select "all files" instead of ".txt files" in the filesave dialog so you don't have a .txt extension to your file. If you end up with convtga.bat.txt just go into Windows Explorer and edit the name.
Open up a DOS prompt window (Start->All Programs->Accessories->Command Prompt). Change directories to your HL2Extracted folder ( cd c:\hl2extracted ).
At the command prompt, type convtga pipemetal001a pipemetal001a and hit Enter. vtf2tga should output some conversion info.
Type exit at the command prompt to close the Command Prompt window.
You should now have a pipemetal001a.tga file in your HL2Extracted folder for use in texturing your models. You can move the vtf and vmt files to your hl2\materials\models\[your model name] folder. Edit the vmt file to suit. I prefer VertexLitGeneric rather than LightMappedGeneric.

 


updated 3-Sep-2005