GridMap

Inherits: Spatial < Node < Object

Nodo para mapas en 3D basados en tiles.

Descripción

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 VisualInstance and therefore can't be hidden or cull masked based on VisualInstance.layers. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.

Tutoriales

Propiedades

bool

cell_center_x

true

bool

cell_center_y

true

bool

cell_center_z

true

int

cell_octant_size

8

float

cell_scale

1.0

Vector3

cell_size

Vector3( 2, 2, 2 )

int

collision_layer

1

int

collision_mask

1

MeshLibrary

mesh_library

bool

use_in_baked_light

false

Métodos

void

clear ( )

void

clear_baked_meshes ( )

RID

get_bake_mesh_instance ( int idx )

Array

get_bake_meshes ( )

int

get_cell_item ( int x, int y, int z ) const

int

get_cell_item_orientation ( int x, int y, int z ) const

bool

get_collision_layer_bit ( int bit ) const

bool

get_collision_mask_bit ( int bit ) const

Array

get_meshes ( )

Array

get_used_cells ( ) const

void

make_baked_meshes ( bool gen_lightmap_uv=false, float lightmap_uv_texel_size=0.1 )

Vector3

map_to_world ( int x, int y, int z ) const

void

resource_changed ( Resource resource )

void

set_cell_item ( int x, int y, int z, int item, int orientation=0 )

void

set_clip ( bool enabled, bool clipabove=true, int floor=0, Vector3.Axis axis=0 )

void

set_collision_layer_bit ( int bit, bool value )

void

set_collision_mask_bit ( int bit, bool value )

Vector3

world_to_map ( Vector3 pos ) const

Señales

  • cell_size_changed ( Vector3 cell_size )

Emitido cuando cell_size cambia.

Constantes

  • INVALID_CELL_ITEM = -1 --- Elemento celular inválido que puede ser usado en set_cell_item para borrar células (o representar una célula vacía en get_cell_item).

Descripciones de Propiedades

  • bool cell_center_x

Default

true

Setter

set_center_x(value)

Getter

get_center_x()

Si true, los elementos de la cuadrícula se centran en el eje X.


  • bool cell_center_y

Default

true

Setter

set_center_y(value)

Getter

get_center_y()

Si true, los elementos de la cuadrícula se centran en el eje Y.


  • bool cell_center_z

Default

true

Setter

set_center_z(value)

Getter

get_center_z()

Si true, los elementos de la cuadrícula se centran en el eje Z.


  • int cell_octant_size

Default

8

Setter

set_octant_size(value)

Getter

get_octant_size()

El tamaño de cada octante medido en número de celdas. Esto se aplica a los tres ejes.


Default

1.0

Setter

set_cell_scale(value)

Getter

get_cell_scale()

La escala de los elementos de celda.

Esto no afecta al tamaño de las celdas de la cuadrícula en sí, sólo a los ítems en ellas. Esto puede ser usado para hacer que los elementos de la celda se superpongan a sus vecinos.


Default

Vector3( 2, 2, 2 )

Setter

set_cell_size(value)

Getter

get_cell_size()

Las dimensiones de las celdas de rejilla.

Esto no afecta al tamaño de las mallas. Ver cell_scale.


  • int collision_layer

Default

1

Setter

set_collision_layer(value)

Getter

get_collision_layer()

Las capas físicas en las que se encuentra este GridMap.

Los GridMaps actúan como cuerpos estáticos, lo que significa que no son afectados por la gravedad u otras fuerzas. Sólo afectan a otros cuerpos físicos que colisionan con ellos.


  • int collision_mask

Default

1

Setter

set_collision_mask(value)

Getter

get_collision_mask()

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


Setter

set_mesh_library(value)

Getter

get_mesh_library()

La MeshLibrary asignada.


  • bool use_in_baked_light

Default

false

Setter

set_use_in_baked_light(value)

Getter

get_use_in_baked_light()

Controls whether this GridMap will be baked in a BakedLightmap or not.

Descripciones de Métodos

  • void clear ( )

Despeja todas las celdas.


  • void clear_baked_meshes ( )


  • RID get_bake_mesh_instance ( int idx )


  • Array get_bake_meshes ( )

Returns an array of ArrayMeshes and Transform references of all bake meshes that exist within the current GridMap.


The MeshLibrary item index located at the grid-based X, Y and Z coordinates. If the cell is empty, INVALID_CELL_ITEM will be returned.


  • int get_cell_item_orientation ( int x, int y, int z ) const

The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is returned if the cell is empty.


  • bool get_collision_layer_bit ( int bit ) const

Devuelve un bit individual en el collision_layer.


  • bool get_collision_mask_bit ( int bit ) const

Devuelve un bit individual en la collision_mask.


Devuelve un array referencias de Transform y Mesh correspondientes a las celdas no vacías de la cuadrícula. Las transformaciones se especifican en el espacio del mundo.


  • Array get_used_cells ( ) const

Devuelve un array de Vector3 con las coordenadas de la celda no vacía en el mapa de la cuadrícula.


  • void make_baked_meshes ( bool gen_lightmap_uv=false, float lightmap_uv_texel_size=0.1 )


Devuelve la posición de una celda de la cuadrícula en el espacio de coordenadas locales del mapa de la cuadrícula.


  • void resource_changed ( Resource resource )


Sets the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.

A negative item index such as INVALID_CELL_ITEM will clear the cell.

Optionally, the item's orientation can be passed. For valid orientation values, see Basis.get_orthogonal_index.


  • void set_clip ( bool enabled, bool clipabove=true, int floor=0, Vector3.Axis axis=0 )


  • void set_collision_layer_bit ( int bit, bool value )

Establece un bit individual en el collision_layer.


  • void set_collision_mask_bit ( int bit, bool value )

Establece un bit individual en la collision_mask.


Devuelve las coordenadas de la celda de la cuadrícula que contiene el punto dado.

pos debería estar en el espacio de coordenadas locales del GridMap.