Class ModelExtract
Namespace: ValveResourceFormat.IO
Assembly: ValveResourceFormat.dll
Extracts Source 2 models to editable vmdl/dmx format.
public class ModelExtractInheritance
object ← ModelExtract
Constructors
ModelExtract(Resource, IFileLoader)
Initializes a new instance of the ModelExtract class.
public ModelExtract(Resource modelResource, IFileLoader fileLoader)Parameters
modelResource Resource
fileLoader IFileLoader
ModelExtract(Mesh, string)
Initializes a new instance of the ModelExtract class.
public ModelExtract(Mesh mesh, string meshFileName)Parameters
mesh Mesh
Mesh data
meshFileName string
File name of the mesh e.g. "models/my_mesh.vmesh"
ModelExtract(PhysAggregateData, string)
Initializes a new instance of the ModelExtract class.
public ModelExtract(PhysAggregateData physAggregateData, string physFileName)Parameters
physAggregateData PhysAggregateData
physFileName string
Properties
AnimationsToExtract
Gets the list of animations to be extracted with their output file names.
public List<(SequenceAnimation Anim, string FileName)> AnimationsToExtract { get; }Property Value
List<(SequenceAnimation Anim, string FileName)>
MaterialInputSignatures
Gets the material input signatures for mapping DirectX semantic names.
public Dictionary<string, Material.VsInputSignature> MaterialInputSignatures { get; }Property Value
Dictionary<string, Material.VsInputSignature>
ModelName
Gets the model name from either the model resource or the file name.
public string ModelName { get; }Property Value
string
PhysHullsToExtract
Gets the list of physics hulls to be extracted with their output file names.
public List<(HullDescriptor Hull, string FileName, string ParentBone, Matrix4x4 BindPose)> PhysHullsToExtract { get; }Property Value
List<(HullDescriptor Hull, string FileName, string ParentBone, Matrix4x4 BindPose)>
Remarks
Matrix4x4 transforms the hull's vertices from body-local space into bind-pose component space, matching the space a PhysicsHullFile node's DMX geometry is authored in.
PhysMeshesToExtract
Gets the list of physics meshes to be extracted with their output file names.
public List<(MeshDescriptor Mesh, string FileName, string ParentBone, Matrix4x4 BindPose)> PhysMeshesToExtract { get; }Property Value
List<(MeshDescriptor Mesh, string FileName, string ParentBone, Matrix4x4 BindPose)>
Remarks
Matrix4x4 transforms the mesh's vertices from body-local space into bind-pose component space, matching the space a PhysicsMeshFile node's DMX geometry is authored in.
PhysicsToRenderMaterialNameProvider
Gets the function to provide render material names for physics surface tags.
public Func<SurfaceTagCombo, string>? PhysicsToRenderMaterialNameProvider { get; init; }Property Value
Func<SurfaceTagCombo, string>?
ProgressReporter
Optional sink for non-fatal progress and warning messages.
public IProgress<string>? ProgressReporter { get; init; }Property Value
IProgress<string>?
ReconstructSoftbody
Gets whether to reconstruct the model's soft-body (cloth) physics. When false, the model is extracted as if it had no cloth.
public bool ReconstructSoftbody { get; init; }Property Value
bool
RenderMeshesToExtract
Gets the list of render meshes to be extracted.
public List<ModelExtract.RenderMeshExtractConfiguration> RenderMeshesToExtract { get; }Property Value
List<ModelExtract.RenderMeshExtractConfiguration>
Translation
Gets or sets the translation offset for the model.
public Vector3 Translation { get; set; }Property Value
Type
Gets the extraction type to apply when generating assets.
public ModelExtract.ModelExtractType Type { get; init; }Property Value
Methods
ConvertMeshToDatamodelMesh(Mesh, string, DatamodelRenderMeshExtractOptions)
Converts a mesh to a datamodel mesh representation.
public static Datamodel ConvertMeshToDatamodelMesh(Mesh mesh, string name, ModelExtract.DatamodelRenderMeshExtractOptions options)Parameters
mesh Mesh
name string
options ModelExtract.DatamodelRenderMeshExtractOptions
Returns
Datamodel
GetContentFiles_DrawCallSplit(Resource, IFileLoader, Vector3[], int)
Extracts content files from an aggregate model resource, splitting by draw calls.
public static IEnumerable<ContentFile> GetContentFiles_DrawCallSplit(Resource aggregateModelResource, IFileLoader fileLoader, Vector3[] drawOrigins, int drawCallCount)Parameters
aggregateModelResource Resource
fileLoader IFileLoader
drawOrigins Vector3[]
drawCallCount int
Returns
GetFragmentModelName(string, int)
Gets the fragment model name for a draw call index.
public static string GetFragmentModelName(string aggModelName, int drawCallIndex)Parameters
aggModelName string
drawCallIndex int
Returns
string
ToContentFile()
Converts the model to a content file with associated meshes and animations.
public ContentFile ToContentFile()Returns
ToDmxAnim(Model, AnimationBase)
Converts an animation to DMX format.
public static byte[] ToDmxAnim(Model model, AnimationBase anim)Parameters
model Model
anim AnimationBase
Returns
byte[]
ToDmxAnim(Skeleton, FlexController[], AnimationBase, bool)
Converts an animation to DMX format using skeleton and flex controllers.
public static byte[] ToDmxAnim(Skeleton skeleton, FlexController[] flexControllers, AnimationBase anim, bool nmSkelAxisFixup = false)Parameters
skeleton Skeleton
flexControllers FlexController[]
anim AnimationBase
nmSkelAxisFixup bool
Returns
byte[]
ToDmxAnim(Skeleton, FlexController[], AnimationBase, IReadOnlyList<(Skeleton Skeleton, AnimationBase Animation)>, bool)
Converts an animation to DMX format using skeleton and flex controllers. Secondary animations (an NM clip's tracks for further skeletons, e.g. the weapon of a viewmodel clip) are written into the same DMX, their joints appended beside the primary skeleton's.
public static byte[] ToDmxAnim(Skeleton skeleton, FlexController[] flexControllers, AnimationBase anim, IReadOnlyList<(Skeleton Skeleton, AnimationBase Animation)> secondaryAnimations, bool nmSkelAxisFixup = false)Parameters
skeleton Skeleton
flexControllers FlexController[]
anim AnimationBase
secondaryAnimations IReadOnlyList<(Skeleton Skeleton, AnimationBase Animation)>
nmSkelAxisFixup bool
Returns
byte[]
ToDmxMesh(Mesh, string, DatamodelRenderMeshExtractOptions)
Converts a mesh to DMX format.
public static byte[] ToDmxMesh(Mesh mesh, string name, ModelExtract.DatamodelRenderMeshExtractOptions options = default)Parameters
mesh Mesh
name string
options ModelExtract.DatamodelRenderMeshExtractOptions
Returns
byte[]
ToDmxMesh(HullDescriptor, Matrix4x4?)
Converts a physics hull descriptor to DMX format.
public byte[] ToDmxMesh(HullDescriptor hull, Matrix4x4? bindPose = null)Parameters
hull HullDescriptor
The hull descriptor to convert.
bindPose Matrix4x4?
Transforms the hull's vertices from body-local space into bind-pose component space, the space a PhysicsHullFile node's DMX geometry is authored in. Defaults to identity.
Returns
byte[]
ToDmxMesh(MeshDescriptor, Matrix4x4?)
Converts a physics mesh descriptor to DMX format.
public byte[] ToDmxMesh(MeshDescriptor mesh, Matrix4x4? bindPose = null)Parameters
mesh MeshDescriptor
The mesh descriptor to convert.
bindPose Matrix4x4?
Transforms the mesh's vertices from body-local space into bind-pose component space, the space a PhysicsMeshFile node's DMX geometry is authored in. Defaults to identity.
Returns
byte[]
ToDmxMesh(Hull, string, string, HashSet<string>, bool, Matrix4x4?)
Converts a Rubikon hull shape to DMX mesh format.
public static byte[] ToDmxMesh(Hull hull, string name, string uniformSurface, HashSet<string> uniformCollisionTags, bool appendVertexNormalStream = false, Matrix4x4? bindPose = null)Parameters
hull Hull
name string
uniformSurface string
uniformCollisionTags HashSet<string>
appendVertexNormalStream bool
bindPose Matrix4x4?
Returns
byte[]
Remarks
bindPose transforms the hull's vertices from body-local space into bind-pose component space, the space a PhysicsHullFile node's geometry is authored in. The raw body-local vertices are transformed by the part's PhysAggregateData.BindPose.
ToDmxMesh(Mesh, string, string, HashSet<string>, string[], bool, Matrix4x4?)
Converts a Rubikon mesh shape to DMX mesh format.
public static byte[] ToDmxMesh(Mesh mesh, string name, string uniformSurface, HashSet<string> uniformCollisionTags, string[] surfaceList, bool appendVertexNormalStream = false, Matrix4x4? bindPose = null)Parameters
mesh Mesh
name string
uniformSurface string
uniformCollisionTags HashSet<string>
surfaceList string[]
appendVertexNormalStream bool
bindPose Matrix4x4?
Returns
byte[]
Remarks
bindPose transforms the mesh's vertices from body-local space into bind-pose component space, matching how ModelExtract.ToDmxMesh(Hull, string, string, HashSet<string>, bool, Matrix4x4?) treats a hull's vertices.
ToDmxSkeleton(Skeleton, bool, int)
Produces a skeleton DMX file. nmLowLodBoneCount is the skeleton's m_numBonesToSampleAtLowLOD; when non-negative, DAG siblings are ordered to reproduce the compiled NM bone order.
public static byte[] ToDmxSkeleton(Skeleton skeleton, bool nmSkelAxisFixup = false, int nmLowLodBoneCount = -1)Parameters
skeleton Skeleton
nmSkelAxisFixup bool
nmLowLodBoneCount int
Returns
byte[]
ToValveModel()
Converts the model to Valve model format as a string.
public string ToValveModel()Returns
string

