Due to a popular demand (I think), it's time for a little model compiling tutorial. Please note that in this tutorial I'm going to show you only the QC commands, exporting and other modelling stuff will be showed in another tutorial. I'm going to cover simple physic, dynamic and static models. No ragdolls, no npc or vehicles.

Now, assuming you have all the required SMD files we're going to compile the model. Those SMDs are:

Reference model (.smd exported as a reference frame. should be named model_ref.smd)

idle animation (.smd exported as an animation sequence. should only contain frame 0 and frame 1 of an idle animation. should be named model_still.smd)

physic model (.smd exported as a reference frame. should be named model_phys.smd)

Now that you have all your SMD files, it's time to compile.

I suggest to start you take my exemple QC file. It contains all the basic commands to create a static or simple physic prop.(save target as..)

Here's the description of each command you will find in the exemple QC.

$modelname This tells the compiler where to save the output .MDL file. The path is based on the game config you are on. If you open the Source SDK application, you'll see at the bottom a list of game you have for the Source Engine. Select the one your making your model for, your mod should be listed if you created it correctly. It will save the .MDL file in the models folder of your mod/game. For a mod called MOD1, it would be:

C:\Program Files\Valve\Steam\SteamApps\SourceMods\MOD1\models\ and then the path specified in the $modelname command. If your command is:

Note that the path+modelname after the $modelname command doesn't need "".

$cdmaterials This command tells the engine where to take the textures. When you exported your model_ref.smd, each face was assigned to a texture name, but not a path. Now this command tells the engine in what folder is the texture. The base path for texture is:

C:\Program Files\Valve\Steam\SteamApps\SourceMods\MOD1\materials\

Usually, you create a folder in materials called models, where you will put all the textures used for models. You should also create a subfolder in materials\models with the name of the folder where you model is placed, like our biglamp01.mdl is in props_city, so your textures will be placed in materials\models\props_city\biglamp01_texture.vmt. The final path will be:

$scale This command can change the scale of your model, if needed. When you make your model, you should consider that 1 unit in 3Ds MAX = 1 unit in Hammer. But if for any reason the model is wrongly scaled, you can change the value of this command, where 1 = the original size of the model.

$body This tells the compiler what SMD is the reference model. Some models have many subparts, so they have a couple of commands like this. But in a simple static or physic prop, only one is needed. Your command should look like this:

$body studio "biglamp01_ref.smd"

studio is the name of the subpart. But that's not very important for a simple prop. Then you have the name of the reference file between "". Note that there's no path because the SMDs should be in the same folder as the QC file.

$origin X Y Z This command is not needed for most of the props, it's mainly for special purposes like first person view weapons. Just replace the X, Y and Z letter by coordinates that will modify the origin. I suggest you simply erase it from the QC file if your only making props.

$upaxis Y This simple command is only needed for Maya users. Since Maya uses the Y axis as the vertical axis, just insert that command in your QC file to make the model straight. For MAX users, simply erase it.

$staticprop This command tells the engine that this prop is a static prop. It collapse all the bones and attachments to the center origin at 0,0,0. If you put this in your QC, you can only use this model as a prop_static or as a prop_detail in Hammer.

$surfaceprop Use this command in a prop_static model to tell the engine what type of prop it is. Here's a list of the values you can put between the "" just after the command:

$sequence This is a sequence command. It include an animation in a model file. Here a typical command for a static prop:

$sequence idle "biglamp01_still.smd" loop fps 1

idle is the name of the sequence.between the "" is the name of the sequence file.loop means the animation is looped.fps 1 is the frame per second rate of the sequence. In this case 1, no need of more since the animation is idle.

$collisionmodel This is the physic model command. It's needed in both static and physic models, but not in prop_detail. Here's a typical physic model command:

$collisionmodel "biglamp01_phys.smd" { $Mass 10 $concave}

Here you only need to change the physic model filename and the mass. The mass is in kilograms (2.2 pounds = 1 kilogram).

$keyvalues Keyvalues is only needed for prop_physic. It's like $staticprop command. It tells the engine how the model should react to the physic. Here's a typical keyvalues command:

$keyvalues{ "prop_data" { "base" "Type.Size" }}

You just need to change the Type.Size value by a propdata. These values are located in the source engine.gcf/hl2/scripts/propdata.txt file, but I got you a copy of it.

TicTac wrote:Just a note, you talked about $staticprop but this parameter has nothing at all to do with static/phys props. it simply means that there's only one bone and one animation in the model. ;)

That makes it automatically static. Because it's not moving.

right?

Nope, static props have different properties, no network traffic, smaller memory footprint, can be lightmapped (where each face counts as a lightmap square), they can effect the light mapping on brushes, and don't get dynamic shadows. (but they do get projected texture shadows, just like everything else)

Last edited by stoopdapoop on Wed Jun 24, 2009 4:46 pm, edited 1 time in total.

all paths are relative to the mod directories, so modelname starts in "models" and $cdmaterials starts in the materials folder. Also, when specifying a materials path you don't need to actually give the filename of the texture you're using, the filename is compiled with the model, so you're just telling it where to look.

it'd be easier to fix your QC if you posted the text (opposed to your screenshot of the text :) ) but replace the first two lines of your QC with