Class Mesh

Mesh class

A mesh is made of many n-sided polygons.

public class Mesh : Geometry, IEnumerable<int[]>, IMeshConvertible

Constructors

NameDescription
Mesh()Initializes a new instance of the Mesh class.
Mesh(string)Initializes a new instance of the Mesh class.
Mesh(TextureData)Construct a mesh using specified height map, if the height map’s pixel format contains multiple components, the first(usually the red) component will be used as the height value(z) The control point’s x and y components are normalized pixel coordinate.
Mesh(TextureData, Matrix4)Construct a mesh using specified height map, if the height map’s pixel format contains multiple components, the first(usually the red) component will be used as the height value(z) The control point’s x and y components are normalized pixel coordinate.
Mesh(TextureData, bool, Matrix4)Construct a mesh using specified height map, if the height map’s pixel format contains multiple components, the first(usually the red) component will be used as the height value(z) The control point’s x and y components are normalized pixel coordinate.

Properties

NameDescription
CastShadows { get; set; }Gets or sets whether this geometry can cast shadow
ControlPoints { get; }Gets all control points
Deformers { get; }Gets all deformers associated with this geometry.
Edges { get; }Gets edges of the Mesh. Edge is optional in mesh, so it can be empty.
Excluded { get; set; }Gets or sets whether to exclude this entity during exporting.
virtual Name { get; set; }Gets or sets the name.
ParentNode { get; set; }Gets or sets the first parent node, if set the first parent node, this entity will be detached from other parent nodes.
ParentNodes { get; }Gets all parent nodes, an entity can be attached to multiple parent nodes for geometry instancing
PolygonCount { get; }Gets the count of polygons
Polygons { get; }Gets the polygons definition of the mesh
Properties { get; }Gets the collection of all properties.
ReceiveShadows { get; set; }Gets or sets whether this geometry can receive shadow.
Scene { get; }Gets the scene that this object belongs to
VertexElements { get; }Gets all vertex elements
Visible { get; set; }Gets or sets if the geometry is visible

Methods

NameDescription
static DoBoolean(BooleanOperation, Mesh, Matrix4?, Mesh, Matrix4?)
AddElement(VertexElement)Adds an existing vertex element to current geometry
CreateElement(VertexElementType)Creates a vertex element with specified type and add it to the geometry.
CreateElement(VertexElementType, MappingMode, ReferenceMode)Creates a vertex element with specified type and add it to the geometry.
CreateElementUV(TextureMapping)Creates a VertexElementUV with given texture mapping type.
CreateElementUV(TextureMapping, MappingMode, ReferenceMode)Creates a VertexElementUV with given texture mapping type.
CreatePolygon(int[])Creates a new polygon with all vertices defined in indices. To create polygon vertex by vertex, please use PolygonBuilder.
CreatePolygon(int, int, int)Create a polygon with 3 vertices(triangle)
CreatePolygon(int[], int, int)Creates a new polygon with all vertices defined in indices. To create polygon vertex by vertex, please use PolygonBuilder.
CreatePolygon(int, int, int, int)Create a polygon with 4 vertices(quad)
FindProperty(string)Finds the property. It can be a dynamic property (Created by CreateDynamicProperty/SetProperty) or native property(Identified by its name)
GetBoundingBox()Gets the bounding box of current entity in its object space coordinate system.
GetDeformers<T>()
GetElement(VertexElementType)Gets a vertex element with specified type
virtual GetEntityRendererKey()Gets the key of the entity renderer registered in the renderer
GetEnumerator()Gets the enumerator for each inner polygons.
GetPolygonSize(int)Gets the vertex count of the specified polygon.
GetProperty(string)Get the value of specified property
GetVertexElementOfUV(TextureMapping)Gets a VertexElementUV instance with given texture mapping type
Optimize(bool)Optimize the mesh’s memory usage by eliminating duplicated control points
Optimize(bool, float, float, float)Optimize the mesh’s memory usage by eliminating duplicated control points
RemoveProperty(Property)Removes a dynamic property.
RemoveProperty(string)Remove the specified property identified by name
SetProperty(string, object)Sets the value of specified property
ToMesh()Gets the Mesh instance from current entity.
Triangulate()Return triangulated mesh
operator &Calculate the intersection of two meshes
operator |Calculate the union of two meshes
operator -Calculate the difference of two meshes

Examples

To add a polygon in mesh:

Mesh mesh = new Mesh();
int[] indices = new int[] {0, 1, 2};
mesh.CreatePolygon(indices);

Travel through all polygons in mesh:

Mesh mesh = new Mesh();
foreach(int[] polygon in mesh)
{
    //deal with polygon
}

See Also