$animation

From Valve Developer Community
Jump to navigation Jump to search

Stub

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

The QC command $animation is used when you're creating a sequence that uses multiple source animations, but where you may need different options - such as frame numbers, alignment, etc. - on each of the different animations.

Syntax

$animation <anim_name> "<file>" <options>

where

<anim_name>
When creating your sequence, refer to the animations by name instead of by filename.
<file>
Todo: name of animation source file (.mdl/.ani) ?
<options>
see below.

$animation options

frame <start_frame> <end_frame>
Sets which frames from the animation file are used for this animation
frames <start_frame> <end_frame>
Same as frame
fixuploop <pre_loop_frames> <post_loop_frames>
This finds the difference between the last frame and the first frame in the animation and blends the difference across the boundary. The range from some negative value (number of frames back from the last frame) to 0, and ranges from 0 to some positive number of frames after the first frame.
This is useful when building a looping animation out of a portion of a non-looping animation, or even cleaning up a animation that is supposed to loop but has a slight hitch.
alignto <goal_animation>
This will shift the current animation so that the root position of the first <local> frame matches the root position <X and Y axis only> of the first (local) frame of another animation. This is useful when animations don't start on the origin, or when you're cutting out just a small piece of a longer source animation and you need a quick way to get it aligned to a shared origin.
align <reference_animation> <X Y Z XR YR ZR> <reference_frame> <to_match_frame>
This is similar to alignto, except that you can specify how the two animations are to match, and that the <to match frame> on the animation is aligned with the <reference frame> of the <reference animation>. This is useful when aligning animations with vertical motion.
alignboneto <bone_name> <goal_animation>
Same as alignto, but will match the specified bone instead of the root.
startloop <local_frame>
This resets the starting frame of a looping animation. This is useful when creating sequences that have multiple animations and the animations need to all run together in phase, but the source animations don't all quite match.
All animations default to a weightlist that assumes all bones have a weight of 1.0. Only the bones with a weight > 0 will have any influence over the animation. QC specified weightlists:
    $weightlist no_hands "Bip01" 1.0 "Bip01 L Hand" 0.0 "Bip01 R Hand" 0.0
    $weightlist head_n_arms "Bip01 Spine 2" 1.0
fudgeloop
Looping animations, at least ones with movement, need the first and last frames to match position <ideally> as well as have movement. The reason for this is that studiomdl needs to tell the engine exactly how far to move the model between the "last" unique keyframe and the "first" keyframe when calculating those last tween frames. Since this last little 1/30th or 1/10th of a second distance is probably not exactly the same distance as the previous keyframe nor is probably exactly the same distance as the average per-frame movement, skipping the definition of the overlap can cause a hitch or foot slide during playback if studiomdl guesses wrong.
If for some serious reason the animator can't create the last frame overlap, then this option tells studiomdl to assume the movement is the average per-frame motion seen so far in the animation, and that it needs to create the overlapping frame itself.
weightlist <weightlist_name>
This copies a predefined list of bone weights to the current animation. You can do this any number of times per animation, which can be useful since subsequent options subtract, match, and fixuploop options only operate on bones with weights > 0. The last specified weightlist option is the one the animation system uses when doing blending. Sequences that use multiple animations need to have all their source animations use the same weightlist or the results are undefined.
subtract <animation> <frame_number>
This subtracts the specified frame of the specified animation from all the frames of the current animation and creates an animation that is the differences between the two, effectively converting the animation to just be the changes from a reference frame of another animation.
This also creates something that can be used as a "delta" animation. The easiest way to think of these are that they’re just fancy bonecontrollers, but ones that have multiple bones and can be a time sequence animation. The resulting animations by themselves are meaningless and are only valid when played on top of other animations.
presubtract <animation>
This subtracts all the frames of the current animation from the first frame of the specified animation and creates an animation that is the differences between the two.
match <animation>
Makes the first frame of the animation match the first frame of the specified animation, and then applies the difference between the two frames to all subsequence frames. This is mainly used to correct animations that are supposed to start at a common pose but don’t for some uncontrollable reason.
walkframe <frame> <LX LY LZ LXR LYR LZR>
You can set up to 16 of these per animation to specify linear piecewise movement. Matches root bone from the previous walkframe command – defaults to frame 0 – to the specified frame of each segment, extracting linear motion between each.
walkalignto <frame> <reference animation> <LX LY LZ LXR LYR LZR>
Like walkframe, but at extracts motion such that at <frame>, the model is aligned to the specified <reference animation>. This is useful when trying to extract the motion inside a animation that’s used to transition between two existing animations.
walkalign <frame> <reference animation> <LX LY LZ LXR LYR LZR> <reference frame> <to match frame>
Like walkalignto, but motion is calculated such that the <to match frame> matches the <reference frame> of the <reference animation>. This is useful when the last frame being used to extract motion over doesn’t quite match a goal animation, but a subsequent frame does.
rotateto <angle>
Finds the current direction of movement <uses the first movement if there are multiple pieces>, then rotates the animation so that the resulting movement is in the specified direction.
noanimation
Makes the animation additive, removes all the animation, zero’s out the weight list and sets a flag so that at run time the engine will skip all processing of the if it’s the only thing contributing to the sequence. This is handy for blended sequences where the "zero" position should have no effect on the model.
derivative <scale>
Turns the animation into the derivative of itself by simply subtracting the previous frame from each frame in the animation. The derivative can be automatically scaled to compensate for any fps issues.
lineardelta
Turns the animation into a delta animation, by subtracting a linear blend of the first and last frames from each frame of the animation.
splinedelta
Turns the animation into a delta animation, by subtracting a spline (s-curve) blend of the first and last frames from each frame of the animation.
compress <skip>
Turns a animation into a lower fps version of itself by only using every Nth frame. Automatically converts specified fps values into new equivalent.
numframes <frames>
Forces an animation to be a specified number of frames, either by clipping the animation or by duplicating the last frame until it has been padded with enough.