Table of Contents

Class ReferenceGrid

Namespace
Stride.CommunityToolkit.Shapes
Assembly
Stride.CommunityToolkit.Shapes.dll

A grid with numbered lines that shows where things are: in world coordinates, the ones models and physics bodies use, or in screen coordinates, the pixels a ShapeBatch draws in with Screen on.

[DataContract("ReferenceGrid")]
[Display("Reference grid", null)]
[ComponentCategory("Debug")]
public class ReferenceGrid : SyncScript, IIdentifiable, ICollectorHolder
Inheritance
ReferenceGrid
Implements
Inherited Members
Extension Methods

Examples

var grid = game.AddGrid();

grid.Space = GridSpace.Screen;
grid.ToggleKey = Keys.None;

Remarks

The two spaces differ in three ways, and the grid shows all three. World coordinates start at the world's origin, count in world units and have Y pointing up. Screen coordinates start at the top left corner of the window, count in pixels and have Y pointing down.

In world space the grid lies in the XY plane under an orthographic camera, as in a 2D scene, and on the ground plane XZ under a perspective one, where it covers a square of Extent around the origin with a short Y axis standing in the middle. The axes have Game Studio's colours: X red, Y green, Z blue. The step between the lines follows the zoom in jumps of 1, 2 and 5, unless MajorStep fixes it.

Add one with game.AddGrid(). ToggleKey steps through off, world and screen; Cycle(), Visible and Space do the same from code.

Fields

AxisXColor

The X axis colour, as in Game Studio.

public static readonly Color AxisXColor

Field Value

Color

AxisYColor

The Y axis colour, as in Game Studio.

public static readonly Color AxisYColor

Field Value

Color

AxisZColor

The Z axis colour, as in Game Studio.

public static readonly Color AxisZColor

Field Value

Color

Properties

Extent

The side of the square the grid covers on the ground plane, in world units. Defaults to 20.

public float Extent { get; set; }

Property Value

float

FontSize

The size of the numbers, in pixels on a 100% display. Defaults to 12.

public float FontSize { get; set; }

Property Value

float

LineColor

The colour of the lines that are not axes. Defaults to white.

public Color LineColor { get; set; }

Property Value

Color

MajorOpacity

The opacity of the major lines, 0 to 1. Defaults to 0.25.

public float MajorOpacity { get; set; }

Property Value

float

MajorStep

The distance between major lines in world units, or 0, the default, to choose it from the zoom so that the lines stay about a hundred pixels apart.

public float MajorStep { get; set; }

Property Value

float

MinorDivisions

How many minor steps make one major step in world space, or 0, the default, to choose four or five so that the minor lines fall on round numbers.

public int MinorDivisions { get; set; }

Property Value

int

MinorOpacity

The opacity of the minor lines, 0 to 1. Defaults to 0.1.

public float MinorOpacity { get; set; }

Property Value

float

Plane

The plane of the world grid. Defaults to Auto.

public GridPlane Plane { get; set; }

Property Value

GridPlane

ScreenMinorDivisions

How many minor steps make one major step in screen space. Defaults to 4.

public int ScreenMinorDivisions { get; set; }

Property Value

int

ScreenStep

The distance between major lines in screen space, in pixels. Defaults to 100.

public float ScreenStep { get; set; }

Property Value

float

ShowCursor

Whether the coordinates under the mouse are written beside it, in both spaces. Defaults to true.

public bool ShowCursor { get; set; }

Property Value

bool

ShowNumbers

Whether the major lines are numbered and the axes lettered. Defaults to true.

public bool ShowNumbers { get; set; }

Property Value

bool

Space

The coordinates the grid shows. Defaults to World.

public GridSpace Space { get; set; }

Property Value

GridSpace

ToggleKey

The key that steps through off, world and screen, or None for no key. Defaults to G. While a key is set, the text overlay names it.

public Keys ToggleKey { get; set; }

Property Value

Keys

Visible

Whether the grid is drawn. Defaults to true.

public bool Visible { get; set; }

Property Value

bool

Methods

Cancel()

public override void Cancel()

Cycle()

Steps to the next state: from hidden to world, from world to screen, from screen to hidden.

public void Cycle()

Start()

public override void Start()

Update()

public override void Update()