Table of Contents

Class VertexContent

Namespace
Microsoft.Xna.Framework.Content.Pipeline.Graphics
Assembly
MonoGame.Framework.Content.Pipeline.dll

Provides methods and properties for maintaining the vertex data of a GeometryContent.

public sealed class VertexContent
Inheritance
VertexContent
Inherited Members

Remarks

This class combines a collection of arbitrarily named data channels with a list of position indices that reference the Positions collection of the parent MeshContent.

Properties

Channels

Gets the list of named vertex data channels in the VertexContent.

public VertexChannelCollection Channels { get; }

Property Value

VertexChannelCollection

Collection of vertex data channels.

PositionIndices

Gets the list of position indices.

public VertexChannel<int> PositionIndices { get; }

Property Value

VertexChannel<int>

Position of the position index being retrieved.

Remarks

This list adds a level of indirection between the actual triangle indices and the Positions member of the parent. This indirection preserves the topological vertex identity in cases where a single vertex position is used by triangles that straddle a discontinuity in some other data channel. For example, the following code gets the position of the first vertex of the first triangle in a GeometryContent object: parent.Positions[Vertices.PositionIndices[Indices[0]]]

Positions

Gets position data from the parent mesh object.

public IndirectPositionCollection Positions { get; }

Property Value

IndirectPositionCollection

Collection of vertex positions for the mesh.

Remarks

The collection returned from this call provides a virtualized view of the vertex positions for this batch. The collection uses the contents of the PositionIndices property to index into the parent Positions. This collection is read-only. If you need to modify any contained values, edit the PositionIndices or Positions members directly.

VertexCount

Number of vertices for the content.

public int VertexCount { get; }

Property Value

int

Number of vertices.

Methods

Add(int)

Appends a new vertex index to the end of the PositionIndices collection. Other vertex channels will automatically be extended and the new indices populated with default values.

public int Add(int positionIndex)

Parameters

positionIndex int

Index into the MeshContent.Positions member of the parent.

Returns

int

Index of the new entry. This can be added to the Indices member of the parent.

AddRange(IEnumerable<int>)

Appends multiple vertex indices to the end of the PositionIndices collection. Other vertex channels will automatically be extended and the new indices populated with default values.

public void AddRange(IEnumerable<int> positionIndexCollection)

Parameters

positionIndexCollection IEnumerable<int>

Index into the Positions member of the parent.

CreateVertexBuffer()

Converts design-time vertex position and channel data into a vertex buffer format that a graphics device can recognize.

public VertexBufferContent CreateVertexBuffer()

Returns

VertexBufferContent

A packed vertex buffer.

Exceptions

InvalidContentException

One or more of the vertex channel types are invalid or an unrecognized name was passed to VertexElementUsage.

Insert(int, int)

Inserts a new vertex index to the PositionIndices collection. Other vertex channels will automatically be extended and the new indices populated with default values.

public void Insert(int index, int positionIndex)

Parameters

index int

Vertex index to be inserted.

positionIndex int

Position of new vertex index in the collection.

InsertRange(int, IEnumerable<int>)

Inserts multiple vertex indices to the PositionIndices collection. Other vertex channels will automatically be extended and the new indices populated with default values.

public void InsertRange(int index, IEnumerable<int> positionIndexCollection)

Parameters

index int

Vertex index to be inserted.

positionIndexCollection IEnumerable<int>

Position of the first element of the inserted range in the collection.

RemoveAt(int)

Removes a vertex index from the specified location in both PositionIndices and VertexChannel<T>.

public void RemoveAt(int index)

Parameters

index int

Index of the vertex to be removed.

RemoveRange(int, int)

Removes a range of vertex indices from the specified location in both PositionIndices and VertexChannel<T>.

public void RemoveRange(int index, int count)

Parameters

index int

Index of the first vertex index to be removed.

count int

Number of indices to remove.