Vixen
02b45cc4
csharp
public static class MeshPrimitives

The shapes the engine can build: a cube, a sphere, and the six others everybody expects.

Read the guide page for this →

Remarks

Geometry and nothing else. What comes back is a MeshData — the same thing an importer produces — so a primitive travels down whatever path an imported mesh does, rather than being a special case that every consumer has to know about. Nothing here touches a device, which is also what makes the whole of it testable without one.

⚠ Every primitive fits inside the unit cube centred on the origin, and there are no exceptions. One rule means a spawn menu can drop any of them at a point and have them all arrive the same size, and it means a scale of 2 means "two metres" for all eight. It costs one thing worth naming: the capsule's radius is a quarter rather than a half, because a capsule one unit wide and one unit tall is a sphere.

Wound counter-clockwise seen from outside, which is FrontFace.CounterClockwise in a right-handed space — the convention Matrix4x4.LookAt establishes for the rest of the engine. Normals point out; texture coordinates run V downwards, as an image does.

No tangents. MeshData treats an empty array as "this mesh has none", which is the truth here — a normal map on a primitive is a thing somebody will want and it is a generator of its own, not four lines bolted onto each of these.

Fields and properties (3)

  • public const int DefaultSegments

    How many segments a curved surface is divided into around its axis.

  • public const int DefaultRings

    How many bands it is divided into along its axis.

  • public const int MinimumSegments

    The lowest either count may be and still describe a solid.

Methods (9)

  • public static MeshData Create(PrimitiveKind kind, int segments = 32, int rings = 16)

    Builds one of the shapes at its standard size.

  • public static MeshData Cube(float size = 1)

    A cube, one face per direction, with hard edges.

  • public static MeshData Sphere(float radius = 0.5, int segments = 32, int rings = 16)

    A sphere, divided by latitude and longitude.

  • public static MeshData Cylinder(float radius = 0.5, float height = 1, int segments = 32)

    A cylinder standing on the Y axis, capped at both ends.

  • public static MeshData Capsule(float radius = 0.25, float height = 1, int segments = 32, int rings = 16)

    A cylinder with a hemisphere on each end.

  • public static MeshData Cone(float radius = 0.5, float height = 1, int segments = 32)

    A cone standing on the Y axis, capped at the bottom.

  • public static MeshData Plane(float size = 1, int divisions = 4)

    A flat square in the ground plane, facing up.

  • public static MeshData Quad(float size = 1)

    A single square standing in the XY plane, facing +Z.

  • public static MeshData Torus(float radius = 0.35, float tube = 0.15, int segments = 32, int sides = 16)

    A torus lying in the ground plane.

Used by (14)

  • EditorGizmoFacingDeviceTestsVixen.Graphics.Golden.Tests
  • MeshExtractionSystemVixen.Rendering
  • MeshExtractionTestsVixen.Rendering.Tests
  • MeshInstanceRendererTestsVixen.Rendering.Tests
  • MeshPrimitivesTestsVixen.Rendering.Tests
  • EditMeshesVixen.Editor.SceneView
  • GizmoGeometryVixen.Editor.SceneView
  • MeshEditVixen.Editor.SceneView
  • PrimitiveShapeTestsVixen.Editor.SceneView.Tests
  • SceneLinesVixen.Editor.SceneView
  • SceneMeshesVixen.Editor.SceneView
  • ScenePickerVixen.Editor.SceneView
  • SceneProbeVixen.Editor.SceneView
  • SubObjectTestsVixen.Editor.SceneView.Tests