Class MeshHelper
- 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
GeometryContentThe geometry which will receive the normals.
overwriteExistingNormals
boolOverwrite 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
MeshContentThe mesh which will receive the normals.
overwriteExistingNormals
boolOverwrite 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
GeometryContentThe mesh geometry which will have add tangent and binormal channels added.
textureCoordinateChannelName
stringThe Vector2 texture coordinate channel used to generate tangent frames.
tangentChannelName
stringbinormalChannelName
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
MeshContentThe mesh which will have add tangent and binormal channels added.
textureCoordinateChannelName
stringThe Vector2 texture coordinate channel used to generate tangent frames.
tangentChannelName
stringbinormalChannelName
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
NodeContentThe 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
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
MeshContentMesh to be processed.
tolerance
floatTolerance 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
GeometryContentGeometry 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
MeshContentMesh 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
MeshContentThe 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
NodeContentThe root node of the scene to transform.
transform
MatrixThe transform matrix to apply to the scene.
Remarks
The node transforms themselves are unaffected.