reckfellENGINE

GridMap

Entity for 3D tile-based maps.

On this page
class GridMapReckfellSharpInherits Entity3D

Entity for 3D tile-based maps.

GridMap lets you place meshes on a grid interactively. It works both from the editor and from scripts, which can help you create in-game level editors. GridMaps use a MeshLibrary which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes. A GridMap contains a collection of cells. Each grid cell refers to a tile in the MeshLibrary. All cells in the map have the same dimensions. Internally, a GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells. Note: GridMap doesn't extend VisualInstance3D and therefore can't be hidden or cull masked based on VisualInstance3D.Layers. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

GridMapConstructor
# GridMap
C#
public GridMap();

Properties15

BakeNavigationProperty
# BakeNavigation
C#
public bool BakeNavigation { get; set; }

If true, this GridMap creates a navigation region for each cell that uses a GridMap.MeshLibrary item with a navigation mesh. The created navigation region will use the navigation layers bitmask assigned to the MeshLibrary's item.

CellCenterXProperty
# CellCenterX
C#
public bool CellCenterX { get; set; }

If true, grid items are centered on the X axis.

CellCenterYProperty
# CellCenterY
C#
public bool CellCenterY { get; set; }

If true, grid items are centered on the Y axis.

CellCenterZProperty
# CellCenterZ
C#
public bool CellCenterZ { get; set; }

If true, grid items are centered on the Z axis.

CellOctantSizeProperty
# CellOctantSize
C#
public int CellOctantSize { get; set; }

The size of each octant measured in number of cells. This applies to all three axis.

CellScaleProperty
# CellScale
C#
public float CellScale { get; set; }

Placed-item basis scale, affecting both meshes and physics shapes. Does not change CellSize or MapToLocal. A value of 0.5 shrinks blocks while retaining the original cell spacing.

CellSizeProperty
# CellSize
C#
public Vector3 CellSize { get; set; }

Grid spacing on three axes. Changes cell spacing/placement, not source MeshLibrary mesh dimensions. Match module dimensions separately; CellScale controls placed mesh and shape scale.

CollisionLayerProperty
# CollisionLayer
C#
public uint CollisionLayer { get; set; }

The physics layers this GridMap is in. GridMaps act as static bodies, meaning they aren't affected by gravity or other forces. They only affect other physics bodies that collide with them.

CollisionMaskProperty
# CollisionMask
C#
public uint CollisionMask { get; set; }

The physics layers this GridMap detects collisions in. See Collision layers and masks in the documentation for more information.

CollisionPriorityProperty
# CollisionPriority
C#
public float CollisionPriority { get; set; }

The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.

CollisionVisibilityModeProperty
# CollisionVisibilityMode
C#
public GridMap.DebugVisibilityMode CollisionVisibilityMode { get; set; }

Show or hide the GridMap's collision shapes. If set to GridMap.DebugVisibilityMode.Default, this depends on the show collision debug settings.

DebugOctantColorProperty
# DebugOctantColor
C#
public Color DebugOctantColor { get; set; }

The Color used for rendering octant debug visuals when GridMap.DebugShowOctants is enabled.

DebugShowOctantsProperty
# DebugShowOctants
C#
public bool DebugShowOctants { get; set; }

If true, shows debug visuals for octants.

MeshLibraryProperty
# MeshLibrary
C#
public MeshLibrary MeshLibrary { get; set; }

Shared grid-item resource: IDs, meshes, transforms and separate physics shapes. Meshes do not automatically create collision. Current persistence is verified with contiguous IDs 0 and 1; sparse 0/7 loses item 7 data through a .rdata roundtrip despite Error.Ok.

PhysicsMaterialProperty
# PhysicsMaterial
C#
public PhysicsMaterial PhysicsMaterial { get; set; }

Overrides the default friction and bounce physics properties for the whole GridMap.

Methods60

Clearvoid
# Clear
C#
public void Clear();

Clear all cells.

ClearBakedMeshesvoid
# ClearBakedMeshes
C#
public void ClearBakedMeshes();

Clears all baked meshes. See GridMap.MakeBakedMeshes.

GetBakeMeshInstanceRid
# GetBakeMeshInstance
C#
public Rid GetBakeMeshInstance(int idx);

Returns Rid of a baked mesh with the given idx.

Parameters
NameTypeDefault
idxint—
Returns Rid
GetBakeMeshesReckfell.Collections.Array
# GetBakeMeshes
C#
public Reckfell.Collections.Array GetBakeMeshes();

Returns an array of ArrayMeshes and Transform3D references of all bake meshes that exist within the current GridMap. Even indices contain ArrayMeshes, while odd indices contain Transform3Ds that are always equal to Transform3D.Identity. This method relies on the output of GridMap.MakeBakedMeshes, which will be called with gen_lightmap_uv set to true and lightmap_uv_texel_size set to 0.1 if it hasn't been called yet.

Returns Reckfell.Collections.Array
GetBasisWithOrthogonalIndexBasis
# GetBasisWithOrthogonalIndex
C#
public Basis GetBasisWithOrthogonalIndex(int index);

Returns one of 24 possible rotations that lie along the vectors (x,y,z) with each component being either -1, 0, or 1. For further details, refer to the Reckfell source code.

Parameters
NameTypeDefault
indexint—
Returns Basis
GetCellItemint
# GetCellItem
C#
public int GetCellItem(Vector3I position);

Reads the stored cell ID. An ID does not prove a matching MeshLibrary item, ready physics or visible geometry.

Parameters
NameTypeDefault
positionVector3I—
position

Grid cell coordinate.

Returns int

Item ID, or -1 for an empty cell. Internal IDs are 16-bit; validate the range before SetCellItem.

GetCellItemBasisBasis
# GetCellItemBasis
C#
public Basis GetCellItemBasis(Vector3I position);

Returns the basis that gives the specified cell its orientation.

Parameters
NameTypeDefault
positionVector3I—
Returns Basis
GetCellItemOrientationint
# GetCellItemOrientation
C#
public int GetCellItemOrientation(Vector3I position);

Reads a cell orientation index, not Euler angles. Use GetCellItemBasis or GetBasisWithOrthogonalIndex for its Basis.

Parameters
NameTypeDefault
positionVector3I—
Returns int

Index 0..23 for a correctly assigned orthogonal orientation; -1 for an empty cell. Do not supply out-of-contract SetCellItem orientations.

GetCellScalefloat
# GetCellScale
C#
public float GetCellScale();
Returns float
GetCellSizeVector3
# GetCellSize
C#
public Vector3 GetCellSize();
Returns Vector3
GetCenterXbool
# GetCenterX
C#
public bool GetCenterX();
Returns bool
GetCenterYbool
# GetCenterY
C#
public bool GetCenterY();
Returns bool
GetCenterZbool
# GetCenterZ
C#
public bool GetCenterZ();
Returns bool
GetCollisionLayeruint
# GetCollisionLayer
C#
public uint GetCollisionLayer();
Returns uint
GetCollisionLayerValuebool
# GetCollisionLayerValue
C#
public bool GetCollisionLayerValue(int layerNumber);

Returns whether or not the specified layer of the GridMap.CollisionLayer is enabled, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetCollisionMaskuint
# GetCollisionMask
C#
public uint GetCollisionMask();
Returns uint
GetCollisionMaskValuebool
# GetCollisionMaskValue
C#
public bool GetCollisionMaskValue(int layerNumber);

Returns whether or not the specified layer of the GridMap.CollisionMask is enabled, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetCollisionPriorityfloat
# GetCollisionPriority
C#
public float GetCollisionPriority();
Returns float
GetCollisionVisibilityModeGridMap.DebugVisibilityMode
# GetCollisionVisibilityMode
C#
public GridMap.DebugVisibilityMode GetCollisionVisibilityMode();
Returns GridMap.DebugVisibilityMode
GetDebugOctantColorColor
# GetDebugOctantColor
C#
public Color GetDebugOctantColor();
Returns Color
GetDebugShowOctantsbool
# GetDebugShowOctants
C#
public bool GetDebugShowOctants();
Returns bool
GetMeshLibraryMeshLibrary
# GetMeshLibrary
C#
public MeshLibrary GetMeshLibrary();
Returns MeshLibrary
GetMeshesReckfell.Collections.Array
# GetMeshes
C#
public Reckfell.Collections.Array GetMeshes();

Returns transform/mesh pairs for existing items. Not a list of entities or colliders; a stored unknown item ID can be absent from this result.

Returns Reckfell.Collections.Array

Array alternating Transform3D and Mesh. Array Count is twice the pair count, not a cell count.

GetNavigationMapRid
# GetNavigationMap
C#
public Rid GetNavigationMap();

Returns the Rid of the navigation map this GridMap node uses for its cell baked navigation meshes. This function returns always the map set on the GridMap node and not the map on the NavigationServer. If the map is changed directly with the NavigationServer API the GridMap node will not be aware of the map change.

Returns Rid
GetOctantCoordsFromCellCoordsVector3I
# GetOctantCoordsFromCellCoords
C#
public Vector3I GetOctantCoordsFromCellCoords(Vector3I cellCoords);

Returns the Vector3I octant coordinates of the octant that the cell at cell_coords belongs to.

Parameters
NameTypeDefault
cellCoordsVector3I—
Returns Vector3I
GetOctantSizeint
# GetOctantSize
C#
public int GetOctantSize();
Returns int
GetOctantsInBoundsReckfell.Collections.Array<Vector3I>
# GetOctantsInBounds
C#
public Reckfell.Collections.Array<Vector3I> GetOctantsInBounds(Aabb bounds);

Returns an array of Vector3I octant coordinates that are inside the given bounds, including octants that have no cells in use.

Parameters
NameTypeDefault
boundsAabb—
Returns Reckfell.Collections.Array<Vector3I>
GetOrthogonalIndexFromBasisint
# GetOrthogonalIndexFromBasis
C#
public int GetOrthogonalIndexFromBasis(Basis basis);

This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index (in the range from 0 to 23) of the point best representing the orientation of the object. For further details, refer to the Reckfell source code.

Parameters
NameTypeDefault
basisBasis—
Returns int
GetPhysicsMaterialPhysicsMaterial
# GetPhysicsMaterial
C#
public PhysicsMaterial GetPhysicsMaterial();
Returns PhysicsMaterial
GetUsedCellsReckfell.Collections.Array<Vector3I>
# GetUsedCells
C#
public Reckfell.Collections.Array<Vector3I> GetUsedCells();

Returns an array of Vector3 with the non-empty cell coordinates in the grid map.

Returns Reckfell.Collections.Array<Vector3I>
GetUsedCellsByItemReckfell.Collections.Array<Vector3I>
# GetUsedCellsByItem
C#
public Reckfell.Collections.Array<Vector3I> GetUsedCellsByItem(int item);

Returns an array of all cells with the given item index specified in item.

Parameters
NameTypeDefault
itemint—
Returns Reckfell.Collections.Array<Vector3I>
GetUsedCellsInOctantReckfell.Collections.Array<Vector3I>
# GetUsedCellsInOctant
C#
public Reckfell.Collections.Array<Vector3I> GetUsedCellsInOctant(Vector3I octantCoords);

Returns an array of Vector3Is with the cell coordinates of non-empty cells inside the octant at octant_coords.

Parameters
NameTypeDefault
octantCoordsVector3I—
Returns Reckfell.Collections.Array<Vector3I>
GetUsedCellsInOctantByItemReckfell.Collections.Array<Vector3I>
# GetUsedCellsInOctantByItem
C#
public Reckfell.Collections.Array<Vector3I> GetUsedCellsInOctantByItem(Vector3I octantCoords, int item);

Returns an array of Vector3Is with the cell coordinates of cells inside the octant at octant_coords that use the specified cell item.

Parameters
NameTypeDefault
octantCoordsVector3I—
itemint—
Returns Reckfell.Collections.Array<Vector3I>
GetUsedOctantsReckfell.Collections.Array<Vector3I>
# GetUsedOctants
C#
public Reckfell.Collections.Array<Vector3I> GetUsedOctants();

Returns an array of Vector3Is with the octant coordinates of the non-empty octants in the grid map.

Returns Reckfell.Collections.Array<Vector3I>
GetUsedOctantsByItemReckfell.Collections.Array<Vector3I>
# GetUsedOctantsByItem
C#
public Reckfell.Collections.Array<Vector3I> GetUsedOctantsByItem(int item);

Returns an array of Vector3Is with the octant coordinates of the octants that use the specified item in the grid map.

Parameters
NameTypeDefault
itemint—
Returns Reckfell.Collections.Array<Vector3I>
GetUsedOctantsInBoundsReckfell.Collections.Array<Vector3I>
# GetUsedOctantsInBounds
C#
public Reckfell.Collections.Array<Vector3I> GetUsedOctantsInBounds(Aabb bounds);

Returns an array of Vector3Is with the octant coordinates of non-empty octants that are inside the local bounds.

Parameters
NameTypeDefault
boundsAabb—
Returns Reckfell.Collections.Array<Vector3I>
IsBakingNavigationbool
# IsBakingNavigation
C#
public bool IsBakingNavigation();
Returns bool
LocalToMapVector3I
# LocalToMap
C#
public Vector3I LocalToMap(Vector3 localPosition);

Divides a local position by CellSize and floors each axis. Convert world positions through ToLocal first; integer-casting division is incorrect for negative coordinates.

Parameters
NameTypeDefault
localPositionVector3—
localPosition

GridMap-local position, not an unconverted world-space ray-hit point.

Returns Vector3I

Cell coordinate. With size 2, point (-0.01,-0.01,-0.01) belongs to (-1,-1,-1). For a point exactly on a surface, account for the boundary side and hit normal.

MakeBakedMeshesvoid
# MakeBakedMeshes
C#
public void MakeBakedMeshes(bool genLightmapUV = false, float lightmapUVTexelSize = 0.1f);

Generates a baked mesh that represents all meshes in the assigned MeshLibrary for use with LightmapGI. If gen_lightmap_uv is true, UV2 data will be generated for each mesh currently used in the GridMap. Otherwise, only meshes that already have UV2 data present will be able to use baked lightmaps. When generating UV2, lightmap_uv_texel_size controls the texel density for lightmaps, with lower values resulting in more detailed lightmaps. lightmap_uv_texel_size is ignored if gen_lightmap_uv is false. See also GridMap.GetBakeMeshes, which relies on the output of this method. Note: Calling this method will not actually bake lightmaps, as lightmap baking is performed using the LightmapGI node.

Parameters
NameTypeDefault
genLightmapUVboolfalse
lightmapUVTexelSizefloat0.1f
MapToLocalVector3
# MapToLocal
C#
public Vector3 MapToLocal(Vector3I mapPosition);

Converts a cell coordinate to local position using CellSize and per-axis CellCenterX/Y/Z. Not necessarily the mesh center: MeshLibrary has separate item transforms.

Parameters
NameTypeDefault
mapPositionVector3I—
mapPosition

Integer cell coordinate.

Returns Vector3

Local cell position. With CellSize=(2,2,2), X/Z centering and Y centering disabled, cell (2,3,-1) gives (5,6,-1). Use ToGlobal for world space.

ResourceChangedvoid · Deprecated
# ResourceChanged
C#
public void ResourceChanged(Resource resource);

This method does nothing.

Parameters
NameTypeDefault
resourceResource—
SetBakeNavigationvoid
# SetBakeNavigation
C#
public void SetBakeNavigation(bool bakeNavigation);
Parameters
NameTypeDefault
bakeNavigationbool—
SetCellItemvoid
# SetCellItem
C#
public void SetCellItem(Vector3I position, int item, int orientation = 0);

Sets the single item in a cell, replacing the previous item. Logical state changes immediately; render and physics octants update later. Validate IDs against GetItemList: an unknown ID can be stored without visible geometry. The verified item field is 16-bit: 65536 becomes 0.

Parameters
NameTypeDefault
positionVector3I—
itemint—
orientationint0
position

Integer cell coordinate, not a position in world units. Source bounds require each coordinate magnitude below 2^20.

item

MeshLibrary ID in 0..65535; a negative value erases the cell. Current library persistence requires contiguous IDs from 0 and reload verification: sparse IDs can lose data.

orientation

Index of one of 24 orthogonal orientations, not degrees. Obtain it through GetOrthogonalIndexFromBasis rather than supplying an arbitrary number.

SetCellScalevoid
# SetCellScale
C#
public void SetCellScale(float scale);
Parameters
NameTypeDefault
scalefloat—
SetCellSizevoid
# SetCellSize
C#
public void SetCellSize(Vector3 size);
Parameters
NameTypeDefault
sizeVector3—
SetCenterXvoid
# SetCenterX
C#
public void SetCenterX(bool enable);
Parameters
NameTypeDefault
enablebool—
SetCenterYvoid
# SetCenterY
C#
public void SetCenterY(bool enable);
Parameters
NameTypeDefault
enablebool—
SetCenterZvoid
# SetCenterZ
C#
public void SetCenterZ(bool enable);
Parameters
NameTypeDefault
enablebool—
SetCollisionLayervoid
# SetCollisionLayer
C#
public void SetCollisionLayer(uint layer);
Parameters
NameTypeDefault
layeruint—
SetCollisionLayerValuevoid
# SetCollisionLayerValue
C#
public void SetCollisionLayerValue(int layerNumber, bool value);

Based on value, enables or disables the specified layer in the GridMap.CollisionLayer, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetCollisionMaskvoid
# SetCollisionMask
C#
public void SetCollisionMask(uint mask);
Parameters
NameTypeDefault
maskuint—
SetCollisionMaskValuevoid
# SetCollisionMaskValue
C#
public void SetCollisionMaskValue(int layerNumber, bool value);

Based on value, enables or disables the specified layer in the GridMap.CollisionMask, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetCollisionPriorityvoid
# SetCollisionPriority
C#
public void SetCollisionPriority(float priority);
Parameters
NameTypeDefault
priorityfloat—
SetCollisionVisibilityModevoid
# SetCollisionVisibilityMode
C#
public void SetCollisionVisibilityMode(GridMap.DebugVisibilityMode visibilityMode);
Parameters
NameTypeDefault
visibilityModeGridMap.DebugVisibilityMode—
SetDebugOctantColorvoid
# SetDebugOctantColor
C#
public void SetDebugOctantColor(Color color);
Parameters
NameTypeDefault
colorColor—
SetDebugShowOctantsvoid
# SetDebugShowOctants
C#
public void SetDebugShowOctants(bool enable);
Parameters
NameTypeDefault
enablebool—
SetMeshLibraryvoid
# SetMeshLibrary
C#
public void SetMeshLibrary(MeshLibrary meshLibrary);
Parameters
NameTypeDefault
meshLibraryMeshLibrary—
SetNavigationMapvoid
# SetNavigationMap
C#
public void SetNavigationMap(Rid navigationMap);

Sets the Rid of the navigation map this GridMap node should use for its cell baked navigation meshes.

Parameters
NameTypeDefault
navigationMapRid—
SetOctantSizevoid
# SetOctantSize
C#
public void SetOctantSize(int size);
Parameters
NameTypeDefault
sizeint—
SetPhysicsMaterialvoid
# SetPhysicsMaterial
C#
public void SetPhysicsMaterial(PhysicsMaterial material);
Parameters
NameTypeDefault
materialPhysicsMaterial—

Signals and events2

CellSizeChangedEvent
# CellSizeChanged
C#
public event GridMap.CellSizeChangedEventHandler CellSizeChanged;

Emitted when GridMap.CellSize changes.

Handler parameters
NameTypeDefault
cellSizeVector3—
ChangedEvent
# Changed
C#
public event Action Changed;

Emitted when the MeshLibrary of this GridMap changes.

Fields and constants1

InvalidCellItemField
# InvalidCellItem
C#
public const long InvalidCellItem = -1;

Invalid cell item that can be used in GridMap.SetCellItem to clear cells (or represent an empty cell in GridMap.GetCellItem).

GridMap.DebugVisibilityMode

ValueDescription
Default = 0

Hide the collisions debug shapes in the editor, and use the debug settings to determine their visibility in game (i.e. EntityTree.DebugCollisionsHint or EntityTree.DebugNavigationHint).

ForceHide = 2

Always hide the collisions debug shapes.

ForceShow = 1

Always show the collisions debug shapes.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.