QC: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(guide was duping Compiling Models)
Line 1: Line 1:
{{mergeto|Compiling a model}}<!-- there are too many "introductions" to this subject.-->
:''For a full '''list of QC commands''', see [[QC Commands]].''
{{note|'''The auto links in the mergeto template above may be messed up. Use [[:Category:QC Commands]] and [[Talk:Qc]] respectively.'''}}
:''To learn '''how to compile a model''', see [[Compiling Models]].''


A '''.QC''' file is a text-based script file that controls the process of compiling a .SMD source file into the final .MDL model that is read by the engine. The extension stands for [[Wikipedia:Quake C|Quake C]], the programming and scripting language from which the [[Valve Data File]] format was originally derived.
A '''QC''' file is a text-based script file that controls the process of compiling a [[SMD]] source file into the final MDL [[model]] that is read by the engine. The extension stands for [[Wikipedia:Quake C|Quake C]], the programming and scripting language from which the [[Valve Data File]] format was originally derived.


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).
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 [[LOD]]s. 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).
 
{{note|For a full list of .QC file commands, see [[QC Commands]].}}


{{tip|Shared QC files intended for use with <code>[[$include]]</code> are given the extension <code>qci</code>.}}
{{tip|Shared QC files intended for use with <code>[[$include]]</code> are given the extension <code>qci</code>.}}
== 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:
# Copy the an existing .QC file from another prop model.
# Rename the .qc file to the name of your prop.
# Open the .QC file in a [[text editor]] (like Notepad) and modify 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"
$cdmaterials  "models/props_foliage"
$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 <code>$modelname</code> sets the name and location of the MDL that is created. This MDL is going to be called <code>tree_deciduous_01a.mdl</code> and will be in the <code>models/props_foliage</code> 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|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 <code>Steam/SteamApps/''username''/counter-strike source/cstrike/models/props_foliage/tree_deciduous_01a.mdl</code>.
[[$body]] "Body" "tree_deciduous_01a_reference.smd"
The <code>$body</code> 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 <code>$scale</code> 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 <code>$staticprop</code> command collapses the model to one bone. This is used to optimize ''all'' models that only use one bone.
[[$surfaceprop]] "wood_solid"
The <code>$surfaceprop</code> 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|game directory]] under <code>scripts\surfaceproperties.txt</code>. If it is not present, it will need to be extracted from the [[GCF|.GCF]] if you wish to view it.
[[$upaxis]] Y
The <code>$upaxis</code> 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 <code>$sequence</code> 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 <code>solider_reference.smd</code> (the solider model, all rigged), and <code>solider_run_anim.smd</code> – 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 <code>run</code> instead of <code>idle</code>.
=== Levels of Detail ===
[[$lod]] 50
{
      replacemodel "tree_deciduous_01a_reference" "tree_deciduous_01a_lod1"
}
The <code>$lod</code> 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 <code>$lod</code> 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 <code>replacemodel</code> command is the actual command that swaps one .SMD for another, at a given distance. In the example above, the <code>tree_deciduous_01a_reference</code> is swapped for the <code>tree_deciduous_01a_lod1</code> 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 <code>tree_deciduous_01a_lod1</code> is swapped out for <code>tree_deciduous_01a_lod2</code>.
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 <code>$collisionmodel</code> is the command to setup the physbox/collision hull. Straight after <code>$collisionmodel</code> 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 <code>//Mass in kilograms</code> 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 <code>$mass</code> 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 <code>$concave</code> line says that the physics hull is made up of individual separate convex hulls (separate pieces), and not just one big hull.
=== Physics ===
For a fully working physics prop, you need to set the correct [[Prop Data|prop data]] in the QC file. For example, for a plastic barrel, you would need the following:
[[$keyvalues]] {
"prop_data" {
"base" "Plastic.Medium"
}
}
== Conclusion ==
This .QC file and the files it references are required to successfully [[Compiling Models|compile]] a Source engine model.


== See also ==
== See also ==
Line 138: Line 12:
* [[:Category:QC Commands]]
* [[:Category:QC Commands]]
* [[QC Commands]]
* [[QC Commands]]
* [[LOD_Models]]
* [[LOD Models]]
* [[Prop Types Overview]]
* [[Prop Types Overview]]
* [[Highlighting and Compiling QCs with ConTEXT]]
* [[Highlighting and Compiling QCs with ConTEXT]]

Revision as of 14:15, 26 November 2008

For a full list of QC commands, see QC Commands.
To learn how to compile a model, see Compiling Models.

A QC file is a text-based script file that controls the process of compiling a SMD source file into the final MDL model that is read by the engine. The extension stands for Quake C, the programming and scripting language from which the Valve Data File format was originally derived.

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).

Tip.pngTip:Shared QC files intended for use with $include are given the extension qci.

See also

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