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
geomGeometryContentThe geometry which will receive the normals.
overwriteExistingNormalsboolOverwrite 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
meshMeshContentThe mesh which will receive the normals.
overwriteExistingNormalsboolOverwrite or skip over geometry with existing normals.
Remarks
This calls CalculateNormals(GeometryContent, bool) to do the work.
CalculateTangentFrames(GeometryContent, string, string, string)
public static void CalculateTangentFrames(GeometryContent geom, string textureCoordinateChannelName, string tangentChannelName, string binormalChannelName)
Parameters
geomGeometryContenttextureCoordinateChannelNamestringtangentChannelNamestringbinormalChannelNamestring
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
meshMeshContentThe mesh which will have add tangent and binormal channels added.
textureCoordinateChannelNamestringThe Vector2 texture coordinate channel used to generate tangent frames.
tangentChannelNamestringbinormalChannelNamestring
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
positionsIList<Vector3>indicesIList<int>normalsIList<Vector3>textureCoordsIList<Vector2>tangentsVector3[]bitangentsVector3[]
FindSkeleton(NodeContent)
Search for the root bone of the skeletion.
public static BoneContent FindSkeleton(NodeContent node)
Parameters
nodeNodeContentThe 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
skeletonBoneContent
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
meshMeshContentMesh to be processed.
tolerancefloatTolerance 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
geometryGeometryContentGeometry 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
meshMeshContentMesh to be processed
OptimizeForCache(MeshContent)
public static void OptimizeForCache(MeshContent mesh)
Parameters
meshMeshContent
SwapWindingOrder(MeshContent)
Reverses the triangle winding order of the mesh.
public static void SwapWindingOrder(MeshContent mesh)
Parameters
meshMeshContentThe 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
sceneNodeContentThe root node of the scene to transform.
transformMatrixThe transform matrix to apply to the scene.
Remarks
The node transforms themselves are unaffected.