class MeshData

Contains mesh vertex and index data used for initializing, updating and reading mesh data from Mesh.

Public

Constructors

MeshData

MeshData(u32 vertexCount, u32 indexCount, const SPtr<VertexDescription> &vertexDescription, IndexType indexType = IT_32BIT)

Constructs a new object that can hold number of vertices described by the provided vertex data description.

As well as a number of indices of the provided type.

Methods

~MeshData

~MeshData() noexcept

SetVertexData

void SetVertexData(VertexElementSemantic semantic, void *data, u32 size, u32 semanticIndex = 0, u32 streamIndex = 0)

Copies data from parameter into the internal buffer for the specified semantic.

semantic
Semantic that allows the engine to connect the data to a shader input slot.
data
Vertex data, containing at least bytes.
size
The size of the data. Must be the size of the vertex element type * number of vertices.
semanticIndex
(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
streamIndex
(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.

GetVertexData

void GetVertexData(VertexElementSemantic semantic, void *data, u32 size, u32 semanticIndex = 0, u32 streamIndex = 0)

Copies data from the internal buffer to the pre-allocated buffer for the specified semantic.

semantic
Semantic that allows the engine to connect the data to a shader input slot.
data
Buffer that will receive vertex data, of at least bytes.
size
The size of the data. Must be the size of the vertex element type * number of vertices.
semanticIndex
(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
streamIndex
(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.

GetVec2DataIter

VertexElemIterator<Vector2> GetVec2DataIter(VertexElementSemantic semantic, u32 semanticIndex = 0, u32 streamIndex = 0)

Returns an iterator you can use for easily retrieving or setting Vector2 vertex elements.

This is the preferred method of assigning or reading vertex data.

GetVec3DataIter

VertexElemIterator<Vector3> GetVec3DataIter(VertexElementSemantic semantic, u32 semanticIndex = 0, u32 streamIndex = 0)

Returns an iterator you can use for easily retrieving or setting Vector3 vertex elements.

This is the preferred method of assigning or reading vertex data.

GetVec4DataIter

VertexElemIterator<Vector4> GetVec4DataIter(VertexElementSemantic semantic, u32 semanticIndex = 0, u32 streamIndex = 0)

Returns an iterator you can use for easily retrieving or setting Vector4 vertex elements.

This is the preferred method of assigning or reading vertex data.

GetDwordDataIter

VertexElemIterator<u32> GetDwordDataIter(VertexElementSemantic semantic, u32 semanticIndex = 0, u32 streamIndex = 0)

Returns an iterator you can use for easily retrieving or setting DWORD vertex elements.

This is the preferred method of assigning or reading vertex data.

GetVertexCount

u32 GetVertexCount() const

Returns the total number of vertices this object can hold.

GetIndexCount

u32 GetIndexCount() const

Returns the total number of indices this object can hold.

GetIndices16

u16 *GetIndices16() const

Returns a 16-bit pointer to the start of the internal index buffer.

GetIndices32

u32 *GetIndices32() const

Returns a 32-bit pointer to the start of the internal index buffer.

GetIndexElementSize

u32 GetIndexElementSize() const

Returns the size of an index element in bytes.

GetIndexType

IndexType GetIndexType() const

Returns the type of an index element.

GetElementData

u8 *GetElementData(VertexElementSemantic semantic, u32 semanticIndex = 0, u32 streamIndex = 0) const

Returns the pointer to the first element of the specified type.

If you want to iterate over all elements you need to call getVertexStride() to get the number of bytes you need to advance between each element.

semantic
Semantic that allows the engine to connect the data to a shader input slot.
semanticIndex
(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
streamIndex
(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.

Returns: null if it fails, else the element data.

GetElementOffset

u32 GetElementOffset(VertexElementSemantic semantic, u32 semanticIndex = 0, u32 streamIndex = 0) const

Returns an offset into the internal buffer where this element with the provided semantic starts.

Offset is provided in number of bytes.

semantic
Semantic that allows the engine to connect the data to a shader input slot.
semanticIndex
(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
streamIndex
(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.

GetIndexData

u8 *GetIndexData() const

Returns a pointer to the start of the index buffer.

GetStreamData

u8 *GetStreamData(u32 streamIndex) const

Returns a pointer to the start of the specified vertex stream.

GetStreamSize

u32 GetStreamSize(u32 streamIndex) const

Returns the size of the specified stream in bytes.

GetStreamSize

u32 GetStreamSize() const

Returns the size of all the streams in bytes.

GetVertexDescription

const SPtr<VertexDescription> &GetVertexDescription() const

Returns an object that describes data contained in a single vertex.

GetSize

u32 GetSize() const

Return the size (in bytes) of the entire buffer.

CalculateBounds

Bounds CalculateBounds() const

Calculates the bounds of all vertices stored in the internal buffer.

staticCombine

static SPtr<MeshData> Combine(const Vector<SPtr<MeshData>> &elements, const Vector<Vector<SubMesh>> &allSubMeshes, Vector<SubMesh> &subMeshes)

Combines a number of submeshes and their mesh data into one large mesh data buffer.

elements
Data containing vertices and indices referenced by the submeshes. Number of elements must be the same as number of submeshes.
allSubMeshes
Submeshes representing vertex and index range to take from mesh data and combine. Number of submeshes must match the number of provided MeshData elements.
subMeshes
Outputs all combined sub-meshes with their new index and vertex offsets referencing the newly created MeshData.

Returns: Combined mesh data containing all vertices and indexes references by the provided sub-meshes.

staticCreate

static SPtr<MeshData> Create(u32 vertexCount, u32 indexCount, const SPtr<VertexDescription> &vertexDescription, IndexType indexType = IT_32BIT)

Constructs a new object that can hold number of vertices described by the provided vertex data description.

As well as a number of indices of the provided type.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Protected

Methods

GetInternalBufferSize

u32 GetInternalBufferSize() const override

Returns the size of the internal buffer in bytes.

Private

Constructors

MeshData

MeshData()

*********************************************************************

Methods

GetIndexBufferOffset

u32 GetIndexBufferOffset() const

Returns an offset in bytes to the start of the index buffer from the start of the internal buffer.

GetStreamOffset

u32 GetStreamOffset(u32 streamIdx = 0) const

Returns an offset in bytes to the start of the stream from the start of the internal buffer.

GetIndexBufferSize

u32 GetIndexBufferSize() const

Returns the size of the index buffer in bytes.

GetDataForIterator

void GetDataForIterator(VertexElementSemantic semantic, u32 semanticIndex, u32 streamIndex, u8 *&data, u32 &stride) const

Returns the data needed for iterating over the requested vertex element.

semantic
Semantic of the element we are looking for.
semanticIndex
If there are multiple semantics with the same name, use different index to differentiate between them.
streamIndex
Zero-based index of the stream the element resides in.
data
Pointer to the start of this elements data.
stride
Number of bytes between vertex elements of this type.

Fields

mDescBuilding

u32 mDescBuilding

mVertexCount

u32 mVertexCount

mIndexCount

u32 mIndexCount

mIndexType

IndexType mIndexType

mVertexDescription

SPtr<VertexDescription> mVertexDescription