Class AnimationGraph
Namespace: ValveResourceFormat.ResourceTypes.ModelAnimation2
Assembly: ValveResourceFormat.dll
Runtime instance of an animation graph (.vnmgraph). Evaluates the graph's node network on the graph's NM skeleton each update and produces a parent space pose.
public class AnimationGraph : IAnimationGraphInheritance
object ← AnimationGraph
Implements
Constructors
AnimationGraph(BinaryKV3, IFileLoader)
Loads the graph definition, its skeleton and all referenced animation clips.
public AnimationGraph(BinaryKV3 graphDefinition, IFileLoader fileLoader)Parameters
graphDefinition BinaryKV3
The graph definition resource data.
fileLoader IFileLoader
Loader used to resolve the skeleton and clip resources.
Exceptions
A graph of the tree animates a skeleton the loader cannot provide.
Fields
ExceptionDataKey
The key under which a failing update stores AnimationGraph.DescribeState() in the exception data.
public const string ExceptionDataKey = "Animation graph state"Field Value
string
Properties
Algorithm
Gets the kind of graph.
public AnimationAlgorithm Algorithm { get; }Property Value
BoolParameters
Gets the boolean control parameters by name.
public Dictionary<string, bool> BoolParameters { get; }Property Value
Dictionary<string, bool>
ChildGraphs
Referenced child graphs, index-aligned with AnimationGraph.DataSlots: one instance per graph resource reference, null for other resource types (or on a recursive reference).
public AnimationGraph?[] ChildGraphs { get; }Property Value
DataSlots
The graph's data slots: one entry per resource reference. Clip resources get a sampleable GraphClip; other resource types are null.
public GraphClip?[] DataSlots { get; }Property Value
GraphClip?[]
FloatParameters
Gets the float control parameters by name.
public Dictionary<string, float> FloatParameters { get; }Property Value
Dictionary<string, float>
GraphSkeleton
The graph library's view of the skeleton (reference pose, bone masks).
public Skeleton GraphSkeleton { get; }Property Value
GraphTimings
Gets how long the last update took for this graph, first, and each referenced graph it evaluated, in evaluation order, while AnimationGraph.RecordUpdateDetails is set.
public IReadOnlyList<GraphTiming> GraphTimings { get; }Property Value
IdParameters
Gets the ID (symbol) control parameters by name.
public Dictionary<string, string> IdParameters { get; }Property Value
Dictionary<string, string>
Name
Gets the display name of the graph (file name and variation).
public string Name { get; }Property Value
string
ParameterHints
Gets, for target and vector parameters read by IK or look-at nodes, the value that would leave the pose as animated. Refreshed on every update.
public Dictionary<string, GraphParameterHint> ParameterHints { get; }Property Value
Dictionary<string, GraphParameterHint>
ParameterNames
Gets the control parameter names, indexed by control parameter node index.
public string[] ParameterNames { get; }Property Value
string[]
ParentSpaceReferencePose
Parent-space reference (bind) pose of the NM skeleton.
public FrameBone[] ParentSpaceReferencePose { get; }Property Value
RecordUpdateDetails
Gets or sets whether updates record the clips they sample and how long each graph took, including referenced graphs, for AnimationGraph.SampledClips and AnimationGraph.GraphTimings. Off by default.
public bool RecordUpdateDetails { get; set; }Property Value
bool
RootMotionDelta
Gets the root motion of the last update, in the character's local space: the new world transform is this delta concatenated onto the previous one.
public FrameBone RootMotionDelta { get; }Property Value
SampledClips
Gets the clips the last update sampled, in sampling order, while AnimationGraph.RecordUpdateDetails is set.
public IReadOnlyList<SampledClip> SampledClips { get; }Property Value
SampledEvents
Gets the events the last update sampled, from the states and clips of this graph and of the graphs it references.
public SampledEventsBuffer SampledEvents { get; }Property Value
Skeleton
Gets the NM skeleton (.vnmskel) this graph animates.
public Skeleton Skeleton { get; }Property Value
SkeletonName
Gets the resource name of the graph's skeleton, matching the external skeleton registration key.
public string SkeletonName { get; }Property Value
string
TargetParameters
Gets the target (bone transform) control parameters by name. A null value leaves the target unset, which turns off the IK reading it.
public Dictionary<string, FrameBone?> TargetParameters { get; }Property Value
Dictionary<string, FrameBone?>
UpdateDetails
Gets what the last update recorded, when AnimationGraph.RecordUpdateDetails is set.
public GraphUpdateDetails? UpdateDetails { get; }Property Value
VectorParameters
Gets the vector control parameters by name.
public Dictionary<string, Vector4> VectorParameters { get; }Property Value
Dictionary<string, Vector4>
WorldTransform
Gets the transform the graph treats as its world space, the root motion accumulated so far.
public FrameBone WorldTransform { get; }Property Value
Methods
DescribeState()
Describes the parameter values and the active states of this graph and its referenced graphs.
public string DescribeState()Returns
string
DescribeUpdatingGraph()
Gets the state of the graph being updated on the calling thread, for reports of a failure raised from inside the update, or null outside of one.
public static string? DescribeUpdatingGraph()Returns
string?
GetFloatParameterRange(string)
Gets the span of values the graph and its child graphs read a float parameter over, or null when nothing in the graph bounds it.
public FloatParameterRange? GetFloatParameterRange(string parameterName)Parameters
parameterName string
Returns
GetParameterIdOptions(string)
Gets the known values for an ID parameter: the IDs the graph and its child graphs compare it with, select on or map from, including through cached, virtual and switched values.
public IEnumerable<string> GetParameterIdOptions(string parameterName)Parameters
parameterName string
Returns
IEnumerable<string>
SignalBoolParameter(string)
Pulses a boolean control parameter as a one-shot "signal": the value reads as true for the next graph update, then returns to the value it held. Use for trigger parameters (e.g. action_reset) that would otherwise re-fire every frame while held true.
public void SignalBoolParameter(string name)Parameters
name string
TryLoad(BinaryKV3, IFileLoader, Func<string, ClipAnimation?>?)
Loads the graph like the constructor does, or returns null when a graph of the tree animates a skeleton the loader cannot provide, as unshipped work in progress graphs do.
public static AnimationGraph? TryLoad(BinaryKV3 graphDefinition, IFileLoader fileLoader, Func<string, ClipAnimation?>? loadedClips = null)Parameters
graphDefinition BinaryKV3
The graph definition resource data.
fileLoader IFileLoader
Loader used to resolve the skeleton and clip resources.
loadedClips Func<string, ClipAnimation?>?
Clips already loaded elsewhere, such as by the model playing the graph, looked up by resource name and used instead of reading them again.
Returns
Update(float, FrameBone)
Advances the graph by timeStep seconds and returns the resulting parent space pose, owned by the graph and valid until the next update.
public FrameBone[] Update(float timeStep, FrameBone worldTransform)Parameters
timeStep float
The time to advance, in seconds.
worldTransform FrameBone
Where the root motion has moved the character so far.

