Blend sequence: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 5: Line 5:
[[Image:Blend sequence controls.png|frame|[[HLMV]]'s 'Sequence' tab can control blends. This character is running backwards and aiming slightly upwards.]]
[[Image:Blend sequence controls.png|frame|[[HLMV]]'s 'Sequence' tab can control blends. This character is running backwards and aiming slightly upwards.]]


A '''Blend sequence''' is a <code>[[$sequence]]</code> that can move smoothly between up to nine sub-<code>[[$animation]]</code>s based on a one-dimensional 'blend scale' sliding value.
A '''Blend sequence''' is a <code>[[$sequence]]</code> that can move smoothly between <code>[[$animation]]</code>s based on one or two sliding 'blend scale' values. This allows the animation's state to be easily controlled by code.


This allows for precise programmatic positioning of parts of a model. For instance, you might create two blend sequences to handle the direction in which an NPC points a weapon - one for pitch and one for yaw. By changing the blends' [[float]] input values, any [[AI]] controlling the model will be able to aim at targets in the world.
Walking and aiming direction are almost always determined by blend sequences.
 
Another very common use for blend sequences is walking direction. A full 360 degrees can be blended between within the same sequence.


== Creating blend sequences ==
== Creating blend sequences ==


Blend sequences make use of the advanced form of <code>[[$sequence]]</code>, so you'll need to define some <code>[[$animation]]</code>s before you can begin.
The ideal number of animations in a blend sequence depends on how precise the motion needs to be, and on how much variation there is to be along the blend scale. Valve use nine for their walking blends (see the example below), but for blends that produce a still pose rather than an animation you can get away with one for each extreme. You may well find it easier to work with a third, central animation for the zero position too however.


Their ideal number depends on how precise the movement needs to be, and how much variation there is to be along the blend scale. Valve use nine for their walking blends (see the example below), but for blends that produce a still pose rather than an animation you can get away with one for each extreme. You may well find it easier to work with a third, central animation for the zero position too however.
Once you have your animations, simply list them within the sequence's keyvalue block in the desired order. They will be evenly distributed along the blend scale.


Once you have your $animations, simply list them within the $sequence's keyvalue block in the desired order. They will be evenly distributed along the blend scale.
;<code>blend <[[string]] name> <[[float]] min> <[[float]] max></code>
: Defines a blend controller. The first controller moves left/right through the blend, the second (if present) up/down.
;<code>blendwidth <[[int]] width></code>
: How many animations each row of the blend contains. The number of columns is determined automatically.


Incomplete...
=== Example ===


;<code>blend <[[string]]|name> <[[float]]|min value> <[[float]]|max value></code>
<source lang=php>
;<code>blendwidth <[[int]]|width></code>
// Define all nine walk_* $animations above this command
:"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."


=== Example ===
$sequence walk {
walk_NW  walk_N  walk_NE // line breaks are for readability only
walk_W    walk_C  walk_E
walk_SW  walk_S  walk_SE


[[$sequence]] walk_all {
blendwidth 3
a_walkS a_walkSE a_walkE a_walkNE a_walkN a_walkNW a_walkW a_walkSW a_walkS
  blend move_x -1 1
'''blendwidth 9'''
  blend move_y -1 1
  '''blend move_yaw -180 180'''
}
  ACT_WALK 1
</source>
node "walking"
}


== Animating for blend sequences ==
== Animating for blend sequences ==
Line 45: Line 46:
*[[$sequence]]
*[[$sequence]]
*[[$animation]]
*[[$animation]]
*[[$poseparameter]]


[[Category:Modeling]]
[[Category:Modeling]]
[[Category:Glossary]]
[[Category:Glossary]]

Revision as of 06:23, 1 July 2011

Stub

This article or section is a stub. You can help by expanding it.

A blend sequence altering the yaw of an NPC's aim. A second blend sequence will be needed to control pitch.
HLMV's 'Sequence' tab can control blends. This character is running backwards and aiming slightly upwards.

A Blend sequence is a $sequence that can move smoothly between $animations based on one or two sliding 'blend scale' values. This allows the animation's state to be easily controlled by code.

Walking and aiming direction are almost always determined by blend sequences.

Creating blend sequences

The ideal number of animations in a blend sequence depends on how precise the motion needs to be, and on how much variation there is to be along the blend scale. Valve use nine for their walking blends (see the example below), but for blends that produce a still pose rather than an animation you can get away with one for each extreme. You may well find it easier to work with a third, central animation for the zero position too however.

Once you have your animations, simply list them within the sequence's keyvalue block in the desired order. They will be evenly distributed along the blend scale.

blend <string name> <float min> <float max>
Defines a blend controller. The first controller moves left/right through the blend, the second (if present) up/down.
blendwidth <int width>
How many animations each row of the blend contains. The number of columns is determined automatically.

Example

// Define all nine walk_* $animations above this command

$sequence walk {
	walk_NW   walk_N   walk_NE // line breaks are for readability only
	walk_W    walk_C   walk_E
	walk_SW   walk_S   walk_SE

	blendwidth 3
 	blend move_x -1 1
 	blend move_y -1 1
}

Animating for blend sequences

To do...

Tip.pngTip:The $animations used in blends are usually still poses, as movement is generated by other animations that play on top. If they aren't, e.g. for walking blends, it is important that each $animation used is the same length and plays at the same framerate!

See also