Class ModelSceneNode
Namespace: ValveResourceFormat.Renderer.SceneNodes
Assembly: Renderer.dll
Scene node for rendering animated models with skeletal animation and morph targets.
public class ModelSceneNode : MeshCollectionNodeInheritance
object ← SceneNode ← MeshCollectionNode ← ModelSceneNode
Derived
ViewmodelSceneNode, XenFloraAnimatedMoverSceneNode
Inherited Members
MeshCollectionNode.Tint, MeshCollectionNode.RenderableMeshes, SceneNode.Transform, SceneNode.LayerName, SceneNode.LayerEnabled, SceneNode.BoundingBox, SceneNode.LocalBoundingBox, SceneNode.Name, SceneNode.Id, SceneNode.IsSelected, SceneNode.Flags, SceneNode.RenderAsViewmodel, SceneNode.Scene, SceneNode.Parent, SceneNode.EnvMaps, SceneNode.ShaderEnvMapVisibility, SceneNode.LightingOrigin, SceneNode.OverlayRenderOrder, SceneNode.CubeMapPrecomputedHandshake, SceneNode.LightProbeVolumePrecomputedHandshake, SceneNode.LightProbeBinding, SceneNode.EntityData, SceneNode.Update(Scene.UpdateContext), SceneNode.Render(Scene.RenderContext), SceneNode.GetSupportedRenderModes(), SceneNode.SetRenderMode(string), SceneNode.Delete(), SceneNode.GetCameraDistance(Camera)
Constructors
ModelSceneNode(Scene, Model, string?, bool)
Initializes a new instance of the class and loads its 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
ActiveMaterialGroup
Gets the name of the currently active material group (skin).
public string ActiveMaterialGroup { get; }Property Value
AnimationController
Gets the animation controller managing skeletal pose and flex data for this model.
public AnimationController AnimationController { get; }Property Value
Animations
A collection of animations available for playback on this model.
public Dictionary<string, Animation> Animations { get; }Property Value
AttachedNodes
Gets the list of nodes attached to this model and the attachment points used.
public List<(SceneNode Node, string AttachmentName, Vector3 Offset, Quaternion Rotation)> AttachedNodes { get; }Property Value
List<(SceneNode Node, string AttachmentName, Vector3 Offset, Quaternion Rotation)>
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
IsAnimated
Gets whether this model has an active GPU bone matrix buffer (i.e., has animations loaded).
public bool IsAnimated { get; }Property Value
IsAutoLod
Gets whether the LoD level is being chosen automatically by distance, rather than forced.
public bool IsAutoLod { get; }Property Value
Tint
Gets or sets the tint color applied to all meshes in this node.
public override Vector4 Tint { get; set; }Property Value
Methods
AddAnimations(List<Animation>)
Adds the given animations to the collection of available animations for this model.
public void AddAnimations(List<Animation> animations)Parameters
AttachNode(SceneNode, string, Vector3, Quaternion)
Attaches another to this model with optional attachment point, offset and rotation.
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.
AttachNodeKeepingTransform(SceneNode)
Attaches node so it keeps its current world position relative to this model, following the model if it later moves. Used for plain parentname parenting (no attachment point), where the child stays where it was authored instead of snapping onto the parent.
public void AttachNodeKeepingTransform(SceneNode node)Parameters
node SceneNode
The child to attach.
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
GetAttachmentTransform(string)
Gets the world transform for the specified attachment point.
public Matrix4x4 GetAttachmentTransform(string attachmentName)Parameters
attachmentName string
Returns
GetMeshBoneIndex(int, RenderableMesh)
Returns the mesh-local bone index for the given model-level bone index within the specified mesh's remapping table slice.
public int GetMeshBoneIndex(int modelBoneIndex, RenderableMesh mesh)Parameters
modelBoneIndex int
mesh RenderableMesh
Returns
GetMeshGroups()
Returns all mesh group names defined by this model.
public IEnumerable<string> GetMeshGroups()Returns
GetReferenceMeshes()
Returns every external reference mesh name and its LoD mask, across all levels.
public IEnumerable<(int MeshIndex, string MeshName, long LoDMask)> GetReferenceMeshes()Returns
IEnumerable<(int MeshIndex, string MeshName, long LoDMask)>
GetSupportedRenderModes()
Returns the render modes supported by this node.
public override IEnumerable<string> GetSupportedRenderModes()Returns
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
LoadAnimationClip(AnimationClip)
Loads an animgraph2 clip from the given 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
true if the clip was found and loaded; otherwise false.
ParseTwistConstraints(Model)
Parses tilt-twist constraints from the model's keyvalues.
protected static TiltTwistConstraint[] ParseTwistConstraints(Model model)Parameters
model Model
Returns
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 , the child does not track the model afterwards. Works for any scene node.
public void PlaceNode(SceneNode child, string attachmentName, Vector3 offset)Parameters
child SceneNode
attachmentName string
offset Vector3
SetActiveLod(int?)
Sets the LoD level to display, rebuilding the renderable mesh list accordingly. Pass null to enable automatic distance-based selection.
public void SetActiveLod(int? lod)Parameters
lod int?
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(Animation?, float)
Activates the given animation instance with a blend-in time, or clears the active animation when null.
public void SetAnimation(Animation? activeAnimation, float blendTime = 0)Parameters
activeAnimation Animation?
The animation to activate, or null to clear.
blendTime float
The time in seconds to blend from the current animation to the new one.
SetAnimationByName(string, float)
Activates the animation with the given name, or stops animation if not found.
public void SetAnimationByName(string animationName, float blendTime = 0)Parameters
animationName string
blendTime float
SetAnimationForWorldPreview(string)
Activates the named animation for world preview mode.
public bool SetAnimationForWorldPreview(string animationName)Parameters
animationName string
Returns
true if the animation was found and activated; otherwise false.
SetCharacterEyeRenderParams()
Detects eye materials on this model and injects bone index and bind-pose uniforms for eyeball rendering.
public void SetCharacterEyeRenderParams()SetMaterialGroup(string)
Activates the named material group (skin), remapping all mesh materials accordingly.
public void SetMaterialGroup(string name)Parameters
name string
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.

