Class ModelSceneNode
Namespace: ValveResourceFormat.Renderer.SceneNodes
Assembly: Renderer.dll
Anchors other scene nodes to this model, at an attachment point, at a bone, or at the model itself.
public class ModelSceneNode : MeshCollectionNodeInheritance
object ← SceneNode ← MeshCollectionNode ← ModelSceneNode
Derived
Inherited Members
MeshCollectionNode.RenderableMeshes, SceneNode.Tint, SceneNode.Alpha, SceneNode.TintAlpha, SceneNode.Transform, SceneNode.LayerName, SceneNode.LayerEnabled, SceneNode.Visible, SceneNode.BoundingBox, SceneNode.LocalBoundingBox, SceneNode.Name, SceneNode.Id, SceneNode.IsSelected, SceneNode.IsPointMarker, SceneNode.Flags, SceneNode.AdditionalFlags, SceneNode.RenderPasses, SceneNode.UpdateBuffers(Camera), SceneNode.Scene, SceneNode.KeepsMarkerSize, SceneNode.Parent, SceneNode.Children, SceneNode.ParentAttachment, SceneNode.LocalTransform, SceneNode.SetParent(SceneNode?, string?, Matrix4x4?), SceneNode.GetChildFrame(string?), SceneNode.UpdateHierarchy(Scene.UpdateContext), SceneNode.GetRigidTransform(Matrix4x4), SceneNode.ShaderEnvMapVisibility, SceneNode.LightingOrigin, SceneNode.OverlayRenderOrder, SceneNode.CubeMapPrecomputedHandshake, SceneNode.LightProbeVolumePrecomputedHandshake, SceneNode.LightProbeBinding, SceneNode.EnvMapBinding, SceneNode.EntityData, SceneNode.EntityInstance, SceneNode.Update(Scene.UpdateContext), SceneNode.Simulation, SceneNode.Render(Scene.RenderContext), SceneNode.GetSupportedRenderModes(), SceneNode.SetRenderMode(string), SceneNode.Delete(), SceneNode.GetCameraDistance(Camera)
Constructors
ModelSceneNode(Scene, Model, string?, bool)
Loads the model's meshes and animations.
public ModelSceneNode(Scene scene, Model model, string? skin = null, bool isWorldPreview = false)Parameters
scene Scene
The scene this node belongs to.
model Model
The model resource to render.
skin string?
The material group (skin) name to activate, or null for the default.
isWorldPreview bool
When true, only embedded animations are loaded.
Properties
ActiveLod
Gets the LoD level currently being rendered (auto-selected or forced).
public int ActiveLod { get; }Property Value
int
ActiveMaterialGroup
Gets the name of the currently active material group (skin).
public string ActiveMaterialGroup { get; }Property Value
string
AnimationController
Gets the animation controller managing skeletal pose and flex data for this model.
public AnimationController AnimationController { get; }Property Value
AnimationGraphReferences
Gets the animation graphs the model is bound to, by identifier and resource name. The first is the default.
public IReadOnlyList<(string Identifier, string GraphPath)> AnimationGraphReferences { get; }Property Value
IReadOnlyList<(string Identifier, string GraphPath)>
Animations
A collection of animations available for playback on this model.
public Dictionary<string, AnimationBase> Animations { get; }Property Value
Dictionary<string, AnimationBase>
Attachments
Attachment points from model data.
public Dictionary<string, Attachment> Attachments { get; }Property Value
Dictionary<string, Attachment>
HasMeshes
Gets whether this model has at least one mesh renderer loaded.
public bool HasMeshes { get; }Property Value
bool
IsAutoLod
Gets whether the LoD level is being chosen automatically by distance, rather than forced.
public bool IsAutoLod { get; }Property Value
bool
Methods
AttachNode(SceneNode, string, Vector3, Quaternion)
Attaches another SceneNode to this model with optional attachment point, offset and rotation, keeping the node's own scale. Shorthand for SceneNode.SetParent(SceneNode?, string?, Matrix4x4?).
public void AttachNode(SceneNode node, string attachmentName = "", Vector3 offset = default, Quaternion rotation = default)Parameters
node SceneNode
The child model to attach.
attachmentName string
The attachment point name.
offset Vector3
The local offset from the attachment point.
rotation Quaternion
The local rotation from the attachment point.
Delete()
Releases resources held by this node.
public override void Delete()GetActiveMeshGroups()
Returns the set of currently active mesh group names.
public ICollection<string> GetActiveMeshGroups()Returns
ICollection<string>
GetAttachmentLocalTransform(Attachment, Skeleton, Matrix4x4[])
Computes the model-local transform of an attachment from the given bone pose.
public static Matrix4x4 GetAttachmentLocalTransform(Attachment attachment, Skeleton skeleton, Matrix4x4[] pose)Parameters
attachment Attachment
skeleton Skeleton
pose Matrix4x4[]
Returns
GetAttachmentTransform(string)
Gets the world transform for the specified attachment point.
public Matrix4x4 GetAttachmentTransform(string attachmentName)Parameters
attachmentName string
Returns
GetChildFrame(string?)
The frame a child follows: the attachment point's world transform, a bone's when no attachment matches, or the model's own transform. Rigid, with no scale.
public override Matrix4x4 GetChildFrame(string? attachmentName)Parameters
attachmentName string?
Returns
GetMaterialGroups()
Returns the material group (skin) names defined by this model, in skin number order.
public IEnumerable<string> GetMaterialGroups()Returns
IEnumerable<string>
GetMeshGroups()
Returns all mesh group names defined by this model.
public IEnumerable<string> GetMeshGroups()Returns
IEnumerable<string>
GetReferenceMeshes()
Returns every external reference mesh name and its LoD mask, across all levels.
public IEnumerable<ModelMeshReference> GetReferenceMeshes()Returns
IEnumerable<ModelMeshReference>
GetSupportedRenderModes()
Returns the render modes supported by this node.
public override IEnumerable<string> GetSupportedRenderModes()Returns
IEnumerable<string>
HasAttachmentOrBone(string)
Whether the given name resolves to an anchor on this model: an attachment point, or a bone when no attachment has that name.
public bool HasAttachmentOrBone(string name)Parameters
name string
Returns
bool
LoadAnimationClip(AnimationClip)
Loads an animgraph2 clip from the given AnimationClip instance and makes it available for playback on this model.
public void LoadAnimationClip(AnimationClip clip)Parameters
clip AnimationClip
LoadAnimationClip(string)
Loads an animgraph2 clip from the file system and makes it available for playback on this model.
public bool LoadAnimationClip(string clipName)Parameters
clipName string
Clip resource name.
Returns
bool
true if the clip was found and loaded; otherwise false.
LoadAnimationGraph(string)
Loads an animation graph to play on this model, reusing the clips the node already loaded. Each node needs its own instance, which holds the playback state.
public AnimationGraph? LoadAnimationGraph(string graphPath)Parameters
graphPath string
The graph resource name, such as one of ModelSceneNode.AnimationGraphReferences.
Returns
The graph, or null when it or a skeleton it animates could not be loaded.
PlaceNode(SceneNode, string, Vector3)
Places child once at the named attachment point or bone (or the model's own transform when no name is given), with offset applied in that anchor's frame. Unlike ModelSceneNode.AttachNode(SceneNode, string, Vector3, Quaternion), the child does not track the model afterwards.
public void PlaceNode(SceneNode child, string attachmentName, Vector3 offset)Parameters
child SceneNode
attachmentName string
offset Vector3
PlayDefaultAnimationGraph()
Plays the model's default animation graph.
public bool PlayDefaultAnimationGraph()Returns
bool
true when the model has a default graph and it loaded.
SetActiveMeshGroups(IEnumerable<string>)
Sets which mesh groups are active, rebuilding the renderable mesh list accordingly.
public void SetActiveMeshGroups(IEnumerable<string> setMeshGroups)Parameters
setMeshGroups IEnumerable<string>
SetAnimation(AnimationBase?, float, bool)
Activates the given animation instance with a blend-in time, or clears the active animation when null.
public void SetAnimation(AnimationBase? activeAnimation, float blendTime = 0, bool warp = false)Parameters
activeAnimation AnimationBase?
The animation to activate, or null to clear.
blendTime float
The time in seconds to blend from the current animation to the new one.
warp bool
Whether re-activating the animation already playing should cross over into a second instance of it rather than restarting it in place.
SetAnimationByName(string, float, bool)
Activates the animation with the given name, or stops animation if not found.
public void SetAnimationByName(string animationName, float blendTime = 0, bool warp = false)Parameters
animationName string
blendTime float
warp bool
SetAnimationForWorldPreview(string)
Activates the named animation for world preview mode.
public bool SetAnimationForWorldPreview(string animationName)Parameters
animationName string
Returns
bool
true if the animation was found and activated; otherwise false.
SetAnimationGraph(IAnimationGraph?)
Plays an animation graph on this model, binding the skinning buffers the same way ModelSceneNode.SetAnimation(AnimationBase?, float, bool) does. Pass null to detach the graph.
public void SetAnimationGraph(IAnimationGraph? graph)Parameters
graph IAnimationGraph?
The animation graph to play, or null to detach.
SetMaterialGroup(string)
Activates the named material group (skin), remapping all mesh materials accordingly.
public void SetMaterialGroup(string name)Parameters
name string
SetOverrideLod(int?)
Sets the LoD level to display, rebuilding the renderable mesh list accordingly. Pass null to enable automatic distance-based selection.
public void SetOverrideLod(int? level)Parameters
level int?
Update(UpdateContext)
Called each frame to update this node's state.
public override void Update(Scene.UpdateContext context)Parameters
context Scene.UpdateContext
The current update context.

