toVertexBuffer

Converts the compound mesh data into a single VertexBuffer for rendering.

The method internally triangulates the compound mesh data, calculates the total number of triangles contained within the mesh data, and populates a VertexBuffer with the vertex attributes (e.g., positions, normals, texture coordinates, etc.) required for rendering the mesh.

Return

a VertexBuffer containing the vertex data of the triangulated mesh.


fun IMeshData.toVertexBuffer(elementOffset: Int = 0, vertexBuffer: VertexBuffer? = null): VertexBuffer(source)

Converts the current mesh data into a VertexBuffer representation, preparing geometry for rendering.

The method processes the mesh data, including positions, normals, texture coordinates, colors, tangents, and bitangents, and writes it into a vertex buffer. It uses triangulated geometry to ensure compatibility with rendering pipelines that expect triangles as input.

Return

A VertexBuffer containing the mesh data in the specified format, ready for rendering.

Parameters

elementOffset

The starting offset in the vertex buffer where the mesh data should be written. Defaults to 0.

vertexBuffer

An optional pre-existing VertexBuffer in which to store the data. If not provided, a new VertexBuffer is created with the appropriate format.


fun IVertexData.toVertexBuffer(elementOffset: Int = 0, vertexBuffer: VertexBuffer? = null): VertexBuffer(source)

Converts the vertex data stored in the IVertexData instance to a VertexBuffer. The method iterates through the vertex attributes such as positions, normals, texture coordinates, and colors, and writes them sequentially into the provided or newly created VertexBuffer. Missing attributes are substituted with default values.

Return

A VertexBuffer containing the processed vertex data.

Parameters

elementOffset

The index offset where the vertex data should start being written in the buffer. Defaults to 0 if no offset is specified.

vertexBuffer

An optional existing VertexBuffer instance to be reused. If null, a new buffer will be created.