Source 2 Animation System VScript API/CModelVScriptCompile.CreateSequence

From Valve Developer Community
Jump to: navigation, search

Function Description

IVSSequence CModelVScriptCompile::CreateSequence(table parameters)

Generates a new animation sequence in the model. The generated sequences can be used the same way as animations imported to the model from external software.

Parameters that take sequence names also accept imported animations.


Example
-- Creates a new sequence named "my_sequence", imports the first two frames from the animation "my_animation" and switches their order.
model:CreateSequence(
	{
		name = "my_sequence",
		fadeInTime = 0.2,
		fadeOutTime = 0.2,
		fps = 30,
		cmds = {
			{ cmd = "fetchframe", sequence = "my_animation", frame = 0, dst = 1 },
			{ cmd = "fetchframe", sequence = "my_animation", frame = 1, dst = 0 },
		}
	}
)

Parameters

Type Name Description
table parameters Sequence parameters (see below).

Returns

IVSSequence - Handle of the created sequence.

Sequence Parameters

The parameters are added as keys in the parameters table. Many of the parameters used are analogues to the $animation and $sequence QC commands used in Source 1.

To do: This list is likely incomplete.

Name Type Description
name string The name of the sequence. (Required)
activities array List of activities to link the sequence to. Syntax: { { < name = "$" >, < weight = "#" > }, ... }
addlayer array Adds a list of sequences to play when this one plays.
animevents array Adds a list of Animation Events. Syntax: { { < name|event = "$" >, < frame|cycle = # > [, option = "$" ] }, ... }
autoplay bool Makes the sequence play at all times, on top of any other animations, no matter what the model is doing.
blendlayer array To do Possible syntax: { { < sequence = "$" >, < startframe = # >, < peakframe = # >, < tailframe = # >, < endframe = # > }, ... }
cmds array Adds a list of commands to run. See below for a list of commands. Syntax: { { < cmd = "$" >, ... }, ... }
delta bool Tells the animation system that the sequences referenced in this sequence have all been subtracted.

The sequence will be played on top of whatever sequences are currently playing, rather than overriding them.

fadeintime float Override how long this animation spends fading in. Default is 0.2.
fadeouttime float Override how long this animation spends fading out. Default is 0.2.
fps int Sets the animations speed in frames per second.
framecacheable
framerangesequence string To do: Possibly sets the sequence length to that of the specified sequence
hidden bool Prevents the sequence from being listed in user interfaces. Useful for sequences which serve only as layers of others.
ikLocks array Adds a list of IK locks to the sequence. Possible syntax: { { < bone= "$" >, < posWeight= # >, < rotWeight= # > }, ... }
looping bool Makes the sequence loop from the first frame.
node
numframes
poseParamX string or int Adds a pose parameter to the sequence, either by index or name.
poseParamY string or int Adds a second pose parameter to the sequence. poseParamX must also be specified
sequences array Sequences to be included in this one. Also used to set a matrix of sequences for pose parameters to blend between. Syntax: { { < sequence_name >, ... }, ... }
snap bool 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 model's state, such as a creature flinching or a weapon firing.

transition array Syntax: { { < entry = "$" >, < exit = "$" > }, ... }
weightlist string or int Adds a weightlist created with CModelVScriptCompile::CreateWeightlist() to the sequence.


Commands

These commands are used in the cmds parameter.

To do: This list is likely incomplete.

Name Syntax Description
add { cmd = "add", dst = #, src = # } Adds two frames together and stores the result in dst.
blend
copy
fetchcycle { cmd = "fetchcycle", sequence = "$", cycle = #, dst = # }
fetchframe { cmd = "fetchframe", sequence = "$", frame = #, dst = # } Fetches a frame from the specified sequence.
fetchframerange { cmd = "fetchframerange", sequence = "$", startframe = #, endframe = #, dst = # } Fetches a number of frames from the specified sequence and places them at the offset specified by dst.
iklockinplace
ikrestoreall
lineardelta
nop {cmd = "nop"} To do To do: No operation ?
reversesequence { cmd = "reversesequence", sequence = "$", dst = # }
scale
sequence { cmd = "sequence", sequence = "$", dst = # },
slerp { cmd = "slerp", dst = #, src = # }
subtract { cmd = "subtract", dst = #, src = # } Subtracts the destination frame from the source frame and places the result in dst.
transform
worldspace { cmd = "worldspace", dst = #, src = #, weightlist = ? }