Table of Contents

Class MeshBuilderExtensions

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

Higher-level shapes composed on top of MeshBuilder's per-vertex API.

public static class MeshBuilderExtensions
Inheritance
MeshBuilderExtensions

Methods

AddExtrudedPolygon(MeshBuilder, IReadOnlyList<Vector2>, float, int, int, Vector2)

Adds a 2D polygon extruded along Z: a front cap, a back cap, and flat-shaded side walls.

public static void AddExtrudedPolygon(this MeshBuilder builder, IReadOnlyList<Vector2> outline, float depth, int positionElement, int normalElement, Vector2 offset = default)

Parameters

builder MeshBuilder

The builder to add to. Must have an index type configured, and position and normal elements registered.

outline IReadOnlyList<Vector2>

The polygon's corners in the XY plane, in order, without repeating the first corner. Either winding is accepted. Concave outlines are fine; self-intersecting ones are not.

depth float

How far the shape extends along Z, centred on zero.

positionElement int

The element index returned by WithPosition.

normalElement int

The element index returned by WithNormal.

offset Vector2

An XY offset applied to every corner, so several shapes can be laid out side by side in one mesh.

Remarks

The caps share their corner vertices, but every side wall gets four vertices of its own: a flat normal per wall is what keeps an extruded shape's edges crisp, and that is only possible when walls do not share vertices with each other or with the caps. An n-corner outline therefore costs 6n vertices and 4(n-1) triangles.

This is the mesh half of the 3D letter glyphs: an outline authored in code becomes solid lettering. A shape with a hole, such as O or 8, is built by calling this once per piece with pieces that touch along their edges without overlapping - abutting walls seal invisibly inside the solid, while overlapping pieces would put two caps on the same plane and shimmer.

Exceptions

ArgumentNullException

The builder or outline is null.

ArgumentOutOfRangeException

The depth is not positive.