Class HammerMeshBuilder
Namespace: ValveResourceFormat.IO
Assembly: ValveResourceFormat.dll
Builds a Hammer editable mesh out of faces, and writes it out as a .
public class HammerMeshBuilderInheritance
Remarks
Most of the work is handled by HalfEdgeMesh, which builds the mesh and keeps it valid. All attribute data lives in data streams attached to the mesh components: position per vertex, corner data per half edge, material per face. then loops through the mesh and writes the vmap format.
Constructors
HammerMeshBuilder()
Initializes a new instance of the class.
public HammerMeshBuilder()Properties
FacesRemoved
Number of faces dropped while building, either degenerate or non manifold.
public int FacesRemoved { get; }Property Value
OriginalFaceCount
Number of faces handed to the builder, including the ones it dropped.
public int OriginalFaceCount { get; }Property Value
PhysicsVertexMatcher
Matcher that reports which physics vertices a render mesh already covers.
public PhysicsVertexMatcher? PhysicsVertexMatcher { get; init; }Property Value
ProgressReporter
Receives diagnostics about faces the builder had to drop.
public IProgress<string>? ProgressReporter { get; init; }Property Value
Methods
AddFace(ReadOnlySpan<int>, string)
Adds one face. Faces that would leave the mesh non manifold are dropped and counted in
.public void AddFace(ReadOnlySpan<int> indices, string material)Parameters
indices ReadOnlySpan<int>
Corner vertices, as indices into the vertices added so far.
material string
Material the face uses.
AddPhysHull(HullDescriptor, PhysAggregateData, Func<string, string>, Vector3, string?)
Adds a physics hull as mesh faces.
public void AddPhysHull(HullDescriptor desc, PhysAggregateData phys, Func<string, string> materialNameProvider, Vector3 positionOffset = default, string? materialOverride = null)Parameters
desc HullDescriptor
Hull to add.
phys PhysAggregateData
Physics data the hull belongs to, read for its collision attributes.
materialNameProvider Func<string, string>
Maps a surface property to the material to use.
positionOffset Vector3
Offset added to every position.
materialOverride string?
Material to use instead of the one the surface property picks.
AddPhysMesh(MeshDescriptor, PhysAggregateData, Func<string, string>, HashSet<int>, Vector3, string?, int, int, bool)
Adds a physics mesh as mesh faces.
public void AddPhysMesh(MeshDescriptor desc, PhysAggregateData phys, Func<string, string> materialNameProvider, HashSet<int> deletedIndices, Vector3 positionOffset = default, string? materialOverride = null, int triangleRangeMin = 0, int triangleRangeMax = 0, bool useTriangleRange = false)Parameters
desc MeshDescriptor
Mesh to add.
phys PhysAggregateData
Physics data the mesh belongs to, read for its collision attributes.
materialNameProvider Func<string, string>
Maps a surface property to the material to use.
Vertices to leave out, usually the ones a render mesh already covers.
positionOffset Vector3
Offset added to every position.
materialOverride string?
Material to use instead of the one the surface property picks.
triangleRangeMin int
First triangle to add when useTriangleRange is set.
triangleRangeMax int
Triangle to stop before when useTriangleRange is set.
useTriangleRange bool
Whether to add only the given triangle range.
AddRenderMesh(DmeMesh, Matrix4x4)
Adds a render mesh, splitting it per face set so each keeps its own material.
public void AddRenderMesh(DmeMesh shape, Matrix4x4 transform)Parameters
shape DmeMesh
Mesh to add.
transform Matrix4x4
Transform applied to positions, normals and tangents.
AddVertices(VertexStreams, Vector3)
Adds the vertices of one source mesh. Faces added afterwards index into these vertices.
public void AddVertices(HammerMeshBuilder.VertexStreams streams, Vector3 positionOffset = default)Parameters
streams HammerMeshBuilder.VertexStreams
Per vertex source data.
positionOffset Vector3
Offset added to every position.
CreateStream<TArray, T>(int, string, string?, params T[])
Creates a named mesh data stream, optionally filled with initial values.
public static CDmePolygonMeshDataStream<T> CreateStream<TArray, T>(int dataStateFlags, string name, string? standardAttributeName = null, params T[] data) where TArray : Array<T>, new() where T : notnullParameters
dataStateFlags int
Flags describing how the stream is stored.
name string
Stream name, in "semantic:index" form.
standardAttributeName string?
Name Hammer knows the stream by, defaults to the semantic.
data T[]
Values to seed the stream with.
Returns
Type Parameters
TArray
Datamodel array type backing the stream.
T
Element type of the stream.
GenerateMesh()
Writes everything added so far out as a Hammer mesh.
public CDmePolygonMesh GenerateMesh()Returns
ReindexTriangleMesh(ReadOnlySpan<Vector3>, ReadOnlySpan<Triangle>, int, int)
Rebuilds a triangle range against a vertex list holding only the vertices that range uses.
public static (List<Vector3> NewTriangles, List<Vector3> NewVertices) ReindexTriangleMesh(ReadOnlySpan<Vector3> vertices, ReadOnlySpan<Mesh.Triangle> triangles, int trianglesRangeStart, int trianglesRangeEnd)Parameters
vertices ReadOnlySpan<Vector3>
Vertices the triangles index into.
triangles ReadOnlySpan<Mesh.Triangle>
Triangles to reindex.
trianglesRangeStart int
First triangle to take.
trianglesRangeEnd int
Triangle to stop before.

