QC

From Valve Developer Community
Revision as of 07:40, 28 November 2006 by N-neko (talk | contribs) (Japanese page added)
Jump to: navigation, search

Definition

The .QC file is a text based script file that controls the whole process of compiling an .SMD model into the final .MDL (game) model.

In the .QC, you set what the .MDL name will be, what .SMD files are used as the reference model, the physics model, and the LODs. You can also set various physics properties, and surface properties (these adjust things like the bullet decals, and the sound that is played when the object is hit).

For a full list of .QC file commands, see QC Commands.

Making a new .QC file

The .QC file varies little between regular prop models, so as a base it is best to start by simply copying an existing .QC file from another prop:

  1. Copy the an existing .QC file from another prop model.
  2. Rename the .qc file to the name of your prop.
  3. Open the .QC file in a text editor (like Notepad) and modifying it to be suitable for your new model.

The .QC file should be saved into the same folder as your .SMD model files.

Typical .QC file

Below is an example of a typical .QC file for a world prop model:

$modelname props_foliage/tree_deciduous_01a.mdl
$body "Body" "tree_deciduous_01a_reference.smd"

$scale 1.0
$staticprop
$surfaceprop "wood_solid"
$upaxis Y

$sequence "idle" "tree_deciduous_01a_reference" fps 30

$lod 50
{
     replacemodel "tree_deciduous_01a_reference" "tree_deciduous_01a_lod1"
}

$collisionmodel "tree_deciduous_01a_physbox.smd"
{
    //Mass in kilograms
    $mass 350.0
    $concave
}

This .QC is sufficient to build a model with both a physics hull (physbox) and LODs (level of detail models).

Individual commands

Here follows a review of each line in the .QC show above:

$modelname props_foliage/tree_deciduous_01a.mdl

The command $modelname sets the name and location of the MDL that is created. This MDL is going to be called tree_deciduous_01a.mdl and will be in the models/props_foliage folder. There is no need inside the .QC file to specify that this will be going into the models folder – that is presumed by Studiomdl (the program that builds MDL models, using the .QC file).

You will also note that there is nothing here saying which game this is model will be built under. This is because the model gets built under the current game directory.

For example, if you have Counter Strike: Source set as your current game in VConfig or the Source SDK Window, this .QC would build the model into Steam/SteamApps/username/counter-strike source/cstrike/models/props_foliage/tree_deciduous_01a.mdl.

$body "Body" "tree_deciduous_01a_reference.smd"

The $body command sets the body group. Body groups are a way of having sub-models inside one MDL. (For example, you could have an MDL which is a lamp-post, and have different body groups that represent different styles of lampposts). If you aren't having any sub-body groups, then just set this to the name of your reference .SMD file.

$scale 1.0

The $scale command allows you the scale the model when you compile it. Typically this should be left at 1.0, and all scaling be done in your 3D package, before you export the .SMD. This command should only be used for doing quick tests to a model.

$staticprop

The $staticprop command collapses the model to one bone. This is used to optimize all models that only use one bone.

$surfaceprop "wood_solid"

The $surfaceprop command sets the surface properties of the object. This has nothing to do with texture, but more the physical properties of the object. Whatever material you set here will effect what sound is played when the object is hit, and what decals appear on the object when it is shot (does it splinter like wood, or chip like stone?). A full list of surface properties available for you game can be found in under the game directory under scripts\surfaceproperties.txt. If it is not present, it will need to be extracted from the .GCF if you wish to view it.

$upaxis Y

The $upaxis command sets what axis should be considered up in the .SMD file. If you export a model from Maya, you need to have this set to "Y", since by default, Maya uses Y up. If you leave the $upaxis command out of the .QC file, then StudioMDL assumes the model is $upaxis Z (Max and XSI).

Sequences

$sequence "idle" "tree_deciduous_01a_reference" fps 30

The $sequence command is used to set animation sequences. All models need to have an "idle" animation sequence – this is the animation that is played when the model is at rest (idling).

The command syntax is as follows:

$sequence "sequence name" "name of SMD to use for the sequence" framerate

Since this model is not animated at all, you can just use the reference model (the .SMD that contains all the faces of the model) as the animation sequence – since this has no animation in it.

When exporting an animation, you will export a reference model, that holds just the bone and face information. Then, as a separate .SMD file you can export the animation – so you might have solider_reference.smd (the solider model, all rigged), and solider_run_anim.smd – which is just an .SMD that holds the bone animations in. You would then put this into your .QC as another sequence, this time called run instead of idle.

Levels of Detail

$lod 50
{
     replacemodel "tree_deciduous_01a_reference" "tree_deciduous_01a_lod1"
}

The $lod command is used to set levels of detail (LOD) models. A model can have any number of LODs, however each LOD should remove at least 140 polygons, otherwise it could well be more expensive than not having the LOD!

The number after the $lod command is the distance at which you want the model to swap to the LOD model. There are no magic numbers here, since models vary in scale and detail. Generally, set the first LOD to around 40 – and see how it looks in Half-Life Model Viewer ( a separate application that is used to view models). HLMV allows you to view your model, with the LOD switches at the distances you have set.

The replacemodel command is the actual command that swaps one .SMD for another, at a given distance. In the example above, the tree_deciduous_01a_reference is swapped for the tree_deciduous_01a_lod1 model at a range of 50 units.

If you wanted another LOD, at say 100 units – the LOD section would look like:

$lod 50
{
     replacemodel "tree_deciduous_01a_reference" "tree_deciduous_01a_lod1"
}

$lod 100
{
     replacemodel "tree_deciduous_01a_reference" "tree_deciduous_01a_lod2"
}

Here, at a range of 100 units, model tree_deciduous_01a_lod1 is swapped out for tree_deciduous_01a_lod2.

To recap, the reference model is used up until 50 units, where it is swapped out for the first LOD model. Then, at 100 units this LOD1 model is swapped out for second LOD model.

Collision models

$collisionmodel "tree_deciduous_01a_physbox.smd"
{
    //Mass in kilograms
    $mass 350.0
    $concave
}

The $collisionmodel is the command to setup the physbox/collision hull. Straight after $collisionmodel you specify the name of the .SMD to use as a collision model. You should always make a unique physics model, and not just use the reference model as a collision hull. The line //Mass in kilograms is just an information line, and has no effect on the computation of the .QC file. Any line with // at the start will be ignored. The $mass command sets the weight of the object. This is applicable when the object is a physics prop, and not a static prop. Make certain to set this correctly, otherwise your object will behave unrealistically. The $concave line says that the physics hull is made up of individual separate convex hulls (separate pieces), and not just one big hull.

Conclusion

This .QC file and the files it references are required to successfully compile a Source engine model.

See also

Template:Otherlang:en Template:Otherlang:en:jp