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

$scale: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Negative values are accepted, allows for flipping/mirroring animations)
No edit summary
 
(41 intermediate revisions by 14 users not shown)
Line 1: Line 1:
The [[$scale]] [[QC command]] multiplies the size of all subsequent SMDs. It does ''not'' affect values defined in the QC itself (e.g. [[$attachment]] locations).
{{LanguageBar}}
{{tabsBar|main=gs|base=$scale}}
{{this is a|QC command|name=$scale}} It uniformly multiplies the size of all subsequent model files. It does ''not'' affect values defined in the QC itself (e.g., {{Command|$attachment}} locations).


{{note|<code>$scale</code> only affects SMDs that come after it in the QC. Specify it before any file references!}}
{{note|{{Code|style=3|$scale}} only affects model files that come after it in the QC. Specify it before any file references!}}
{{note|<code>$scale</code> also accepts negative values. This can be used to flip/mirror animations or models if the compiled model is then decompiled.}}
{{note|{{Code|style=3|$scale}} also accepts negative values. This can be used to flip/mirror animations or models if the compiled model is then decompiled. Note that the model's normals will be inverted and will be rotated 180 degrees backwards, this can be easily fixed in a Source engine compatible model editor or by using the <code>angles</code> parameter in a {{Ent|$sequence}} block.}}
{{warning|<code>$scale</code> prevents [[flex animation]] from working when using the VTA format. This limitation can be bypassed by using the DMX format.}}
{{note|{{Command|$definebone}} will cause the defined bone, and the vertices assigned to it, to be scaled from their defined local position instead of the model file's origin.}}
{{warning|{{Code|style=3|$scale}} does not affect [[flex animation]] when using the [[VTA]] format. You have to change the size of the model to match {{Code|style=3|$scale}} value, and then export your [[VTA]] file. This limitation can be bypassed by using the [[DMX]] format.}}
{{warning|{{Code|style=3|$scale}} does not affect {{Ent|$proceduralbones}}.}}
{{warning|Negative values cause the prop to become upside-down and flips the textures to the opposite side of their mesh.}}
 
Sequences or animations can be scaled individually by specifying the "scale" option, see below for an example.
:{{note|{{Code|style=3|scale}} option will be multiplied with {{Code|style=3|$scale}}. If you make {{Code|style=3|$scale}} 0.5 and {{Code|style=3|scale}} value in {{Ent|$sequence}} 0.5, the final result will be 0.25 from the original size.}}


== Example ==
== Example ==
 
=== <kbd>$scale</kbd> ===
<source lang=php highlight=4>
<source lang=php highlight=4>
$modelname "weapons/shell.mdl"
$modelname "weapons/shell.mdl"
$cdmaterials "models/weapons/"
$cdmaterials "models/weapons/"


$scale 3 // before any SMDs
$scale 3 // before any model files such as SMD or DMX)
$body shell "shell_ref.smd"
$body shell "shell_ref.smd"
$sequence idle "shell_idle.smd"
$sequence idle "shell_idle.smd"
</source>
</source>


[[Category:QC Commands|scale]]
=== <kbd>$sequence scale</kbd> ===
<source lang=php highlight=3>
$sequence spin fan_spin.smd {
        fps 30
        scale 3
}
</source>
 
== Values for International System of Units ==
Values for scaling meshes if the model was based on SI. Unscaled models may have incorrect dimensions.
{| class="standard-table"
! colspan="8" | 1 foot = 16 units
|-
| Millimeters || {{Code|select=1|<nowiki>0.05249</nowiki>}}
|-
| Centimeters || {{Code|select=1|<nowiki>0.5249</nowiki>}}
|-
| Meters || {{Code|select=1|<nowiki>52.496</nowiki>}}
|-
| Kilometers || {{Code|select=1|<nowiki>52,496</nowiki>}}
|}
 
{| class="standard-table"
! colspan="8" | 1 foot = 12 units
|-
| Millimeters || {{Code|select=1|<nowiki>0.03937</nowiki>}}
|-
| Centimeters || {{Code|select=1|<nowiki>0.3937</nowiki>}}
|-
| Meters || {{Code|select=1|<nowiki>39.37</nowiki>}}
|-
| Kilometers || {{Code|select=1|<nowiki>39,370</nowiki>}}
|}
 
== See also ==
[[Dimensions]]
 
__NOTOC__

Latest revision as of 17:46, 3 August 2025

English (en)Translate (Translate)

$scale is a QC command available in all Source Source games. It uniformly multiplies the size of all subsequent model files. It does not affect values defined in the QC itself (e.g., $attachment locations).

Note.pngNote:$scale only affects model files that come after it in the QC. Specify it before any file references!
Note.pngNote:$scale also accepts negative values. This can be used to flip/mirror animations or models if the compiled model is then decompiled. Note that the model's normals will be inverted and will be rotated 180 degrees backwards, this can be easily fixed in a Source engine compatible model editor or by using the angles parameter in a $sequence block.
Note.pngNote:$definebone will cause the defined bone, and the vertices assigned to it, to be scaled from their defined local position instead of the model file's origin.
Warning.pngWarning:$scale does not affect flex animation when using the VTA format. You have to change the size of the model to match $scale value, and then export your VTA file. This limitation can be bypassed by using the DMX format.
Warning.pngWarning:$scale does not affect $proceduralbones.
Warning.pngWarning:Negative values cause the prop to become upside-down and flips the textures to the opposite side of their mesh.

Sequences or animations can be scaled individually by specifying the "scale" option, see below for an example.

Note.pngNote:scale option will be multiplied with $scale. If you make $scale 0.5 and scale value in $sequence 0.5, the final result will be 0.25 from the original size.

Example

$scale

$modelname		"weapons/shell.mdl"
$cdmaterials	"models/weapons/"

$scale		3		// before any model files such as SMD or DMX)
$body		shell	"shell_ref.smd"
$sequence	idle	"shell_idle.smd"

$sequence scale

$sequence spin fan_spin.smd {
        fps 30
        scale 3
}

Values for International System of Units

Values for scaling meshes if the model was based on SI. Unscaled models may have incorrect dimensions.

1 foot = 16 units
Millimeters 0.05249
Centimeters 0.5249
Meters 52.496
Kilometers 52,496
1 foot = 12 units
Millimeters 0.03937
Centimeters 0.3937
Meters 39.37
Kilometers 39,370

See also

Dimensions