Table of Contents

Class Primitive3D

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

A 3D primitive shape with its dimensions: the thing game.CreatePrimitive(Primitive3D.Sphere(0.5f)) builds a model from, and a physics package derives the matching collider from.

public abstract record Primitive3D : IEquatable<Primitive3D>
Inheritance
Primitive3D
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. A sphere takes a radius, a cylinder a radius and a height, a box three extents; there is no shared size whose meaning changes per shape. The defaults are those of Stride's own procedural models, so a factory called with no arguments gives the same mesh as new SphereProceduralModel().

The mesh builder and each physics package switch over the same set, so a shape added to one and missed in the other is a compile error, not a mesh that does not match its collider.

Properties

Name

The shape's name for labels: Cube for a box with three equal extents, otherwise the case's name without its Shape suffix: Box, Sphere, Teapot.

public string Name { get; }

Property Value

string

Methods

Box(Vector3)

A box with the given full extents along X, Y and Z.

public static Primitive3D Box(Vector3 size)

Parameters

size Vector3

Returns

Primitive3D

Capsule(float, float, int)

A capsule: a cylinder of length between two hemispheres of radius, along Y.

public static Primitive3D Capsule(float radius = 0.35, float length = 0.5, int tessellation = 8)

Parameters

radius float
length float
tessellation int

Returns

Primitive3D

Cone(float, float, int)

A cone with the given base radius and height, its apex up.

public static Primitive3D Cone(float radius = 0.5, float height = 1, int tessellation = 16)

Parameters

radius float
height float
tessellation int

Returns

Primitive3D

Cube(float)

A cube size units along every edge.

public static Primitive3D Cube(float size = 1)

Parameters

size float

Returns

Primitive3D

Cylinder(float, float, int)

A cylinder of the given radius and height, along Y.

public static Primitive3D Cylinder(float radius = 0.5, float height = 1, int tessellation = 32)

Parameters

radius float
height float
tessellation int

Returns

Primitive3D

Plane(float, float, int, int)

A flat plane of the given width (X) and length (Z), facing up, optionally subdivided.

public static Primitive3D Plane(float width = 1, float length = 1, int tessellationX = 1, int tessellationY = 1)

Parameters

width float
length float
tessellationX int
tessellationY int

Returns

Primitive3D

Sphere(float, int)

A sphere of the given radius.

public static Primitive3D Sphere(float radius = 0.5, int tessellation = 16)

Parameters

radius float
tessellation int

Returns

Primitive3D

Teapot(float, int)

The Utah teapot, scaled uniformly by size.

public static Primitive3D Teapot(float size = 1, int tessellation = 8)

Parameters

size float
tessellation int

Returns

Primitive3D

Text(string, MeshFont, TextMeshOptions)

Solid lettering with every option of TextMeshOptions: lines, alignment, spacing, curve quality.

public static Primitive3D Text(string text, MeshFont font, TextMeshOptions options)

Parameters

text string
font MeshFont
options TextMeshOptions

Returns

Primitive3D

Text(string, MeshFont?, float, float, TextAnchor?)

Solid lettering: text in font (the toolkit's embedded font when null), size units per EM, extruded depth along Z, with the anchor of the text block at the entity's origin: its centre by default, like every other shape.

public static Primitive3D Text(string text, MeshFont? font = null, float size = 1, float depth = 0.25, TextAnchor? anchor = TextAnchor.MiddleCenter)

Parameters

text string
font MeshFont
size float
depth float
anchor TextAnchor?

Returns

Primitive3D

Torus(float, float, int)

A torus: a ring of radius from the centre to the middle of the tube, whose tube is thickness across.

public static Primitive3D Torus(float radius = 0.375, float thickness = 0.125, int tessellation = 32)

Parameters

radius float
thickness float
tessellation int

Returns

Primitive3D

TriangularPrism(Vector3)

A triangular prism: a triangle X wide and Y tall, extruded Z along the depth.

public static Primitive3D TriangularPrism(Vector3 size)

Parameters

size Vector3

Returns

Primitive3D