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

$weightlist: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(11 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{stub}}
{{this is a|QC command|name=$weightlist}} It defines the influence to which each bone in a model is affected by a [[$sequence]] or [[$animation]]. For example, you could set the weight of the leg bones to 0 to only animate the top half of the skeleton.
The [[QC command]] [[$weightlist]] creates a named list of boneweights that can be used by animations that are intended to be blended on top of other animations.  
* The weightlist is built assuming that the root bone has a weight of 0, and that all child bones inherit the weight of their closest specified parent bone. This means that you only have to specify weights when they change, not for each and every bone in the list.  


==Syntax==
A <code>$weightlist</code> can be reused as many times as is needed. It must come above anything that uses it in the QC.
$weightlist <weightlist_name> "<bone_1_name>" <bone_1_weight> "<bone_2_name>" <bone_2_weight> 
where
;<weightlist_name>
: {{todo| confirm: name of the weightlist?}}
;<bone_1_name>
: is the name of the bone whose weight you wish to change.
;<bone_1_weight>
: is the weighting attributed to the specified bone and all its children.


==Example==
{{note|''No, this has nothing to do with physical weight or mass.''}}
{{todo| would be very helfpful}}
{{note|Values above 1 are accepted unlike what one might expect. These will multiply the motion of the animation.}}
{{tip|You can have up to 128 $weightlists [[QC_Commands|commands]]}}
{{tip|You can declare a default weight list with [[$defaultweightlist]] and this doesn't count on the 128 limit}}


== Usage ==
{{warning|Opening bracket must be on the same line as $weightlist}}
<source lang=php>
$weightlist my_weightlist {
<bone> <weight>
<bone> <weight>
...
}


[[Category:QC Commands]]
$sequence my_weighted_anim "my_anim.smd" weightlist my_weightlist
</source>
 
Bones inherit weight from their parents, and all root bones start with a weight of 0.
 
<source lang=php>
$weightlist no_hands {
"Bip01_Pelvis" 1.0
"Bip01_LHand" 0.0
"Bip01_RHand" 0.0
}
 
$weightlist head_and_arms "Bip01_Spine2" 1.0
 
$Weightlist UpperbodyBlend {
"Bip01_Pelvis" 0.1
"Bip01_L_Thigh" 0.0
"Bip01_R_Thigh" 0.0
"Bip01_Spine" 0.2
"Bip01_Spine1" 0.4
"Bip01_Spine2" 0.6
"Bip01_Spine4" 0.4
"Bip01_L_Clavicle" 0.8
"Bip01_L_Upperarm" 1.0
"Bip01_R_Clavicle" 0.8
"Bip01_R_Upperarm" 1.0
}</source>
 
==== PosWeight ====
optionally you can set '''<code>posweight</code>''' option right after bone ''weight'' value to also set weight for location translations on top of declared weight. Useful for blend different length skeleton animations or even disable position translations. <br/>{{note|'''posweight''' cannot be used when weight is already zero}}{{note|It doesn't really matter if posweight is double quoted}}
 
<source lang=php>
$weightlist rotate_but_dont_move {
"Bip01_Pelvis" 1.0 "posweight" 0.0
}</source>
 
== See also ==
 
* [[$animation#Blending|Subtracted animations]]

Latest revision as of 17:58, 3 August 2025

$weightlist is a QC command available in all Source Source games. It defines the influence to which each bone in a model is affected by a $sequence or $animation. For example, you could set the weight of the leg bones to 0 to only animate the top half of the skeleton.

A $weightlist can be reused as many times as is needed. It must come above anything that uses it in the QC.

Note.pngNote:No, this has nothing to do with physical weight or mass.
Note.pngNote:Values above 1 are accepted unlike what one might expect. These will multiply the motion of the animation.
Tip.pngTip:You can have up to 128 $weightlists commands
Tip.pngTip:You can declare a default weight list with $defaultweightlist and this doesn't count on the 128 limit

Usage

Warning.pngWarning:Opening bracket must be on the same line as $weightlist
$weightlist my_weightlist {
	<bone> <weight>
	<bone> <weight>
	...
}

$sequence my_weighted_anim "my_anim.smd" weightlist my_weightlist

Bones inherit weight from their parents, and all root bones start with a weight of 0.

$weightlist no_hands {
	"Bip01_Pelvis" 1.0
	"Bip01_LHand" 0.0
	"Bip01_RHand" 0.0
}

$weightlist head_and_arms "Bip01_Spine2" 1.0

$Weightlist UpperbodyBlend {
	"Bip01_Pelvis" 0.1 
	"Bip01_L_Thigh" 0.0 
	"Bip01_R_Thigh" 0.0 
	"Bip01_Spine" 0.2 
	"Bip01_Spine1" 0.4 
	"Bip01_Spine2" 0.6 
	"Bip01_Spine4" 0.4
	"Bip01_L_Clavicle" 0.8
	"Bip01_L_Upperarm" 1.0
	"Bip01_R_Clavicle" 0.8
	"Bip01_R_Upperarm" 1.0
}

PosWeight

optionally you can set posweight option right after bone weight value to also set weight for location translations on top of declared weight. Useful for blend different length skeleton animations or even disable position translations.

Note.pngNote:posweight cannot be used when weight is already zero
Note.pngNote:It doesn't really matter if posweight is double quoted
$weightlist rotate_but_dont_move {
	"Bip01_Pelvis" 1.0 "posweight" 0.0
}

See also