Table of Contents

Class GeometricMeshDataExtensions

Namespace
Stride.CommunityToolkit.Rendering
Assembly
Stride.CommunityToolkit.dll

Turns CPU mesh data into something a Mesh can draw.

public static class GeometricMeshDataExtensions
Inheritance
GeometricMeshDataExtensions

Methods

Bounds(GeometricMeshData<VertexPositionNormalTexture>)

The box and the sphere around the vertices.

public static (BoundingBox Box, BoundingSphere Sphere) Bounds(this GeometricMeshData<VertexPositionNormalTexture> meshData)

Parameters

meshData GeometricMeshData<VertexPositionNormalTexture>

The mesh data.

Returns

(BoundingBox Box, BoundingSphere Sphere)

The bounds; empty when there are no vertices.

Exceptions

ArgumentNullException

The mesh data is null.

ToMesh(GeometricMeshData<VertexPositionNormalTexture>, GraphicsDevice, int)

Uploads the mesh data and wraps it in a Mesh with its bounds, which the renderer uses to cull it when it is off screen; a MeshDraw alone has none and is never culled.

public static Mesh ToMesh(this GeometricMeshData<VertexPositionNormalTexture> meshData, GraphicsDevice device, int materialIndex = 0)

Parameters

meshData GeometricMeshData<VertexPositionNormalTexture>

The mesh data.

device GraphicsDevice

The graphics device the buffers are created on.

materialIndex int

The index of the material the mesh uses in its model.

Returns

Mesh

The mesh; the caller owns its draw's buffers, see ToMeshDraw(GeometricMeshData<VertexPositionNormalTexture>, GraphicsDevice).

Exceptions

ArgumentNullException

The mesh data or the device is null.

ArgumentException

The mesh data is empty.

ToMeshDraw(GeometricMeshData<VertexPositionNormalTexture>, GraphicsDevice)

Uploads the vertices and indices to the GPU and wraps them in a MeshDraw.

public static MeshDraw ToMeshDraw(this GeometricMeshData<VertexPositionNormalTexture> meshData, GraphicsDevice device)

Parameters

meshData GeometricMeshData<VertexPositionNormalTexture>

The mesh data, such as a procedural model's or TextMesh's.

device GraphicsDevice

The graphics device the buffers are created on.

Returns

MeshDraw

A draw with a 32-bit index buffer, ready for a Mesh.

Remarks

The caller owns the buffers: nothing tracks them, so dispose VertexBuffers and IndexBuffer when the mesh goes, or a mesh rebuilt every frame leaks a buffer pair per rebuild. ToMesh(GeometricMeshData<VertexPositionNormalTexture>, GraphicsDevice, int) adds the bounds a MeshDraw cannot carry.

Exceptions

ArgumentNullException

The mesh data or the device is null.

ArgumentException

The mesh data has no vertices or no indices: there is nothing to upload, and a GPU buffer cannot be empty. Remove the mesh instead.