This article's documentation is for anything that uses the Source engine. Click here for more information.

$model (QC): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(22 intermediate revisions by 14 users not shown)
Line 1: Line 1:
The [[QC command]] '''$model''' specifies a reference [[SMD]] file to be used as part of a complex model. Simple models (including all [[$staticprop]]s) should use [[$body]].
{{LanguageBar}}
{{note|Not to be confused with [[$model (VMT)]] which is used in VMT files.}}
{{this is a|QC command|name=$model|notitlechange=1}}
{{distinguish|Model|desc1=a three-dimensional object|$model (VMT)|desc2=a VMT parameter}}
This [[QC command]] specifies a reference [[SMD]], [[DMX]], [[OBJ]], or [[FBX]] file to be used as part of a complex model. Simple models (including all those with {{ent|$staticprop}}) should use {{ent|$body}}.


== QC syntax ==
== QC Syntax ==
  $model "<name>" "<filpath>/<reference_model>.smd"
  $model "<name>" "<filepath>/<reference_model>"


; <code><name></code>
; <code><name></code>
: A unique identifier for this model.
: A unique identifier for this model.
; <code><filepath>/<reference_model>.smd</code>
; <code><filepath>/<reference_model></code>
: Filepath (relative to the QC file's current directory) and Filename of a reference.smd.
: Filepath (relative to the QC file's current directory) and filename of the reference model, including extension.




Line 14: Line 16:
  [[$modelname]] "weapons/shell.mdl"
  [[$modelname]] "weapons/shell.mdl"
  [[$cdmaterials]] "models/weapons/"
  [[$cdmaterials]] "models/weapons/"
  '''[[$model]] "Shell" "shell.smd"'''
  '''[[$model]] Shell "shell"'''
  [[$sequence]] "idle" "shell.smd"
  [[$sequence]] idle "shell"


== Options ==
== Options ==


{{stub}}
=== eyeball ===


===eyeball===
{{Inline note|See {{ent|Eyeball}}.}}


See [[Eyeball]].
=== eyelid ===


===eyelid===
: Tells any NPCs using this model how to close their eyes (e.g., to blink).
;<code><name></code>: Base name of the eyelid flexcontroller. This is combined with the "lowerer", "neutral", and "raiser" options to build the piecewise blend positions of the eyelid.
:;<code><name></code>: Base name of the eyelid flexcontroller. This is combined with the "lowerer", "neutral", and "raiser" options to build the piecewise blend positions of the eyelid.
;<code>"<expression_file_name>.vta"</code>: The name of the file to find the morph targets.
:;<code><expression_file_name>.vta</code>: The name of the file to find the morph targets.
;<code>lowerer <frame> <height></code>: One of the three options, the frame number in the <code>expression_file</code>, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
:;<code>lowerer <frame> <height></code>: One of the three options, the frame number in the <code>expression_file</code>, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
;<code>neutral <frame> <height></code>: One of the three options, the frame number in the <code>expression_file</code>, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
:;<code>neutral <frame> <height></code>: One of the three options, the frame number in the <code>expression_file</code>, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
;<code>raiser <frame> <height></code>: One of the three options, the frame number in the <code>expression_file</code>, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
:;<code>raiser <frame> <height></code>: One of the three options, the frame number in the <code>expression_file</code>, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
;<code>split <distance></code>: Where to start, on the opposite side of the "0" line, for finding vertices that belong to this eyelid morph target.
:;<code>split <distance></code>: Where to start, on the opposite side of the "0" line, for finding vertices that belong to this eyelid morph target.
;<code>eyeball <eyeball_name></code>: Name of the eyeball that will drive this eyelid's flexcontroller.
:;<code>eyeball <eyeball_name></code>: Name of the eyeball that will drive this eyelid's flexcontroller.


  [[$model]] "female_01" "female_01_reference_RE.smd" {
=== dmxeyelid ===
    '''[[eyelid]]  upper_right "mdldecompiler_expressions.vta" lowerer 4 0.000000 neutral 0 0.000000 raiser 0 0.000000 split 0.1 eyeball righteye'''
: The same as eyelid, but loads morph targets from .dmx instead of .vta.
}
; Syntax:
 
  dmxeyelid <upper|lower> <[[DMX_model|DMX File]]> lowerer <[[DMX_model#Flex_controllers|delta]]> <[[float|pos]]> neutral <[[DMX_model#Flex_controllers|delta]]> <[[float|pos]]> raiser <[[DMX_model#Flex_controllers|delta]]> <[[float|pos]]> righteyeball <righteye> lefteyeball <lefteye>
=== flexfile ===
; Example:
;<code>"<expression_file_name>.vta"</code>:  
<source lang=php>
[[$model]] "female_01" "female_01_reference_RE.smd" {'''
dmxeyelid upper $file$ lowerer "EM64U" -0.23 neutral "AU0"  0.15 raiser "EM63U"  0.28 righteyeball "righteye" lefteyeball "lefteye"
    '''[[flexfile]] "mdldecompiler_expressions.vta" {'''
dmxeyelid  lower $file$ lowerer "EM64D" -0.32 neutral "AU0" -0.24 raiser "EM63D" -0.06 righteyeball "righteye" lefteyeball "lefteye"
    '''[[flexpair]] "AU1" 1.0 frame 5'''
</source>
    '''[[flex]] "AU12AU25" frame 10'''
: where:
    '''}'''
:: "AU0", "EM63U", "EM63D", "EM64U", and "EM64D" - are all delta shape names.
}
:: "righteye" and "lefteye" - are the same '''<name>''' used by right and left {{ent|Eyeball}}
 
{{warning|Flex animation is incompatible with [[$scale]].}}


=== flex ===
=== Flex options ===
flex (flexname) [frame (frame #)] [position (controller value)] [split (distance)] [decay (amount)]
: {{Inline note| See [[Flex animation]] for detailed information.}}


A flex is a set of animated vertices and normals, otherwise known as a morph target.
; <code>[[Flex_animation#NoAutoDMXRules|NoAutoDMXRules]]</code>
* <code>frame (number)</code> is the frame number in the vta file where the flex can be found.
:: Remove any flexcontrollers already created.
* <code>position (controller value)</code> is for setting piecewise flexes.
* <code>split (distance)</code> pulls just one side of a flex, in units from the center line. Positive numbers starting on the right side at 0% at the specified distance growing to 100% on the negative side.  Negative numbers do the opposite.
* <code>decay (amount)</code>This specifies how "fleshy" the decay looks.  By default, within each flex, the vertices that move the most move the fastest, with the shortest movements moving only 20% of their total distance each frame - about 0.7 seconds to reach 99% of their target. The <code>(amount)</code> scales the decay, with 0 being even the smallest movements are instant, and values larger then 1 being even the longest movements are delayed.


=== flexpair ===
; <code>[[Flex_animation#VTA_format|flexfile]] <[[string|name]]></code>
  flexpair (flexname) (split distance) [options....]
:: Loads a [[VTA]] file.
; <code>[[Flex_animation#Defining_flexes|defaultflex]] frame <[[Int|frame]]></code>
:: Define which [[VTA|VTA frame]] is the baseline shape.
; <code>[[Flex_animation#Defining_flexes|flex]] <[[string|name]]> <options></code>
:: Define a basic shape.
; <code>[[Flex_animation#Defining_flexes|flexpair]] <[[string|name]]> <options></code>
:: Define flex split in right and left, with the said name and bind <R|L> postfix to the right shape.
; <code>[[Flex_animation#Defining_controllers|flexcontroller]] <[[string|group]]> <options></code>
:: Define a controller used by [[Faceposer]] and [[Creating_Faceposer_gestures|KeyValues gestures]].
; <code>[[Flex_animation#Defining_controllers|localvar]] <[[string]]> </code>
:: Define a variable to store flex rules.


Same options as [[#flex|flex]], but automatically creates two flexes with a split, with "R" and "L" appended to their name.
=== mouth ===


===flexcontroller===
mouth ([[int]]|mouth number) (flex controller name) (bone name) ([[float]]|X) ([[float]]|Y) ([[float]]|Z)
: Defines a mouth. Mouth number is sequentially numbered starting from 0, i.e., the first mouth should be mouth 0. X, Y, and Z indicate the forward vector (the direction the mouth faces?){{Clarify}}


  flexcontroller (group name) [range (min) (max)] [default (val)] (controller name) [(controller name) ... ]
=== spherenormals ===
 
This defines a named input into the flex system.  These normally just show up as sliders in [[Face Poser]], and are used as the inputs into the set of equations that actually drive the flexes. 
 
If you specify two names on the line, and the first is named <code>right_...</code> and the second <code>left_...</code>, then Face Poser will turn them into a single slider with right/left control.  Internally they're still stored and processed as independent right and left flexcontrollers, but the UI will show them as one.
 
[[$model]] "female_01" "female_01_reference_RE.smd" {
    '''flexcontroller eyelid right_lid_raiser "range" 0.000 1.000'''
}
 
===localvar===
;<code><name></code>: to do
;<code><definition></code>: to do
[[$model]] "female_01" "female_01_reference_RE.smd" {
    '''[[localvar]] upper_right_raiser'''
    '''%upper_right_raiser = ( right_lid_raiser * (( 1.000 - ( right_lid_droop *  0.800)) * (( 1.000 -  right_lid_closer) * ( 1.000 -  blink))))'''
}
 
===mouth===
mouth ([[int]]|mouth number) (flex controller name) (bone name) ([[float]]|X) (Y) (Z)
 
This defines a mouth. Mouth number is sequentially numbered starting from 0. ie. The first mouth should be mouth 0. X, Y, and Z indicate the forward vector (the direction the mouth faces?)
 
[[$model]] "female_01" "female_01_reference_RE.smd" {
    '''[[mouth]] 0 "mouth"  ValveBiped.Bip01_Head1 0.000 1.000 0.000'''
}
 
===defaultflex===
translates to:
 
flex "default" [options]
 
Options are the same as for flex.
 
===frame===
;<code><frame></code>: to do
;<code>position</code>: to do
;<code>split <distance></code>: to do
 
===spherenormals===


  spherenormals (material name) ([[float]]|X) ([[float]]|Y) ([[float]]|Z)
  spherenormals (material name) ([[float]]|X) ([[float]]|Y) ([[float]]|Z)
:; material name: The parts of the model with this material (mesh) will be effected
:; X, Y, Z: Coordinates to the sphere center
: This option will change the normals of the indicated mesh to point to (or from) the vector specified using X, Y, Z. Faces that are facing away from the vector will have normals pointing away from vector. All other faces, including coplanar faces, will have normals pointing towards the vector. In effect, shading will be done as though all the faces are parts of a sphere centered at vector.


*material name - the parts of the model with this material (mesh) will be effected
=== vcafile ===
*X, Y, Z - coordinates to the sphere center
{{Inline note| See [[Vertex animation]]. }}


This option will change the normals of the indicated mesh to point to (or from) the vector specified using X, Y, Z. Faces that are facing away from the vector will have normals pointing away from vector. All other faces, including coplanar faces will have normals pointing towards the vector. In effect, shading will be done as though all the faces are parts of a sphere centered at vector.
== Complex Example ==
Source: http://code.google.com/p/modderation/source/browse/trunk/codebases/from-source/utils/studiomdl/studiomdl.cpp
 
== Complex example ==


From <code>sourcesdk_content\hl2\modelsrc\humans_sdk\Male_sdk\Male_06_sdk.qc</code>:
From <code>sourcesdk_content\hl2\modelsrc\humans_sdk\Male_sdk\Male_06_sdk.qc</code>:


  $model male_06 "male_06_reference.smd"{
  $model male_06 "male_06_reference"{
  eyeball righteye "ValveBiped.Bip01_Head1" -1.2711 -4.2197 67.5593 "eyeball_r" 1 4 "pupil_r" 0.63
  eyeball righteye "ValveBiped.Bip01_Head1" -1.2711 -4.2197 67.5593 "eyeball_r" 1 4 "pupil_r" 0.63
  eyeball lefteye "ValveBiped.Bip01_Head1" 1.3572 -4.2197 67.5514 "eyeball_l" 1 -4 "pupil_l" 0.63
  eyeball lefteye "ValveBiped.Bip01_Head1" 1.3572 -4.2197 67.5514 "eyeball_l" 1 -4 "pupil_l" 0.63
Line 140: Line 109:
*[[Qc eyes]]
*[[Qc eyes]]
*[[Eye Position Setup]]
*[[Eye Position Setup]]
[[Category:QC Commands|M]]

Latest revision as of 21:28, 18 July 2025

English (en)한국어 (ko)Translate (Translate)

$model is a QC command available in all Source Source games.

Not to be confused with Model (a three-dimensional object) or $model (VMT) (a VMT parameter).

This QC command specifies a reference SMD, DMX, OBJ, or FBX file to be used as part of a complex model. Simple models (including all those with $staticprop) should use $body.

QC Syntax

$model "<name>" "<filepath>/<reference_model>"
<name>
A unique identifier for this model.
<filepath>/<reference_model>
Filepath (relative to the QC file's current directory) and filename of the reference model, including extension.


Example

$modelname "weapons/shell.mdl"
$cdmaterials "models/weapons/"
$model Shell "shell"
$sequence idle "shell"

Options

eyeball

See Eyeball.

eyelid

Tells any NPCs using this model how to close their eyes (e.g., to blink).
<name>
Base name of the eyelid flexcontroller. This is combined with the "lowerer", "neutral", and "raiser" options to build the piecewise blend positions of the eyelid.
<expression_file_name>.vta
The name of the file to find the morph targets.
lowerer <frame> <height>
One of the three options, the frame number in the expression_file, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
neutral <frame> <height>
One of the three options, the frame number in the expression_file, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
raiser <frame> <height>
One of the three options, the frame number in the expression_file, and the distance above or below the center of the pupil that polygon edge of the eyelid crosses the white of the eye.
split <distance>
Where to start, on the opposite side of the "0" line, for finding vertices that belong to this eyelid morph target.
eyeball <eyeball_name>
Name of the eyeball that will drive this eyelid's flexcontroller.

dmxeyelid

The same as eyelid, but loads morph targets from .dmx instead of .vta.
Syntax
dmxeyelid <upper|lower> <DMX File> lowerer <delta> <pos> neutral <delta> <pos> raiser <delta> <pos> righteyeball <righteye> lefteyeball <lefteye>
Example
dmxeyelid  upper $file$ lowerer "EM64U" -0.23 neutral "AU0"  0.15 raiser "EM63U"  0.28 righteyeball "righteye" lefteyeball "lefteye"
dmxeyelid  lower $file$ lowerer "EM64D" -0.32 neutral "AU0" -0.24 raiser "EM63D" -0.06 righteyeball "righteye" lefteyeball "lefteye"
where:
"AU0", "EM63U", "EM63D", "EM64U", and "EM64D" - are all delta shape names.
"righteye" and "lefteye" - are the same <name> used by right and left Eyeball

Flex options

See Flex animation for detailed information.
NoAutoDMXRules
Remove any flexcontrollers already created.
flexfile <name>
Loads a VTA file.
defaultflex frame <frame>
Define which VTA frame is the baseline shape.
flex <name> <options>
Define a basic shape.
flexpair <name> <options>
Define flex split in right and left, with the said name and bind <R|L> postfix to the right shape.
flexcontroller <group> <options>
Define a controller used by Faceposer and KeyValues gestures.
localvar <string>
Define a variable to store flex rules.

mouth

mouth (int|mouth number) (flex controller name) (bone name) (float|X) (float|Y) (float|Z)
Defines a mouth. Mouth number is sequentially numbered starting from 0, i.e., the first mouth should be mouth 0. X, Y, and Z indicate the forward vector (the direction the mouth faces?)[Clarify]

spherenormals

spherenormals (material name) (float|X) (float|Y) (float|Z)
material name
The parts of the model with this material (mesh) will be effected
X, Y, Z
Coordinates to the sphere center
This option will change the normals of the indicated mesh to point to (or from) the vector specified using X, Y, Z. Faces that are facing away from the vector will have normals pointing away from vector. All other faces, including coplanar faces, will have normals pointing towards the vector. In effect, shading will be done as though all the faces are parts of a sphere centered at vector.

vcafile

See Vertex animation.

Complex Example

From sourcesdk_content\hl2\modelsrc\humans_sdk\Male_sdk\Male_06_sdk.qc:

$model male_06 "male_06_reference"{
	eyeball righteye "ValveBiped.Bip01_Head1" -1.2711 -4.2197 67.5593 "eyeball_r" 1 4 "pupil_r" 0.63
	eyeball lefteye "ValveBiped.Bip01_Head1" 1.3572 -4.2197 67.5514 "eyeball_l" 1 -4 "pupil_l" 0.63

	eyelid  upper_right "male_06_expressions" lowerer 1 -0.2621 neutral 0 0.1287 raiser 2 0.2467 split 0.1 eyeball righteye
	eyelid  lower_right "male_06_expressions" lowerer 3 -0.3409 neutral 0 -0.2156 raiser 4 -0.0736 split 0.1 eyeball righteye
	eyelid  upper_left "male_06_expressions" lowerer 1 -0.2621 neutral 0 0.1287 raiser 2 0.2467 split -0.1 eyeball lefteye
	eyelid  lower_left "male_06_expressions" lowerer 3 -0.3409 neutral 0 -0.2156 raiser 4 -0.0736 split -0.1 eyeball lefteye

	mouth 0 "mouth" "ValveBiped.Bip01_Head1" 0 1 0     // mouth illumination

	flexfile "male_06_expressions" {
		$include "../standardflex_xsi.qci"
	}

	$include "../facerules_xsi.qci"
	$include "../bodyrules_xsi.qci"

}

See also