$model (QC): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎flexfile: vertices can only move 8 units, who knew?)
(→‎Options: moved flex docs out, and general cleanup)
Line 19: Line 19:
== Options ==
== Options ==


{{stub}}
; <code>eyeball</code>
 
: See [[Eyeball]].
===eyeball===
; <code>eyelid</code>
 
: Tells any NPCs using this model how to close their eyes (e.g. to blink).
See [[Eyeball]].
:;<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.
===eyelid===
:;<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><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>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>"<expression_file_name>.vta"</code>: The name of the file to find the morph targets.
:;<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>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>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>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>eyeball <eyeball_name></code>: Name of the eyeball that will drive this eyelid's flexcontroller.
;<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>flexfile</code>
;<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>flex</code>
;<code>eyeball <eyeball_name></code>: Name of the eyeball that will drive this eyelid's flexcontroller.
; <code>flexpair</code>
 
; <code>defaultflex</code>
[[$model]] "female_01" "female_01_reference_RE.smd" {
; <code>flexcontroller</code>
    '''[[eyelid]]  upper_right "mdldecompiler_expressions.vta" lowerer 4 0.000000 neutral 0 0.000000 raiser 0 0.000000 split 0.1 eyeball righteye'''
; <code>localvar</code>
}
: See [[Flex animation]].
 
; <code>mouth</code>
=== flexfile ===
: <code>mouth ([[int]]|mouth number) (flex controller name) (bone name) ([[float]]|X) (Y) (Z)</code>
 
: 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?)
Defines a source of [[flex animation]]s.
; <code>spherenormals</code>
 
: <code>spherenormals (material name) ([[float]]|X) ([[float]]|Y) ([[float]]|Z)</code>
<source lang=php highlight=2>
:; material name: The parts of the model with this material (mesh) will be effected
$model "female_01" "female_01_reference_RE.smd" {
:; X, Y, Z: Coordinates to the sphere center
flexfile "mdldecompiler_expressions.vta" {
: 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.
flexpair "AU1" 1.0 frame 5
flex "AU12AU25" frame 10
}
// flexcontroller, %AU1, etc.
}
</source>
 
{{warning|Flex animation is incompatible with [[$scale]].}}
 
{{note|A vertex can be moved '''8 units at most''' (in any dimension) by a flex animation. After this, its location starts to wrap back around!}}
 
=== flex ===
flex (flexname) [frame (frame #)] [position (controller value)] [split (distance)] [decay (amount)]
 
A flex is a set of animated vertices and normals, otherwise known as a morph target.
* <code>frame (number)</code> is the frame number in the vta file where the flex can be found.
* <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 ===
flexpair (flexname) (split distance) [options....]
 
Same options as [[#flex|flex]], but automatically creates two flexes with a split, with "R" and "L" appended to their name.
 
===flexcontroller===
 
  flexcontroller (group name) [range (min) (max)] [default (val)] (controller name) [(controller name) ... ]
 
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)
 
*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.
Source: http://code.google.com/p/modderation/source/browse/trunk/codebases/from-source/utils/studiomdl/studiomdl.cpp


== Complex example ==
== Complex example ==

Revision as of 05:12, 3 March 2011

The QC command $model specifies a reference SMD file to be used as part of a complex model. Simple models (including all $staticprops) should use $body.

Note.pngNote:Not to be confused with $model (VMT) which is used in VMT files.

QC syntax

$model "<name>" "<filpath>/<reference_model>.smd"
<name>
A unique identifier for this model.
<filepath>/<reference_model>.smd
Filepath (relative to the QC file's current directory) and Filename of a reference.smd.


Example

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

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.
flexfile
flex
flexpair
defaultflex
flexcontroller
localvar
See Flex animation.
mouth
mouth (int|mouth number) (flex controller name) (bone name) (float|X) (Y) (Z)
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?)
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.

Complex example

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

$model male_06 "male_06_reference.smd"{
	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