Table of Contents

Class MeshHelper

Namespace
Microsoft.Xna.Framework.Content.Pipeline.Graphics
Assembly
MonoGame.Framework.Content.Pipeline.dll
public static class MeshHelper
Inheritance
MeshHelper
Inherited Members

Methods

CalculateNormals(GeometryContent, bool)

Generates vertex normals by accumulation of triangle face normals.

public static void CalculateNormals(GeometryContent geom, bool overwriteExistingNormals)

Parameters

geom GeometryContent

The geometry which will receive the normals.

overwriteExistingNormals bool

Overwrite or skip over geometry with existing normals.

Remarks

We use a "Mean Weighted Equally" method generate vertex normals from triangle face normals. If normal cannot be calculated from the geometry we set it to zero.

CalculateNormals(MeshContent, bool)

Generates vertex normals by accumulation of triangle face normals.

public static void CalculateNormals(MeshContent mesh, bool overwriteExistingNormals)

Parameters

mesh MeshContent

The mesh which will receive the normals.

overwriteExistingNormals bool

Overwrite or skip over geometry with existing normals.

Remarks

This calls CalculateNormals(GeometryContent, bool) to do the work.

CalculateTangentFrames(GeometryContent, string, string, string)

Generate the tangents and binormals (tangent frames) for each vertex in the mesh geometry.

public static void CalculateTangentFrames(GeometryContent geom, string textureCoordinateChannelName, string tangentChannelName, string binormalChannelName)

Parameters

geom GeometryContent

The mesh geometry which will have add tangent and binormal channels added.

textureCoordinateChannelName string

The Vector2 texture coordinate channel used to generate tangent frames.

tangentChannelName string
binormalChannelName string

CalculateTangentFrames(MeshContent, string, string, string)

Generate the tangents and binormals (tangent frames) for each vertex in the mesh.

public static void CalculateTangentFrames(MeshContent mesh, string textureCoordinateChannelName, string tangentChannelName, string binormalChannelName)

Parameters

mesh MeshContent

The mesh which will have add tangent and binormal channels added.

textureCoordinateChannelName string

The Vector2 texture coordinate channel used to generate tangent frames.

tangentChannelName string
binormalChannelName string

CalculateTangentFrames(IList<Vector3>, IList<int>, IList<Vector3>, IList<Vector2>, out Vector3[], out Vector3[])

public static void CalculateTangentFrames(IList<Vector3> positions, IList<int> indices, IList<Vector3> normals, IList<Vector2> textureCoords, out Vector3[] tangents, out Vector3[] bitangents)

Parameters

positions IList<Vector3>
indices IList<int>
normals IList<Vector3>
textureCoords IList<Vector2>
tangents Vector3[]
bitangents Vector3[]

FindSkeleton(NodeContent)

Search for the root bone of the skeletion.

public static BoneContent FindSkeleton(NodeContent node)

Parameters

node NodeContent

The node from which to begin the search for the skeleton.

Returns

BoneContent

The root bone of the skeletion or null if none is found.

FlattenSkeleton(BoneContent)

Traverses a skeleton depth-first and builds a list of its bones.

public static IList<BoneContent> FlattenSkeleton(BoneContent skeleton)

Parameters

skeleton BoneContent

Returns

IList<BoneContent>

MergeDuplicatePositions(MeshContent, float)

Merge any positions in the PositionCollection of the specified mesh that are at a distance less than the specified tolerance from each other.

public static void MergeDuplicatePositions(MeshContent mesh, float tolerance)

Parameters

mesh MeshContent

Mesh to be processed.

tolerance float

Tolerance value that determines how close positions must be to each other to be merged.

Remarks

This method will also update the PositionIndices in the GeometryContent of the specified mesh.

MergeDuplicateVertices(GeometryContent)

Merge vertices with the same PositionIndices and VertexChannel data within the specified GeometryContent.

public static void MergeDuplicateVertices(GeometryContent geometry)

Parameters

geometry GeometryContent

Geometry to be processed.

MergeDuplicateVertices(MeshContent)

Merge vertices with the same PositionIndices and VertexChannel data within the Geometry of this mesh. If you want to merge positions too, call MergeDuplicatePositions(MeshContent, float) on your mesh before this function.

public static void MergeDuplicateVertices(MeshContent mesh)

Parameters

mesh MeshContent

Mesh to be processed

OptimizeForCache(MeshContent)

public static void OptimizeForCache(MeshContent mesh)

Parameters

mesh MeshContent

SwapWindingOrder(MeshContent)

Reverses the triangle winding order of the mesh.

public static void SwapWindingOrder(MeshContent mesh)

Parameters

mesh MeshContent

The mesh which will be modified.

Remarks

This method is useful when changing the direction of backface culling like when switching between left/right handed coordinate systems.

TransformScene(NodeContent, Matrix)

Transforms the contents of a node and its descendants.

public static void TransformScene(NodeContent scene, Matrix transform)

Parameters

scene NodeContent

The root node of the scene to transform.

transform Matrix

The transform matrix to apply to the scene.

Remarks

The node transforms themselves are unaffected.