Documentation
¶
Overview ¶
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.
Index ¶
- type Advanced
- type Any
- type CellItem
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AsGridMap() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode3D() Node3D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) BakeNavigation() bool
- func (self Instance) CellCenterX() bool
- func (self Instance) CellCenterY() bool
- func (self Instance) CellCenterZ() bool
- func (self Instance) CellOctantSize() int
- func (self Instance) CellScale() Float.X
- func (self Instance) CellSize() Vector3.XYZ
- func (self Instance) Clear()
- func (self Instance) ClearBakedMeshes()
- func (self Instance) CollisionLayer() int
- func (self Instance) CollisionMask() int
- func (self Instance) CollisionPriority() Float.X
- func (self Instance) GetBakeMeshInstance(idx int) RID.Mesh
- func (self Instance) GetBakeMeshes() []any
- func (self Instance) GetBasisWithOrthogonalIndex(index int) Basis.XYZ
- func (self Instance) GetCellItem(position Vector3i.XYZ) CellItem
- func (self Instance) GetCellItemBasis(position Vector3i.XYZ) Basis.XYZ
- func (self Instance) GetCellItemOrientation(position Vector3i.XYZ) CellItem
- func (self Instance) GetCollisionLayerValue(layer_number int) bool
- func (self Instance) GetCollisionMaskValue(layer_number int) bool
- func (self Instance) GetMeshes() []any
- func (self Instance) GetNavigationMap() RID.NavigationMap3D
- func (self Instance) GetOrthogonalIndexFromBasis(basis Basis.XYZ) int
- func (self Instance) GetUsedCells() []Vector3i.XYZ
- func (self Instance) GetUsedCellsByItem(item CellItem) []Vector3i.XYZ
- func (self Instance) ID() ID
- func (self Instance) LocalToMap(local_position Vector3.XYZ) Vector3i.XYZ
- func (self Instance) MakeBakedMeshes()
- func (self Instance) MapToLocal(map_position Vector3i.XYZ) Vector3.XYZ
- func (self Instance) MeshLibrary() MeshLibrary.Instance
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) OnCellSizeChanged(cb func(cell_size Vector3.XYZ), flags ...Signal.Flags)
- func (self Instance) OnChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) PhysicsMaterial() PhysicsMaterial.Instance
- func (self Instance) ResourceChanged(resource Resource.Instance)
- func (self Instance) SetBakeNavigation(value bool)
- func (self Instance) SetCellCenterX(value bool)
- func (self Instance) SetCellCenterY(value bool)
- func (self Instance) SetCellCenterZ(value bool)
- func (self Instance) SetCellItem(position Vector3i.XYZ, item CellItem)
- func (self Instance) SetCellOctantSize(value int)
- func (self Instance) SetCellScale(value Float.X)
- func (self Instance) SetCellSize(value Vector3.XYZ)
- func (self Instance) SetCollisionLayer(value int)
- func (self Instance) SetCollisionLayerValue(layer_number int, value bool)
- func (self Instance) SetCollisionMask(value int)
- func (self Instance) SetCollisionMaskValue(layer_number int, value bool)
- func (self Instance) SetCollisionPriority(value Float.X)
- func (self Instance) SetMeshLibrary(value MeshLibrary.Instance)
- func (self Instance) SetNavigationMap(navigation_map RID.NavigationMap3D)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPhysicsMaterial(value PhysicsMaterial.Instance)
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type CellItem ¶
type CellItem int
const InvalidCellItem CellItem = -1 //gd:GridMap.INVALID_CELL_ITEM
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) BakeNavigation ¶
If true, this GridMap creates a navigation region for each cell that uses a MeshLibrary item with a navigation mesh. The created navigation region will use the navigation layers bitmask assigned to the MeshLibrary's item.
func (Instance) CellCenterX ¶
If true, grid items are centered on the X axis.
func (Instance) CellCenterY ¶
If true, grid items are centered on the Y axis.
func (Instance) CellCenterZ ¶
If true, grid items are centered on the Z axis.
func (Instance) CellOctantSize ¶
The size of each octant measured in number of cells. This applies to all three axis.
func (Instance) CellScale ¶
The scale of the cell items.
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
func (Instance) CellSize ¶
The dimensions of the grid's cells.
This does not affect the size of the meshes. See CellScale.
func (Instance) ClearBakedMeshes ¶
func (self Instance) ClearBakedMeshes()
Clears all baked meshes. See MakeBakedMeshes.
func (Instance) CollisionLayer ¶
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.
func (Instance) CollisionMask ¶
The physics layers this GridMap detects collisions in. See Collision layers and masks in the documentation for more information.
func (Instance) CollisionPriority ¶
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.
func (Instance) GetBakeMeshInstance ¶
Returns Resource.ID of a baked mesh with the given 'idx'.
func (Instance) GetBakeMeshes ¶
Returns an array of ArrayMeshes and Transform3D.BasisOrigin references of all bake meshes that exist within the current GridMap. Even indices contain ArrayMeshes, while odd indices contain Transform3D.BasisOrigins that are always equal to [Transform3d.Identity].
This method relies on the output of 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.
func (Instance) GetBasisWithOrthogonalIndex ¶
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 Godot source code.
func (Instance) GetCellItem ¶
The MeshLibrary item index located at the given grid coordinates. If the cell is empty, InvalidCellItem will be returned.
func (Instance) GetCellItemBasis ¶
Returns the basis that gives the specified cell its orientation.
func (Instance) GetCellItemOrientation ¶
The orientation of the cell at the given grid coordinates. -1 is returned if the cell is empty.
func (Instance) GetCollisionLayerValue ¶
Returns whether or not the specified layer of the CollisionLayer is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetCollisionMaskValue ¶
Returns whether or not the specified layer of the CollisionMask is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetMeshes ¶
Returns an array of Transform3D.BasisOrigin and Mesh references corresponding to the non-empty cells in the grid. The transforms are specified in local space. Even indices contain Transform3D.BasisOrigins, while odd indices contain Meshes related to the Transform3D.BasisOrigin in the index preceding it.
func (Instance) GetNavigationMap ¶
func (self Instance) GetNavigationMap() RID.NavigationMap3D
Returns the Resource.ID 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.
func (Instance) GetOrthogonalIndexFromBasis ¶
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 Godot source code.
func (Instance) GetUsedCells ¶
Returns an array of Vector3.XYZ with the non-empty cell coordinates in the grid map.
func (Instance) GetUsedCellsByItem ¶
Returns an array of all cells with the given item index specified in 'item'.
func (Instance) LocalToMap ¶
Returns the map coordinates of the cell containing the given 'local_position'. If 'local_position' is in global coordinates, consider using Node3D.ToLocal before passing it to this method. See also MapToLocal.
func (Instance) MakeBakedMeshes ¶
func (self Instance) MakeBakedMeshes()
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 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.
func (Instance) MapToLocal ¶
Returns the position of a grid cell in the GridMap's local coordinate space. To convert the returned value into global coordinates, use Node3D.ToGlobal. See also LocalToMap.
func (Instance) MeshLibrary ¶
func (self Instance) MeshLibrary() MeshLibrary.Instance
The assigned MeshLibrary.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) OnCellSizeChanged ¶
Emitted when CellSize changes.
func (Instance) OnChanged ¶
Emitted when the MeshLibrary of this GridMap changes.
func (Instance) PhysicsMaterial ¶
func (self Instance) PhysicsMaterial() PhysicsMaterial.Instance
Overrides the default friction and bounce physics properties for the whole GridMap.
func (Instance) ResourceChanged ¶
This method does nothing.
func (Instance) SetBakeNavigation ¶
SetBakeNavigation sets the property returned by [IsBakingNavigation].
func (Instance) SetCellCenterX ¶
SetCellCenterX sets the property returned by [GetCenterX].
func (Instance) SetCellCenterY ¶
SetCellCenterY sets the property returned by [GetCenterY].
func (Instance) SetCellCenterZ ¶
SetCellCenterZ sets the property returned by [GetCenterZ].
func (Instance) SetCellItem ¶
Sets the mesh index for the cell referenced by its grid coordinates.
A negative item index such as InvalidCellItem will clear the cell.
Optionally, the item's orientation can be passed. For valid orientation values, see GetOrthogonalIndexFromBasis.
func (Instance) SetCellOctantSize ¶
SetCellOctantSize sets the property returned by [GetOctantSize].
func (Instance) SetCellScale ¶
SetCellScale sets the property returned by [GetCellScale].
func (Instance) SetCellSize ¶
SetCellSize sets the property returned by [GetCellSize].
func (Instance) SetCollisionLayer ¶
SetCollisionLayer sets the property returned by [GetCollisionLayer].
func (Instance) SetCollisionLayerValue ¶
Based on 'value', enables or disables the specified layer in the CollisionLayer, given a 'layer_number' between 1 and 32.
func (Instance) SetCollisionMask ¶
SetCollisionMask sets the property returned by [GetCollisionMask].
func (Instance) SetCollisionMaskValue ¶
Based on 'value', enables or disables the specified layer in the CollisionMask, given a 'layer_number' between 1 and 32.
func (Instance) SetCollisionPriority ¶
SetCollisionPriority sets the property returned by [GetCollisionPriority].
func (Instance) SetMeshLibrary ¶
func (self Instance) SetMeshLibrary(value MeshLibrary.Instance)
SetMeshLibrary sets the property returned by [GetMeshLibrary].
func (Instance) SetNavigationMap ¶
func (self Instance) SetNavigationMap(navigation_map RID.NavigationMap3D)
Sets the Resource.ID of the navigation map this GridMap node should use for its cell baked navigation meshes.
func (Instance) SetPhysicsMaterial ¶
func (self Instance) SetPhysicsMaterial(value PhysicsMaterial.Instance)
SetPhysicsMaterial sets the property returned by [GetPhysicsMaterial].
type MoreArgs ¶
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) MakeBakedMeshes ¶
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 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.
func (MoreArgs) SetCellItem ¶
Sets the mesh index for the cell referenced by its grid coordinates.
A negative item index such as InvalidCellItem will clear the cell.
Optionally, the item's orientation can be passed. For valid orientation values, see GetOrthogonalIndexFromBasis.