$sequence: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(partial rewrite)
Line 1: Line 1:
{{stub}}
<div style="float:right;padding:0 1em;background:#FFF;">__TOC__</div>
The [[QC command]] [[$sequence]] is used to specify an activity that the model may perform.


==QC syntax ==
The [[QC command]] <code>[[$sequence]]</code> defines a [[skeletal animation]]. It can be used either on its own, or to make use of Source's more advanced skeletal animation features in conjunction with <code>[[$animation]]</code> commands


  $sequence <name> <animation smd> fps <framerate integer> <any other options>
{{note|A <code>$sequence</code> can only see <code>$animation</code>s that come above it in the QC file.}}
 
== Usage ==
 
=== Simple ===
 
  $sequence <name> <Skeletal animation SMD> <options>
 
=== Advanced ===
 
$sequence <name> <options>
  {
  {
  <any $sequence properties>
  <[[$animation]] name(s)>
  }
  }


==== example 1 ====
== Options ==
[[$modelname]] "weapons/shell.mdl"
[[$cdmaterials]] "models/weapons/"
[[$model]] "Shell" "shell.smd"
'''[[$sequence]] idle "idle" fps 5.00'''


==== example 2 ====
=== Simple ===
[[$sequence]] run_holding_all {
a_runS a_runSE a_runE a_runNE a_runN_SMG a_runNW a_runW a_runSW a_runS
blendwidth 9 blend move_yaw -180 180 addlayer layer_run_holding ACT_RUN_RIFLE 1 node "running"
}


==$sequence options==
;<code><[[string]]|name></code>
 
:The name of the animation. Will appear in HLMV, Hammer, etc.
;activity (activity_name) (weight)
;<code><[[string]]|Skeletal animation SMD></code>
:This command binds the sequence to an activity name. An activity name is an alias for one or more sequences that the code can use.
:Path to the $sequence's source SMD. ''By including this, you tell studiomdl that you are using the simple version of the command.''
:The advantage to using activities is that the modeler can bind multiple sequences to one activity name, thus getting some variation in the animations the model plays without programmer intervention. For example, the modeler could create three idle animations and bind them all to ACT_IDLE. The programmer only has to write code saying to play ACT_IDLE, and one of the three idle sequences will be chosen.
;<code>loop</code>
:The second parameter, activity_name, must be an activity in the programmer's activity tables (in ai_activity.cpp and activitylist.cpp).
:Should this animation loop, or is it played once then stopped?
:The third parameter, weight, controls how often this sequence will be chosen versus other sequences bound to the same activity name. Sequences with higher weights will be chosen more often. For example, if you had a sequence called "idle1" with a weight of 1 and a sequence called "idle2" with a weight of 2, then "idle2" would have twice the chance of being played when the model is told to play ACT_IDLE.
;<code>fps <[[float]]|keyframes per second></code>
:If you only have one sequence for an activity, you can set the weight to -1 for a slight preformance boost.
:Override the speed at which the animation plays. Note that it's in ''key''frames per second - the animation will play back smoothly no matter what value you use!
;autoplay
;<code>activity <[[string]]|name> <[[float]]|weight></code>
:The sequence is automatically added at the end of the bone setup during playback, after all other sequences have been composited together. These sequences are usually "delta" sequences, but they don’t have to be. If the model has multiple autoplay sequences, they’re added in the order they appear in the QC file.  
:Links the sequence to an [[activity]]. The name should be one recognised by the target NPC's code. <code>Weight</code> modifies how likely this particular sequence is to be picked when the activity is called; a weight of <code>2</code> makes the animation twice as likely as to be called as an animation with a weight of <code>1</code>.
:The easiest way to think of these are that they’re just fancy bonecontrollers, but ones that have multiple bones. Autoplay sequences are only played at a cycle/frame index of 0.
:{{todo|What is every sequence in the activity had a weight of 2?}}
;addlayer (sequence)
:{{tip|If there is only one sequence tied to the activity, use a weight of -1.}}
:Automatically composites another sequence on top of the current sequence, before it’s composited on top of the current bone setup. The cycle index of this new sequence is the same as the current sequence.  
;<code>autoplay</code>
;blendlayer (sequence) (start) (peak) (tail) (end) [spline] [xfade]
:Makes the $sequence play at all times, on top of any other animations, no matter what the model is doing. Good for blended breathing animations and other automated motion. If a model has multiple <code>autoplay</code> $sequences, they’re layered in the order that they appear in the QC.
:Similar to addlayer, but the layer is only composited over the specified frames. The "spline" option coverts the linear fade in (start to peak) and fade out (tail to end) to a spline curve.  
:{{warning|Don't use this for an animation that might be played normally, or you'll end up with it playing twice and the motion doubling up.}}
;delta
:{{todo|What does "Autoplay sequences are only played at a cycle/frame index of 0" mean?}}
:The compliment to the "subtract" command, this tells the animation compositing system to "add" this sequence on top of the current bone setup instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
;<code>addlayer <[[string]]|new $sequence name></code>
;predelta
:Play another sequence at the same time as this one. Only useful if the new sequence(s) are blended. The animations begin together.
:The compliment to the "presubtract" command, this tells the animation compositing system to add the current bone setup on top of a different frame of reference instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.  
:{{todo|Do they also end together?}}
;snap
;<code>blendlayer <[[string]]|new $sequence name> <[[int]]|startframe> <[[int]]|peakframe> <[[int]]|tailframe> <[[int]]|endframe> [spline] [xfade]</code>
:Similar to <code>addlayer</code>, but the new $sequence only plays over specified frames.
:*The <code>spline</code> option converts the linear start-peak and tail-end fades of the $sequence to a spline curve.
:*{{todo|Behaviour of xfade.}}
;<code>snap</code>
:Remove all blending when transitioning to this animation. This is useful for reaction animations that are the result of sudden and violent changes in the models state such as flinching for creatures or shooting for weapons.  
:Remove all blending when transitioning to this animation. This is useful for reaction animations that are the result of sudden and violent changes in the models state such as flinching for creatures or shooting for weapons.  
;realtime
;<code>realtime</code>
:Ignore the cycle clock, play the sequence off of the real-time system clock. Useful when adding layers that need to not be cycle locked to their parent sequence.  
:Ignore the $sequence's kfps and time the $sequence with the global system clock. Useful when adding layers that shouldn't play at the same rate as their parent $sequence.  
;fadein (time)
;<code>fadein <[[float]]|seconds></code>
:Override default 0.2 second blend with specified time when transitioning to this animation.  
:Override default 0.2 second blend with specified time when transitioning to this animation.  
;fadeout (time)
;<code>fadeout <[[float]]|seconds></code>
:Override default 0.2 second blend with specified time when transitioning from this animation.  
:Override default 0.2 second blend with specified time when transitioning from this animation.  
=== Advanced ===
;All simple options
:Except for <code><Skeletal animation SMD></code>.
;<code>delta</code>
:The compliment to the "subtract" command, this tells the animation compositing system to "add" this sequence on top of the current bone setup instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
:{{warning|Using this with an $animation that hasn't been <code>subtract</code>ed has bad results!}}
;<code>predelta</code>
:The compliment to the "presubtract" command, this tells the animation compositing system to add the current bone setup on top of a different frame of reference instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
=== Unclear ===
{{todo|Which category are these?}}
;blendwidth (width)
;blendwidth (width)
:Instead of just 1x1, 2x1, 3x1, 2x2, and 3x3 blends, by blending width, you can now have any size rectangular blends such as 7x1, 3x4, 2x9, etc.  
:Instead of just 1x1, 2x1, 3x1, 2x2, and 3x3 blends, by blending width, you can now have any size rectangular blends such as 7x1, 3x4, 2x9, etc.  
Line 65: Line 85:
;keyvalues { [stuff] }
;keyvalues { [stuff] }
:Add a keyvalue block (see [[$keyvalues]]) to a specific sequence.  
:Add a keyvalue block (see [[$keyvalues]]) to a specific sequence.  
== Examples ==
=== Simple ===
[[$modelname]] "weapons/shell.mdl"
[[$cdmaterials]] "models/weapons/"
[[$body]] shell "shell-ref.smd"
'''[[$sequence]] idle "shell-idle.smd"'''
=== Advanced ===
$sequence run_holding_all
{
a_runS a_runSE a_runE a_runNE a_runN_SMG a_runNW a_runW a_runSW a_runS
blendwidth 9 blend move_yaw -180 180 addlayer layer_run_holding ACT_RUN_RIFLE 1 node "running"
}




[[Category:QC Commands]]
[[Category:QC Commands|S]]

Revision as of 07:13, 28 April 2008

The QC command $sequence defines a skeletal animation. It can be used either on its own, or to make use of Source's more advanced skeletal animation features in conjunction with $animation commands

Note.pngNote:A $sequence can only see $animations that come above it in the QC file.

Usage

Simple

$sequence <name> <Skeletal animation SMD> <options>

Advanced

$sequence <name> <options>
{
	<$animation name(s)>
}

Options

Simple

<string|name>
The name of the animation. Will appear in HLMV, Hammer, etc.
<string|Skeletal animation SMD>
Path to the $sequence's source SMD. By including this, you tell studiomdl that you are using the simple version of the command.
loop
Should this animation loop, or is it played once then stopped?
fps <float|keyframes per second>
Override the speed at which the animation plays. Note that it's in keyframes per second - the animation will play back smoothly no matter what value you use!
activity <string|name> <float|weight>
Links the sequence to an activity. The name should be one recognised by the target NPC's code. Weight modifies how likely this particular sequence is to be picked when the activity is called; a weight of 2 makes the animation twice as likely as to be called as an animation with a weight of 1.
Todo: What is every sequence in the activity had a weight of 2?
Tip.pngTip:If there is only one sequence tied to the activity, use a weight of -1.
autoplay
Makes the $sequence play at all times, on top of any other animations, no matter what the model is doing. Good for blended breathing animations and other automated motion. If a model has multiple autoplay $sequences, they’re layered in the order that they appear in the QC.
Warning.pngWarning:Don't use this for an animation that might be played normally, or you'll end up with it playing twice and the motion doubling up.
Todo: What does "Autoplay sequences are only played at a cycle/frame index of 0" mean?
addlayer <string|new $sequence name>
Play another sequence at the same time as this one. Only useful if the new sequence(s) are blended. The animations begin together.
Todo: Do they also end together?
blendlayer <string|new $sequence name> <int|startframe> <int|peakframe> <int|tailframe> <int|endframe> [spline] [xfade]
Similar to addlayer, but the new $sequence only plays over specified frames.
  • The spline option converts the linear start-peak and tail-end fades of the $sequence to a spline curve.
  • Todo: Behaviour of xfade.
snap
Remove all blending when transitioning to this animation. This is useful for reaction animations that are the result of sudden and violent changes in the models state such as flinching for creatures or shooting for weapons.
realtime
Ignore the $sequence's kfps and time the $sequence with the global system clock. Useful when adding layers that shouldn't play at the same rate as their parent $sequence.
fadein <float|seconds>
Override default 0.2 second blend with specified time when transitioning to this animation.
fadeout <float|seconds>
Override default 0.2 second blend with specified time when transitioning from this animation.

Advanced

All simple options
Except for <Skeletal animation SMD>.
delta
The compliment to the "subtract" command, this tells the animation compositing system to "add" this sequence on top of the current bone setup instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
Warning.pngWarning:Using this with an $animation that hasn't been subtracted has bad results!
predelta
The compliment to the "presubtract" command, this tells the animation compositing system to add the current bone setup on top of a different frame of reference instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.

Unclear

Todo: Which category are these?
blendwidth (width)
Instead of just 1x1, 2x1, 3x1, 2x2, and 3x3 blends, by blending width, you can now have any size rectangular blends such as 7x1, 3x4, 2x9, etc.
blend (name) (min) (max)
You can have up to 8 unique parameters.
node (name)
Tags the sequence as belonging to a point on the sequence transition graph table. This is for animations which don’t change graph state, such as looping animations. Multiple sequences can be at the same entry in the graph table, at which point they won’t need transition animations be move between each other.
Alternatively, you can have them at different points and expressly skip transitions (see $skiptransition). Sequences with no declaration are assumed at the root node and the transition graph assumes any sequence can move from the root node or to the root node without a intermediate transition.
transition (from) (to)
This specifies that the animation enters from one point on the node graph and exits at another point. This is used to play transitional sequences such as walk_to_stand, run_to_crouch, etc.
rtransition (name1) (name2)
Same as transition, but flags the sequence as able to be run in reverse order. This was used by the tentacle in HL1 but I don’t recommend it be used expect in special cases.
exitphase (phase)
When transitioning between looping animations, such as "stand_to_run", this tells the movement system where to start the next sequence, assuming it’s looping. It’s also assumed that you’ve made all the sequences that share the next node to be phase matched (see startloop).
$skiptransition (name1) (name2) [(name3) ...]
This adds a rule to the transition graph to allow direct movement between all the named nodes. This is useful for transitions between unique named nodes that that may not require any specific intermediate animation. This is how to avoid the transition graph from forcing "walk" to "run" to instead be a "walk" to "stand" to "run" transition.
keyvalues { [stuff] }
Add a keyvalue block (see $keyvalues) to a specific sequence.

Examples

Simple

$modelname		"weapons/shell.mdl"
$cdmaterials		"models/weapons/"
$body		shell	"shell-ref.smd"
$sequence	idle	"shell-idle.smd"

Advanced

$sequence run_holding_all
{
	a_runS a_runSE a_runE a_runNE a_runN_SMG a_runNW a_runW a_runSW a_runS
	blendwidth 9 blend move_yaw -180 180 addlayer layer_run_holding ACT_RUN_RIFLE 1 node "running"
}