Table of Contents

Class Primitive2D

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

A flat 2D primitive shape in the XY plane with its dimensions: the thing game.CreatePrimitive(Primitive2D.Circle(0.5f)) builds a model from, and a physics package derives the matching collider from. A 2D shape still lives in a 3D world; the thickness its collider gets along Z is the physics options' Depth, not part of the shape.

public abstract record Primitive2D : IEquatable<Primitive2D>
Inheritance
Primitive2D
Implements
Derived

Remarks

The set is closed: every shape is one of the nested records below, created through the static factories, which name exactly the dimensions the shape has. The defaults are the ones the toolkit's 2D helpers always used.

Properties

Name

The shape's name for labels: Square for a rectangle with equal sides, otherwise the case's name without its Shape suffix: Rectangle, Circle, Polygon.

public string Name { get; }

Property Value

string

Methods

Capsule(float, float, int)

A capsule standing along Y: height from end to end, with semicircular ends of radius.

public static Primitive2D Capsule(float radius = 0.25, float height = 1, int tessellation = 16)

Parameters

radius float
height float
tessellation int

Returns

Primitive2D

Circle(float, int)

A circle of the given radius.

public static Primitive2D Circle(float radius = 0.5, int tessellation = 32)

Parameters

radius float
tessellation int

Returns

Primitive2D

Polygon(params Vector2[])

A convex polygon from its corners, in order around the outline; at least three distinct points.

public static Primitive2D Polygon(params Vector2[] vertices)

Parameters

vertices Vector2[]

Returns

Primitive2D

Rectangle(float, float)

A rectangle of the given width (X) and height (Y).

public static Primitive2D Rectangle(float width = 0.5, float height = 1)

Parameters

width float
height float

Returns

Primitive2D

RegularPolygon(float, int)

A regular polygon with sides corners on a circle of radius.

public static Primitive2D RegularPolygon(float radius = 0.5, int sides = 6)

Parameters

radius float
sides int

Returns

Primitive2D

Square(float)

A square size units along every side.

public static Primitive2D Square(float size = 1)

Parameters

size float

Returns

Primitive2D

Triangle(float, float)

An isosceles triangle width across its base and height from base to apex.

public static Primitive2D Triangle(float width = 1, float height = 1)

Parameters

width float
height float

Returns

Primitive2D