Click or drag to resize
AB4D logo

MeshUtils Class

MeshUtils class contains static methods that work with MeshGeometry3D.
Inheritance Hierarchy
SystemObject
  Ab3d.UtilitiesMeshUtils

Namespace:  Ab3d.Utilities
Assembly:  Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 10.1.8147.1045
Syntax
C#
public static class MeshUtils

The MeshUtils type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberCreatePolygonIndicesByDefault
Gets or sets a static Boolean that specifies if Polygon indices are created for 3D models defined in Ab3d.PowerToys library (box, sphere, pyramid, etc.). Default value is false. This value is used when the CreatePolygonIndices property for the actual Mesh3D object does not have a value set - for example a CreatePolygonIndices in BoxMesh3D class.
Top
Methods
  NameDescription
Public methodStatic memberAddPolygonPositions
Adds positions that define the edge lines for specified model3D (lines are not connected; each line is defined by two positions) to the specified Point3DCollection. Edge lines are specified with using PolygonIndicesProperty DependencyProperty on child MeshGeometry3D objects. See remarks in PolygonIndicesProperty for more info.
Public methodStatic memberCalculateNormals(MeshGeometry3D)
Calculates normals for the meshGeometry. The normals are normalized.
Public methodStatic memberCalculateNormals(MeshGeometry3D, Boolean)
Calculates normals for the meshGeometry.
Public methodStatic memberCollectAllMeshes
CollectAllMeshes method returns a list of MeshUtilsMesh3DInfo structs that contains information about all 3D meshes in the specified Model3D hierarchy.
Public methodStatic memberCombineAllMeshes(ListMeshUtilsMesh3DInfo)
CombineAllMeshes method combines all meshes from a list of Mesh3DInfo into a single MeshGeometry3D. It also applies all the transformations to the positions and normals (transformed by inversed transposed matrix).
Public methodStatic memberCombineAllMeshes(Model3D, Transform3D)
CombineAllMeshes method combines all meshes from the specified Model3D hierarchy and converts them into a single MeshGeometry3D. It also applies all the transformations to the positions and normals (transformed by inversed transposed matrix).
Public methodStatic memberCombineMeshes(IListMeshGeometry3D)
CombineMeshes return a MeshGeometry3D that is created with combining all Positions, Normals, TextureCoordinates and TriangleIndices for all the meshes that are set to the meshes parameter.
Public methodStatic memberCombineMeshes(MeshGeometry3D)
CombineMeshes return a MeshGeometry3D that is created with combining all Positions, Normals, TextureCoordinates and TriangleIndices for all the meshes that are set to the meshes parameter.
Public methodStatic memberConvertConnectedPositionsToDisconnected
Converts collection of Point3D that represents a connected 3D line (3D line strip) into a collection of Point3D that represent disconnected 3D lines. In connected 3D lines the end position of one line is used as a start position of the next line. In disconnected 3D lines each lines is defined by 2 positions.
Public methodStatic memberFlipNormals
Updates the normal vectors so that they point in the other direction.
Public methodStatic memberFlipTriangles
Updates the TriangleIndices collection with swaping second and third index in each triangle. This changes the orientation in which the triangles are defined.
Public methodStatic memberGenerateCubicTextureCoordinates
Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the cubic projection that projects the 3D positions to an axis aligned 3D cube.
Public methodStatic memberGenerateCylindricalTextureCoordinates(MeshGeometry3D, Vector3D, Vector3D)
Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Cylindrical projection. TextureCoordinates for position that are parallel to the cylinderDirectionVector use simple planar projection. TextureCoordinates for other positions are calculated based on the angle from the cylinder center axis to the position. The GenerateCylindricalTextureCoordinates does not set the TextureCoordinates on the mesh.
Public methodStatic memberGenerateCylindricalTextureCoordinates(MeshGeometry3D, Rect, Vector3D, Vector3D, Boolean)
Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Cylindrical projection. TextureCoordinates for position that are parallel to the cylinderDirectionVector use simple planar projection. TextureCoordinates for other positions are calculated based on the angle from the cylinder center axis to the position. The GenerateCylindricalTextureCoordinates does not set the TextureCoordinates on the mesh.
Public methodStatic memberGeneratePlanarTextureCoordinates(MeshGeometry3D, Vector3D, Vector3D, Boolean, Boolean, Boolean)
Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Planar projection. The plane is defined by the planeNormalVector (perpendicular to the plane) and planeHeightVector (defines the y up direction in the plane).
Public methodStatic memberGeneratePlanarTextureCoordinates(MeshGeometry3D, Vector3D, Vector3D, Rect, Boolean, Boolean, Boolean)
Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Planar projection. The plane is defined by the planeNormalVector (perpendicular to the plane) and planeHeightVector (defines the y up direction in the plane).
Public methodStatic memberGetAverageNormalVector3D
Returns a Vector3D that represents an average normal vector of the MeshGeometry3D (calculated with summing normal vectors of all triangles and dividing it by the number of triangles).
Public methodStatic memberGetIntersectingTriangles
Public methodStatic memberGetPolygonPositions(MeshGeometry3D, Transform3D)
Returns Point3DCollection with positions that define the edge lines for the specified meshGeometry3D (lines are not connected; each line is defined by two positions). Edge lines are specified with using PolygonIndicesProperty DependencyProperty. If this DependencyProperty is not defined then null is returned. See remarks in PolygonIndicesProperty for more info.
Public methodStatic memberGetPolygonPositions(Model3D, Transform3D)
Returns Point3DCollection with positions that define the edge lines for specified model3D (lines are not connected; each line is defined by two positions). Edge lines are specified with using PolygonIndicesProperty DependencyProperty on child MeshGeometry3D objects. See remarks in PolygonIndicesProperty for more info.
Public methodStatic memberGetPolygonPositionsCount(MeshGeometry3D)
Returns the count of positions that can be created from polygon indices.
Public methodStatic memberGetPolygonPositionsCount(Model3D)
Returns the count of positions that can be created from polygon indices that are defined in this Model3D.
Public methodStatic memberGetPolygons
GetPolygons method returns a List of Lists of Point3D structs that represents polygons (each polygon is defined by a List of Point3D structs) that are created from the PolygonIndicesProperty DependencyProperty on the MeshGeometry3D object. When PolygonIndices are not defined, then null is returned. See remarks in PolygonIndicesProperty for more info.
Public methodStatic memberPositionAndScaleMeshGeometry3D
PositionAndScaleModel3D method translates and scales the model3D so that it is positioned according to position and positionType parameters and that it will fit into the Size3D defined by finalSize parameter.
Public methodStatic memberProject3DPointsTo2DPlane
Projects a list of 3D position into a 2D plane with specified planeNormalVector and planeHeightVector.
Public methodStatic memberSplitMeshByIndexesOfTriangles
SplitMeshByIndexesOfTriangles splits the originalMeshGeometry3D into mesh1 and mesh2 based on the list of triangle indexes defined in indexesOfTriangles (can be get by GetIntersectingTriangles(Rect3D, MeshGeometry3D, Transform3D) method). When the triangle index is present in the indexesOfTriangles, then the triangle is added to mesh1, otherwise triangle is added to mesh2. Note that mesh1 can be null (when indexesOfTriangles is null or empty). mesh2 can be null when indexesOfTriangles contains the same number of triangles as the originalMeshGeometry3D.
Public methodStatic memberTransformMeshGeometry3D
Transforms the specified MeshGeometry3D with the specified Transform3D and returns a new MeshGeometry3D (the same MeshGeometry3D is returned in case of null or identity transform). If transformNormals is set to true (by default) the normals are transformed with inverted and transposed transform matrix.
Top
Fields
  NameDescription
Public fieldStatic memberEdgeLineIndicesProperty
EdgeLineIndicesProperty is a DependencyProperty that can be set to the MeshGeometry3D object and specifies a List<int> with Position indexes that define edge lines for the MeshGeometry3D. Each line is defined by two consecutive indexes.
Public fieldStatic memberPolygonIndicesProperty
PolygonIndicesProperty is a DependencyProperty that can be set to the MeshGeometry3D object and specifies an Int32Collection with Position indexes that define polygons for the MeshGeometry3D.
Top
See Also