Class Animation
Namespace: ValveResourceFormat.ResourceTypes.ModelAnimation
Assembly: ValveResourceFormat.dll
Represents a model animation that can be sampled per frame.
public abstract class AnimationInheritance
Derived
ClipAnimation, SequenceAnimation
Properties
CycleDuration
Gets the length of one playback cycle in seconds, the period looping wraps around. Zero when the animation is a single pose or carries no frame rate.
public float CycleDuration { get; }Property Value
CycleFrames
Gets the number of frame intervals one playback cycle spans. Looping wraps over the intervals between samples, so the last frame is where the next cycle starts rather than a sample of its own.
public int CycleFrames { get; }Property Value
Duration
Gets the duration of the animation in seconds, which is also the period looping playback wraps around.
public virtual float Duration { get; }Property Value
Fps
Gets the frames per second of the animation.
public float Fps { get; protected init; }Property Value
FrameCount
Gets the total number of frames in the animation.
public int FrameCount { get; protected init; }Property Value
HasFlexData
Gets whether decoding this animation writes any flex controller data.
public virtual bool HasFlexData { get; }Property Value
IsAdditive
Gets or sets whether this animation is additive: its frames are per-bone deltas meant to be composed over a base pose. AG2 clips and AG1 sequences both carry what their own data says; the owning model then adds the sequences its AG1 graph feeds into additive slots, which is not knowable from the animation alone.
public bool IsAdditive { get; set; }Property Value
Name
Gets the name of the animation.
public string Name { get; protected init; }Property Value
TargetSkeletonName
Gets the resource name of the skeleton this animation is authored on. A model's own skeleton is named after the vmdl it came from, so animations on it carry that name.
public string TargetSkeletonName { get; protected init; }Property Value
Methods
ComposeAdditiveOverBindPose(FrameBone[], Skeleton)
Composes an already-decoded additive frame over the skeleton bind pose, in place.
public void ComposeAdditiveOverBindPose(FrameBone[] bones, Skeleton skeleton)Parameters
bones FrameBone[]
skeleton Skeleton
DecodeFrame(Frame)
Decodes animation data for the specified frame.
public abstract void DecodeFrame(Frame outFrame)Parameters
outFrame Frame
GetAdditiveDelta(int, FrameBone)
The delta a decoded bone of an additive frame contributes, in the one convention everything composing deltas expects: add the position and the scale, post-multiply the rotation. The two formats do not decode to that convention on their own, which is what this reconciles.
public abstract FrameBone GetAdditiveDelta(int boneIndex, FrameBone bone)Parameters
boneIndex int
bone FrameBone
Returns
GetCyclePosition(float)
Splits a playback time into the number of whole cycles already played, the frame reached within the current one, and how far past that frame the time sits. Everything that samples an animation over time goes through this, so the pose, the root motion and the loop counting cannot drift apart.
public (int Cycle, int Frame, float Remainder) GetCyclePosition(float time)Parameters
time float
Returns
(int Cycle, int Frame, float Remainder)
Remarks
The frame is relative to the current cycle, and stops one short of so the frame after it is always a valid sample to interpolate towards; the remainder reaches one at the end. A cycle owns the moment it ends, so a clip parked on its end holds its last frame rather than reading as frame zero of a cycle it never entered.
GetMovementOffsetData(float)
Returns interpolated root motion data at the specified time.
public abstract AnimationMovement.MovementData GetMovementOffsetData(float time)Parameters
time float
Returns
AnimationMovement.MovementData
GetMovementOffsetData(int)
Returns interpolated root motion data at the specified frame.
public abstract AnimationMovement.MovementData GetMovementOffsetData(int frame)Parameters
frame int
Returns
AnimationMovement.MovementData
GetRootMotionDelta(float, float)
The root motion advanced through between two playback times, as a rigid transform (yaw about Z plus translation) to compose onto whatever the animation drives.
public Matrix4x4 GetRootMotionDelta(float fromTime, float toTime)Parameters
fromTime float
toTime float
Returns
Remarks
Looping is unrolled rather than replayed: a step crossing the loop point runs out its cycle and carries on from the start of the next. Samples are the root's transform per frame rather than a delta from its start, and composing them this way cancels out the clip's own starting offset. Stepping backwards gives the forward step undone.
HasMovementData()
Determines whether this animation has movement data.
public abstract bool HasMovementData()Returns
SnapTimeToFrame(float)
The playback time of the whole frame nearest time, staying in the cycle being played. Sampling an exact frame rather than interpolating moves playback by up to half a frame, and this is what says where to.
public float SnapTimeToFrame(float time)Parameters
time float
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()Returns
A string that represents the current object.
Remarks
Returns the animation name.

