Table of Contents

Class ModelExtract

Namespace
ValveResourceFormat.IO
Assembly
ValveResourceFormat.dll

Extracts Source 2 models to editable vmdl/dmx format.

public class ModelExtract

Inheritance

Inherited Members

Constructors

ModelExtract(Resource, IFileLoader)

Initializes a new instance of the ValveResourceFormat.IO.ModelExtract class.

public ModelExtract(Resource modelResource, IFileLoader fileLoader)

Parameters

modelResource Resource
fileLoader IFileLoader

ModelExtract(Mesh, string)

Initializes a new instance of the ValveResourceFormat.IO.ModelExtract class.

public ModelExtract(Mesh mesh, string fileName)

Parameters

mesh Mesh

Mesh data

fileName string

File name of the mesh e.g "models/my_mesh.vmesh"

ModelExtract(PhysAggregateData, string)

Initializes a new instance of the ValveResourceFormat.IO.ModelExtract class.

public ModelExtract(PhysAggregateData physAggregateData, string fileName)

Parameters

physAggregateData PhysAggregateData
fileName string

Properties

AnimationsToExtract

Gets the list of animations to be extracted with their output file names.

public List<(Animation Anim, string FileName)> AnimationsToExtract { get; }

Property Value

List<(Animation 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)> PhysHullsToExtract { get; }

Property Value

List<(HullDescriptor Hull, string FileName)>

PhysMeshesToExtract

Gets the list of physics meshes to be extracted with their output file names.

public List<(MeshDescriptor Mesh, string FileName)> PhysMeshesToExtract { get; }

Property Value

List<(MeshDescriptor Mesh, string FileName)>

PhysicsCollisionTags

Gets the physics collision tag sets associated with the current aggregate data.

public HashSet<string>[] PhysicsCollisionTags { get; }

Property Value

HashSet<string>[]

PhysicsSurfaceNames

Gets the physics surface property names discovered in the aggregate data.

public string[] PhysicsSurfaceNames { get; }

Property Value

string[]

PhysicsToRenderMaterialNameProvider

Gets or initializes the function to provide render material names for physics surface tags.

public Func<ModelExtract.SurfaceTagCombo, string> PhysicsToRenderMaterialNameProvider { get; init; }

Property Value

Func<ModelExtract.SurfaceTagCombo, string>

RenderMeshesToExtract

Gets the list of render meshes to be extracted.

public List<ModelExtract.RenderMeshExtractConfiguration> RenderMeshesToExtract { get; }

Property Value

List<ModelExtract.RenderMeshExtractConfiguration>

SurfaceTagCombos

Gets the set of surface tag combinations.

public HashSet<ModelExtract.SurfaceTagCombo> SurfaceTagCombos { get; }

Property Value

HashSet<ModelExtract.SurfaceTagCombo>

Translation

Gets or sets the translation offset for the model.

public Vector3 Translation { get; set; }

Property Value

Vector3

Type

Gets the extraction type to apply when generating assets.

public ModelExtract.ModelExtractType Type { get; init; }

Property Value

ModelExtract.ModelExtractType

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

IEnumerable<ContentFile>

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

ContentFile

ToDmxAnim(Model, Animation)

Converts an animation to DMX format.

public static byte[] ToDmxAnim(Model model, Animation anim)

Parameters

model Model
anim Animation

Returns

byte[]

ToDmxAnim(Skeleton, FlexController[], Animation)

Converts an animation to DMX format using skeleton and flex controllers.

public static byte[] ToDmxAnim(Skeleton skeleton, FlexController[] flexControllers, Animation anim)

Parameters

skeleton Skeleton
flexControllers FlexController[]
anim Animation

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)

Converts a physics hull descriptor to DMX format.

public byte[] ToDmxMesh(HullDescriptor hull)

Parameters

hull HullDescriptor

Returns

byte[]

ToDmxMesh(MeshDescriptor)

Converts a physics mesh descriptor to DMX format.

public byte[] ToDmxMesh(MeshDescriptor mesh)

Parameters

mesh MeshDescriptor

Returns

byte[]

ToDmxMesh(Hull, string, string, HashSet<string>, bool)

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)

Parameters

hull Hull
name string
uniformSurface string
uniformCollisionTags HashSet<string>
appendVertexNormalStream bool

Returns

byte[]

ToDmxMesh(Mesh, string, string, HashSet<string>, string[], bool)

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)

Parameters

mesh Mesh
name string
uniformSurface string
uniformCollisionTags HashSet<string>
surfaceList string[]
appendVertexNormalStream bool

Returns

byte[]

ToValveModel()

Converts the model to Valve model format as a string.

public string ToValveModel()

Returns

string