Class Model
Namespace: ValveResourceFormat.ResourceTypes
Assembly: ValveResourceFormat.dll
Represents a model resource containing meshes, skeleton, and animations.
public class Model : KeyValuesOrNTROInheritance
object ← Block ← KeyValuesOrNTRO ← Model
Inherited Members
KeyValuesOrNTRO.Type, KeyValuesOrNTRO.Data, KeyValuesOrNTRO.Format, KeyValuesOrNTRO.Read(BinaryReader), KeyValuesOrNTRO.Serialize(Stream), KeyValuesOrNTRO.WriteText(IndentedTextWriter), Block.Type, Block.Offset, Block.Size, Block.Resource, Block.Read(BinaryReader), Block.ToString(), Block.WriteText(IndentedTextWriter), Block.Serialize(Stream)
Extension Methods
ResourceDataExtensions.AsKeyValueCollection(Block)
Properties
AnimGraph2References
Gets the animation graphs bound to this model, in declaration order. The first is the default.
public IReadOnlyList<(string Identifier, string GraphPath)> AnimGraph2References { get; }Property Value
IReadOnlyList<(string Identifier, string GraphPath)>
Attachments
Gets the attachments for this model.
public Dictionary<string, Attachment> Attachments { get; }Property Value
Dictionary<string, Attachment>
BoneConstraints
Gets the bone constraints the model was authored with, in compiled order.
public IReadOnlyList<BoneConstraint> BoneConstraints { get; }Property Value
BoneRemapTable
Gets the model's bone remap table, which maps the bone indices a mesh's BLENDINDICES carry to bone indices of the model skeleton.
public BoneRemapTable BoneRemapTable { get; }Property Value
FlexControllers
Gets the flex controllers for this model.
public FlexController[] FlexControllers { get; }Property Value
HitboxSets
Gets the hitbox sets for this model.
public Dictionary<string, Hitbox[]> HitboxSets { get; }Property Value
Dictionary<string, Hitbox[]>
KeyValues
Gets the key-values data from the model info.
[NotNull]
public KVObject KeyValues { get; }Property Value
KVObject
LodInfo
Gets this model's level-of-detail structure (which meshes belong to which LOD level and the per-level switch values). Built once and cached.
public ModelLodInfo LodInfo { get; }Property Value
MeshGroups
Gets the model's mesh groups, and the body groups their names encode.
public ModelMeshGroups MeshGroups { get; }Property Value
Name
Gets the model name.
public string Name { get; }Property Value
string
NmSkeletonRefs
Gets the NM skeletons this model can be animated on, by resource path, in declaration order.
public string[] NmSkeletonRefs { get; }Property Value
string[]
SequenceGroup
Gets the model's embedded animation data and the legacy sequence group behind it.
public EmbeddedSequenceGroup SequenceGroup { get; }Property Value
Skeleton
Gets the skeleton for this model.
public Skeleton Skeleton { get; }Property Value
Methods
GetAllAnimations(IFileLoader)
Gets all animations from this model including embedded, referenced, and animation groups.
public IEnumerable<AnimationBase> GetAllAnimations(IFileLoader fileLoader)Parameters
fileLoader IFileLoader
The file loader to use.
Returns
Enumerable of all animations.
GetAllAnimations(IFileLoader, bool)
Gets all animations from this model including embedded, referenced, and animation groups.
public IEnumerable<AnimationBase> GetAllAnimations(IFileLoader fileLoader, bool includeAnimationGraphClips)Parameters
fileLoader IFileLoader
The file loader to use.
includeAnimationGraphClips bool
Whether to load the clips of the model's animation graphs too.
Returns
Enumerable of all animations.
GetAnimatedMaterialAttributes()
Gets the material attributes the anim graph is allowed to drive, with their channel count (1 for a scalar float target, 4 for a color target).
public IEnumerable<(string AttributeName, int NumChannels)> GetAnimatedMaterialAttributes()Returns
IEnumerable<(string AttributeName, int NumChannels)>
Enumerable of attribute name and channel count pairs.
GetAnimationGroupAnimations(IFileLoader)
Gets the animations this model reaches through the standalone animation groups it references.
public IEnumerable<SequenceAnimation> GetAnimationGroupAnimations(IFileLoader fileLoader)Parameters
fileLoader IFileLoader
The file loader to use.
Returns
IEnumerable<SequenceAnimation>
Enumerable of animations.
GetAnimationGroupAnimations(IFileLoader, Skeleton, FlexController[])
Gets the animations this model reaches through the standalone animation groups it references. With remap tables built for the provided skeleton and flex controllers.
public IEnumerable<SequenceAnimation> GetAnimationGroupAnimations(IFileLoader fileLoader, Skeleton skeleton, FlexController[] flexControllers)Parameters
fileLoader IFileLoader
skeleton Skeleton
flexControllers FlexController[]
Returns
IEnumerable<SequenceAnimation>
GetBoneConstraints(string)
Gets the compiled data of every bone constraint of one class, in compiled order.
public IEnumerable<KVObject> GetBoneConstraints(string className)Parameters
className string
The compiled constraint class, e.g. CTiltTwistConstraint.
Returns
IEnumerable<KVObject>
GetEmbeddedAnimations()
Gets embedded animations from the model.
public IEnumerable<SequenceAnimation> GetEmbeddedAnimations()Returns
IEnumerable<SequenceAnimation>
Enumerable of animations.
GetEmbeddedAnimations(Skeleton, FlexController[])
Gets embedded animations from the model, with remap tables built for the provided skeleton and flex controllers.
public IEnumerable<SequenceAnimation> GetEmbeddedAnimations(Skeleton skeleton, FlexController[] flexControllers)Parameters
skeleton Skeleton
flexControllers FlexController[]
Returns
IEnumerable<SequenceAnimation>
GetEmbeddedMeshes()
Gets the meshes embedded in the model itself.
public IEnumerable<ModelMesh> GetEmbeddedMeshes()Returns
Remarks
A mesh's own index addresses the model's mask tables, which cover embedded and referenced meshes alike.
GetEmbeddedMeshesForLod(int)
Gets the embedded meshes present in the given LOD level.
public IEnumerable<ModelMesh> GetEmbeddedMeshesForLod(int level)Parameters
level int
Returns
GetEmbeddedPhys()
Gets embedded physics data from the model.
public PhysAggregateData? GetEmbeddedPhys()Returns
The physics aggregate data, or null if not present.
GetMaterialGroups()
Gets the material groups defined in the model.
public IEnumerable<(string Name, string[] Materials)> GetMaterialGroups()Returns
IEnumerable<(string Name, string[] Materials)>
Enumerable of material group names and their materials.
GetReferenceMeshNamesAndLoD()
Gets the model's references to meshes that live in their own vmesh. Slots filled by an embedded mesh are left out.
public IEnumerable<ModelMeshReference> GetReferenceMeshNamesAndLoD()Returns
IEnumerable<ModelMeshReference>
GetReferenceMeshNamesForLod(int)
Gets the referenced mesh names present in the given LOD level.
public IEnumerable<ModelMeshReference> GetReferenceMeshNamesForLod(int level)Parameters
level int
Returns
IEnumerable<ModelMeshReference>
GetReferencedAnimationGroupNames()
Gets referenced animation group names.
public IEnumerable<string> GetReferencedAnimationGroupNames()Returns
IEnumerable<string>
Enumerable of animation group names.
GetReferencedAnimations(IFileLoader)
Gets animations referenced from other models.
public IEnumerable<AnimationBase> GetReferencedAnimations(IFileLoader fileLoader)Parameters
fileLoader IFileLoader
The file loader to use.
Returns
Enumerable of animations.
GetReferencedPhysNames()
Gets referenced physics data names.
public IEnumerable<string> GetReferencedPhysNames()Returns
IEnumerable<string>
Enumerable of physics data names.
GetRemapTable(int)
Get the bone remap table of a specific mesh. This is used to remap bone indices in the mesh VBIB to bone indices of the model skeleton.
public int[]? GetRemapTable(int meshIndex)Parameters
meshIndex int
Returns
int[]?
Read(BinaryReader)
Reads the block data from a binary reader.
public override void Read(BinaryReader reader)Parameters
reader BinaryReader
The binary reader to read from.
SetExternalMeshData(Mesh)
Populates flex controllers, hitbox sets and attachments the model does not have from an external mesh resource.
public void SetExternalMeshData(Mesh mesh)Parameters
mesh Mesh
The mesh providing supplemental data.
SetExternalMorphData(Morph?)
Populates cached flex controller data from an externally loaded morph resource.
public void SetExternalMorphData(Morph? morph)Parameters
morph Morph?
The morph data whose flex controllers should be reused.

