Class AnimationController
Namespace: ValveResourceFormat.Renderer
Assembly: Renderer.dll
Drives a model's skeleton from whichever owns the animation being played: the model's own player, or the player of an external NM skeleton whose pose is remapped onto the model by bone name.
public class AnimationControllerInheritance
Constructors
AnimationController(Skeleton, FlexController[])
Initializes a new for the given skeleton and flex controllers, computing the bind pose and inverse bind pose matrices.
public AnimationController(Skeleton skeleton, FlexController[] flexControllers)Parameters
skeleton Skeleton
The skeleton whose bones define the rig.
flexControllers FlexController[]
The flex controllers used for facial/morph animation.
Properties
ActiveAnimation
Gets the currently active animation, or null if none is set.
public Animation? ActiveAnimation { get; }Property Value
ActiveClipFinished
Gets whether the active animation clip has finished playing.
public bool ActiveClipFinished { get; }Property Value
AnimationFrame
Gets the decoded animation frame data for the current tick, or null when no animation is active.
public Frame? AnimationFrame { get; }Property Value
ApplyAdditive
Gets or sets whether the active animation is composed over the bind pose.
public bool ApplyAdditive { get; set; }Property Value
BindPose
The skeleton skinning bind pose.
public Matrix4x4[] BindPose { get; }Property Value
Clips
Gets the clips of the player currently driving the pose.
public Dictionary<string, AnimationPlayer.PlaybackClip> Clips { get; }Property Value
Dictionary<string, AnimationPlayer.PlaybackClip>
CurrentPlayer
The player driving the pose when an external skeleton's animation is active, or null while the model's own skeleton is being animated.
public AnimationPlayer? CurrentPlayer { get; }Property Value
ExternalSkeletons
Gets the external skeletons registered for playback, indexed by skeleton name.
public IReadOnlyDictionary<string, AnimationController.ExternalSkeleton> ExternalSkeletons { get; }Property Value
IReadOnlyDictionary<string, AnimationController.ExternalSkeleton>
Frame
Gets or sets the current frame index of the active animation.
public int Frame { get; set; }Property Value
FrameCache
Gets the frame cache used to retrieve and interpolate frames on the model skeleton.
public AnimationFrameCache FrameCache { get; }Property Value
FrametimeMultiplier
Gets or sets the playback speed multiplier applied to the animation timestep.
public float FrametimeMultiplier { get; set; }Property Value
InverseBindPose
The skeleton inverse bind pose.
public Matrix4x4[] InverseBindPose { get; }Property Value
IsPaused
Gets or sets whether animation playback is paused. Changing the value forces a pose update.
public bool IsPaused { get; set; }Property Value
IsUsingMixer
Gets whether the current animation frame is the result of blending multiple clips together.
public bool IsUsingMixer { get; }Property Value
Looping
Gets or sets whether animations should loop when reaching the end.
public bool Looping { get; set; }Property Value
Pose
The flattened worldspace transform of each bone, according to the current animation frame.
public Matrix4x4[] Pose { get; }Property Value
ResolvePosition
Optional resolver from an attachment/bone name to a world position, used to place the sounds of animation events. TODO: rework this.
public Func<string, Vector3?>? ResolvePosition { get; set; }Property Value
Skeleton
The skeleton being animated.
public Skeleton Skeleton { get; }Property Value
Time
Gets or sets the current playback time in seconds.
public float Time { get; set; }Property Value
Transform
The parent animating transform.
public Matrix4x4 Transform { get; set; }Property Value
TwistConstraints
Gets or sets the tilt-twist skeleton constraints. These are not yet evaluated at runtime; only hardcoded first-person viewmodel constraints are currently applied (see ).
public TiltTwistConstraint[] TwistConstraints { get; set; }Property Value
Methods
ApplyConstraints()
Applies twist constraints to the current pose. Currently only hardcoded first-person viewmodel arm-twist constraints are applied (when is set); the configured array is not yet evaluated.
public void ApplyConstraints()ApplyFirstpersonLegs()
Hides bones from spine_0 and up (keeping the pelvis and legs visible).
public void ApplyFirstpersonLegs()ApplyInverseKinematics()
Applies inverse kinematics to the current pose.
public void ApplyInverseKinematics()ConsumeRootMotionDelta()
Takes the root motion the last advanced through, as a rigid transform to compose onto whatever the animation drives, and clears it. Identity when playback did not advance.
public Matrix4x4 ConsumeRootMotionDelta()Returns
GetFrame()
Returns the animation frame for the current time, using exact frame lookup when paused or interpolation during playback.
public Frame? GetFrame()Returns
The current animation frame, or null if no animation is active.
GetSkinningMatrices(Span<Matrix4x4>)
Get bone matrices in bindpose space. Bones that do not move from the original location will have an identity matrix. Thus there will be no transformation in the vertex shader.
public void GetSkinningMatrices(Span<Matrix4x4> modelBones)Parameters
IsPlayable(Animation)
Whether the animation can play correctly on this controller.
public bool IsPlayable(Animation animation)Parameters
animation Animation
Returns
PauseLastFrame()
Pauses playback and seeks to the last frame of the active animation.
public void PauseLastFrame()RegisterBoneMask(string, Dictionary<string, float>, string?)
Registers a bone mask for per-bone transform weighting.
public void RegisterBoneMask(string name, Dictionary<string, float> boneWeights, string? skeletonName = null)Parameters
name string
The name of the bone mask.
boneWeights Dictionary<string, float>
Dictionary mapping bone names to weight values (0.0 to 1.0).
skeletonName string?
Optional external skeleton to register the mask on.
RegisterExternalSkeleton(string, Skeleton)
Registers an external skeleton animations can be played on, creating a bone remapping table.
public void RegisterExternalSkeleton(string skeletonName, Skeleton skeleton)Parameters
skeletonName string
The name identifying the external skeleton.
skeleton Skeleton
The external skeleton to register.
RegisterUpdateHandler(Action<Animation?, int>)
Registers a callback invoked each time the animation frame changes, receiving the active animation and frame index.
public void RegisterUpdateHandler(Action<Animation?, int> handler)Parameters
handler Action<Animation?, int>
The callback to invoke on each animation update.
SetAnimation(Animation?)
Sets the active animation, resets playback to frame zero, and clears the frame cache.
public void SetAnimation(Animation? animation)Parameters
animation Animation?
The animation to activate, or null to clear.
SetAnimation(Animation?, float, bool)
Sets the active animation with a blend-in time for smooth transitions, playing it on the external skeleton it targets when it has one.
public void SetAnimation(Animation? animation, float blendTime, bool warp = false)Parameters
animation Animation?
The animation to activate, or null to clear.
blendTime float
The time in seconds to blend from previous animations to the new animation.
warp bool
Whether re-activating the animation already playing should cross over into a second instance of it rather than restarting it in place.
SetAnimationProperties(string, float?, bool?, string?)
Sets properties for a clip with the specified animation name.
public void SetAnimationProperties(string name, float? time = null, bool? looping = null, string? boneMask = null)Parameters
name string
The name of the animation.
time float?
Optional playback time to set.
looping bool?
Optional looping flag to set.
boneMask string?
Optional bone mask name to set.
SetAnimationWeight(string, float, bool)
Sets the blend weight for a clip with the specified animation name.
public void SetAnimationWeight(string name, float weight, bool restartIfNew = false)Parameters
name string
The name of the animation.
weight float
The weight value (0.0 to 1.0).
restartIfNew bool
Whether to restart the animation if it's just now fading in.
Update(float)
Advances the animation by timeStep seconds and recomputes bone poses.
public bool Update(float timeStep)Parameters
timeStep float
Elapsed time in seconds since the last update.

