Class AnimationPlayer
Namespace: ValveResourceFormat.Renderer
Assembly: Renderer.dll
Plays animations on a single skeleton: advances clip time, mixes the weighted clips into a frame and writes that frame's world-space pose. An AnimationController owns one player per skeleton its model can be animated from.
public class AnimationPlayerInheritance
object ← AnimationPlayer
Constructors
AnimationPlayer(Skeleton, FlexController[], Matrix4x4[], Matrix4x4[])
Initializes a new AnimationPlayer for the given skeleton and flex controllers. The bind pose and pose buffers are supplied by the owner and may be shared with it.
public AnimationPlayer(Skeleton skeleton, FlexController[] flexControllers, Matrix4x4[] bindPose, Matrix4x4[] pose)Parameters
skeleton Skeleton
The skeleton whose bones define the rig.
flexControllers FlexController[]
The flex controllers used for facial/morph animation.
bindPose Matrix4x4[]
The skeleton's world-space bind pose, one entry per bone.
pose Matrix4x4[]
The pose buffer to write into, one entry per bone.
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 (is not looping and has reached the end).
public bool ActiveClipFinished { get; }Property Value
bool
Algorithm
Gets what drives the pose: the attached graph, the clips, or nothing.
public AnimationAlgorithm Algorithm { 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
AnimationLookup
Optional resolver from an animation or sequence name to the loaded ValveResourceFormat.Animation.
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. Seeded from the animation's additive flag on activation. Changing the value forces a pose update.
public bool ApplyAdditive { get; set; }Property Value
bool
BindPose
Gets the skeleton's world-space bind pose.
public Matrix4x4[] BindPose { get; }Property Value
Clips
Gets the current clips. Use AnimationPlayer.ClearClips() to empty them.
public IReadOnlyDictionary<string, AnimationPlayer.PlaybackClip> Clips { get; }Property Value
IReadOnlyDictionary<string, AnimationPlayer.PlaybackClip>
Frame
Gets or sets the current frame index of the active animation. Seeking stays within the cycle being played, so scrubbing a looping animation does not unwind earlier cycles.
public int Frame { get; set; }Property Value
int
FrameCache
Gets the frame cache used to retrieve and interpolate animation frames.
public AnimationFrameCache FrameCache { get; }Property Value
Graph
Gets the animation graph driving this player, or null when clips drive it.
public IAnimationGraph? Graph { 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
Pose
Gets the world-space transform of each bone for the current animation frame.
public Matrix4x4[] Pose { get; }Property Value
ResolvePosition
Gets or sets the resolver from an attachment name to a world position, an empty name being the model itself.
public Func<string, Vector3?>? ResolvePosition { get; set; }Property Value
RootMotionDelta
Gets the root motion the active clip has moved through since this was last consumed, as a rigid transform. Seeking contributes too, backwards as the motion in reverse.
public Matrix4x4 RootMotionDelta { get; }Property Value
Skeleton
Gets the skeleton this player animates.
public Skeleton Skeleton { get; }Property Value
Time
Gets or sets the current playback time in seconds.
public float Time { get; set; }Property Value
float
Methods
ClearClips()
Clears all clips and blend state.
public void ClearClips()ConsumeRootMotionDelta()
Takes AnimationPlayer.RootMotionDelta and clears it, so a caller running at a different rate than the animation neither applies a step twice nor loses one.
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 registered or set.
public float GetPoseParameter(string name)Parameters
name string
Returns
float
PrewarmAnimationSounds(AnimationBase)
Pre-decodes every sound the animation's events can play. Call when the animation is loaded.
public static void PrewarmAnimationSounds(AnimationBase animation)Parameters
animation AnimationBase
RegisterBoneMask(string, Dictionary<string, float>)
Registers a bone mask for per-bone transform weighting.
public void RegisterBoneMask(string name, Dictionary<string, float> boneWeights)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).
RegisterMorphMask(string, Dictionary<string, float>)
Registers a morph mask for per-flex-controller weighting. A controller not named defaults to 1.
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, with its live value at zero clamped into range.
public void RegisterPoseParameter(PoseParameter parameter)Parameters
parameter PoseParameter
SetAnimation(AnimationBase?, float, bool, bool)
Sets the active animation with a blend-in time for smooth transitions.
public void SetAnimation(AnimationBase? animation, float blendTime, bool looping, 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.
looping bool
Whether the clip should loop when reaching the end.
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.
SetGraph(IAnimationGraph?)
Attaches an animation graph as this player's pose source, replacing any playing clips. Pass null to detach and return to clip playback.
public void SetGraph(IAnimationGraph? graph)Parameters
graph IAnimationGraph?
SetPoseParameter(string, float)
Sets the live value of a pose parameter, clamped to its range when it was registered, and forces the next AnimationPlayer.Update(float, Matrix4x4) to recompute the pose.
public void SetPoseParameter(string name, float value)Parameters
name string
value float
Update(float, Matrix4x4)
Advances the animation by timeStep seconds and writes the skeleton's world-space pose under rootTransform.
public bool Update(float timeStep, Matrix4x4 rootTransform)Parameters
timeStep float
Elapsed time in seconds since the last update.
rootTransform Matrix4x4
The transform applied to the skeleton roots.
Returns
bool
true if the pose was updated; false if nothing changed.
ClipEventFired
Raised for every event of an animation graph clip crossed while the player advances its clips. Consumers filter for the event types they handle.
public event Action<Event>? ClipEventFiredEvent Type
SequenceEventFired
Raised for every event of a sequence animation crossed while the player advances its clips. Kept apart from AnimationPlayer.ClipEventFired because sequence events are a struct, which handing to a delegate of their shared interface would box on every fire.
public event Action<AnimationEvent>? SequenceEventFired
