Class AnimationController
Namespace: ValveResourceFormat.Renderer
Assembly: Renderer.dll
Drives a model's skeleton from whichever AnimationPlayer 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
object ← AnimationController
Constructors
AnimationController(Skeleton, FlexController[], ClothRootPin[])
Initializes a new AnimationController for the given skeleton and flex controllers, computing the bind pose and inverse bind pose matrices.
public AnimationController(Skeleton skeleton, FlexController[] flexControllers, ClothRootPin[] clothRootPins)Parameters
skeleton Skeleton
The skeleton whose bones define the rig.
flexControllers FlexController[]
The flex controllers used for facial/morph animation.
clothRootPins ClothRootPin[]
The pins that hold procedural cloth roots to their animated anchor bones.
Properties
ActiveAnimation
Gets the currently active animation, or null if none is set.
public AnimationBase? ActiveAnimation { get; }Property Value
ActiveClipFinished
Gets whether the active animation clip has finished playing.
public bool ActiveClipFinished { get; }Property Value
bool
AnimationFrame
Gets the decoded animation frame data for the current tick, or null when no animation is active.
public Frame? AnimationFrame { get; }Property Value
AnimationLookup
Optional resolver from an animation or sequence name to the loaded ValveResourceFormat.Animation, used to resolve an auto layer's AnimationAutoLayer.ReferencedAnimationName.
public Func<string, AnimationBase?>? AnimationLookup { get; set; }Property Value
Func<string, AnimationBase?>?
ApplyAdditive
Gets or sets whether the active animation is composed over the bind pose.
public bool ApplyAdditive { get; set; }Property Value
bool
BindPose
The skeleton skinning bind pose.
public Matrix4x4[] BindPose { get; }Property Value
BoneConstraints
Gets or sets the bone constraints evaluated on the pose after each update.
public BoneConstraintSolver? BoneConstraints { get; set; }Property Value
Clips
Gets the clips of the player currently driving the pose.
public IReadOnlyDictionary<string, AnimationPlayer.PlaybackClip> Clips { get; }Property Value
IReadOnlyDictionary<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
EnableConstraints
Gets or sets whether the bone constraints are evaluated after each pose update.
public bool EnableConstraints { get; set; }Property Value
bool
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>
FlexValues
Gets the flex controller values of the current frame with the morph driving constraints applied, or the frame's own values when no constraint writes morphs.
public float[]? FlexValues { get; }Property Value
float[]?
Frame
Gets or sets the current frame index of the active animation.
public int Frame { get; set; }Property Value
int
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
float
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
bool
JiggleBones
Gets or sets the jiggle bones simulated on the pose on every update that advances time.
public JiggleBoneSolver? JiggleBones { get; set; }Property Value
Looping
Gets or sets whether animations should loop when reaching the end.
public bool Looping { get; set; }Property Value
bool
ModelToWorld
Gets or sets the transform from model space to world space that the jiggle bones are simulated in.
public Matrix4x4 ModelToWorld { get; set; }Property Value
Pose
The flattened worldspace transform of each bone, according to the current animation frame.
public Matrix4x4[] Pose { get; }Property Value
PoseParameters
Gets the pose parameters registered on the model player.
public IReadOnlyCollection<PoseParameter> PoseParameters { get; }Property Value
IReadOnlyCollection<PoseParameter>
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
float
Transform
The parent animating transform.
public Matrix4x4 Transform { get; set; }Property Value
Methods
ApplyConstraints()
Evaluates the bone constraints on the current pose, and the morph driving ones on the frame's flex controller values.
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 AnimationController.Update(float) 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.
GetPoseParameter(string)
Gets the live value of a pose parameter, or zero for one that was never set.
public float GetPoseParameter(string name)Parameters
name string
Returns
float
IsPlayable(AnimationBase)
Whether the animation can play correctly on this controller.
public bool IsPlayable(AnimationBase animation)Parameters
animation AnimationBase
Returns
bool
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.
RegisterMorphMask(string, Dictionary<string, float>)
Registers a morph mask for per-flex-controller weighting on the model player.
public void RegisterMorphMask(string name, Dictionary<string, float> controllerWeights)Parameters
name string
The name of the morph mask.
controllerWeights Dictionary<string, float>
Dictionary mapping flex controller names to weight values.
RegisterPoseParameter(PoseParameter)
Registers a pose parameter a blend sequence positions its animations along, on the model player.
public void RegisterPoseParameter(PoseParameter parameter)Parameters
parameter PoseParameter
RegisterUpdateHandler(Action<AnimationBase?, int>)
Registers a callback invoked each time the animation frame changes, receiving the active animation and frame index.
public void RegisterUpdateHandler(Action<AnimationBase?, int> handler)Parameters
handler Action<AnimationBase?, int>
The callback to invoke on each animation update.
SetAnimation(AnimationBase?)
Sets the active animation, resets playback to frame zero, and clears the frame cache.
public void SetAnimation(AnimationBase? animation)Parameters
animation AnimationBase?
The animation to activate, or null to clear.
SetAnimation(AnimationBase?, 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(AnimationBase? animation, float blendTime, bool warp = false)Parameters
animation AnimationBase?
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.
SetAnimationGraph(IAnimationGraph?)
Attaches an animation graph as the pose source, playing it on the player of the skeleton the graph animates: the model's own, or an external one registered if needed. Pass null to detach the graph from the current player and return to clip playback.
public void SetAnimationGraph(IAnimationGraph? graph)Parameters
graph IAnimationGraph?
The animation graph to play, or null to detach.
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.
SetPoseParameter(string, float)
Sets the live value of a registered pose parameter, clamped to its range.
public void SetPoseParameter(string name, float value)Parameters
name string
value float
StepGraph(float)
Advances the attached animation graph by one step on the next update while AnimationController.IsPaused, as that frame's only update.
public void StepGraph(float timeStep)Parameters
timeStep float
How far to advance, in seconds, before AnimationController.FrametimeMultiplier.
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.
Returns
bool

