Class VertexElementMaterial

VertexElementMaterial class

Defines material index for specified components. A node can have multiple materials, the VertexElementMaterial is used to render different part of the geometry in different materials.

public class VertexElementMaterial : VertexElement

Constructors

NameDescription
VertexElementMaterial()Initializes a new instance of the VertexElementMaterial class.

Properties

NameDescription
Indices { get; }Gets the indices data(Inherited from VertexElement.)
MappingMode { get; set; }Gets or sets how the element is mapped.(Inherited from VertexElement.)
Name { get; set; }Gets or sets the name.(Inherited from VertexElement.)
ReferenceMode { get; set; }Gets or sets how the element is referenced.(Inherited from VertexElement.)
VertexElementType { get; }Gets the type of the VertexElement(Inherited from VertexElement.)

Methods

NameDescription
override Clear()Removes all elements from the direct and the index arrays.
SetIndices(int[])Load indices(Inherited from VertexElement.)
override ToString()String representation of vertex element.(Inherited from VertexElement.)

Examples

The following code shows how to assign different material to different face of a box.

// Create a mesh of box(A box is composed by 6 planes)
Mesh box = (new Box()).ToMesh();
// Create a material element on this mesh
VertexElementMaterial mat = (VertexElementMaterial)box.CreateElement(VertexElementType.Material, MappingMode.Polygon, ReferenceMode.Index);
// And specify different material index for each plane
mat.Indices.AddRange(new int[] { 0, 1, 2, 3, 4, 5 });

See Also