Table of Contents

Class Procedural2DModelBuilder

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

A helper class for generating 2D procedural models based on a specified primitive model type and size.

public static class Procedural2DModelBuilder
Inheritance
Procedural2DModelBuilder

Methods

Build(Primitive2DModelType, Vector2?, float, Vector2[]?)

Generates a 2D procedural model based on the specified primitive model type, size, depth, and custom vertices.

public static PrimitiveProceduralModelBase Build(Primitive2DModelType type, Vector2? size = null, float depth = 0, Vector2[]? vertices = null)

Parameters

type Primitive2DModelType

The type of 2D primitive model to create (e.g., Circle, Square, Triangle).

size Vector2?

The size parameters for the model as a Vector2, where X and Y represent the dimensions. If null, default dimensions for the model type will be used.

depth float

The depth of the 2D model, which affects its thickness in 3D space.

vertices Vector2[]

Custom polygon vertices in the XY plane. Used only for Polygon and takes precedence over size.

Returns

PrimitiveProceduralModelBase

A PrimitiveProceduralModelBase object representing the generated 2D model.

Remarks

This method creates different types of 2D procedural models (such as Rectangle, Circle, etc.) with the specified size and depth. The depth adds a third dimension to the 2D shape, turning it into a 3D object (e.g., a 2D rectangle becomes a 3D rectangular prism).

Exceptions

InvalidOperationException

Thrown when an unsupported type is specified.