class_gridmap.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the GridMap.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_GridMap:
  5. GridMap
  6. =======
  7. **Inherits:** :ref:`Spatial<class_spatial>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Node for 3D tile-based maps.
  12. Member Functions
  13. ----------------
  14. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`clear<class_GridMap_clear>` **(** **)** |
  16. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`clear_baked_meshes<class_GridMap_clear_baked_meshes>` **(** **)** |
  18. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`RID<class_rid>` | :ref:`get_bake_mesh_instance<class_GridMap_get_bake_mesh_instance>` **(** :ref:`int<class_int>` idx **)** |
  20. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Array<class_array>` | :ref:`get_bake_meshes<class_GridMap_get_bake_meshes>` **(** **)** |
  22. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_cell_item<class_GridMap_get_cell_item>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const |
  24. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`get_cell_item_orientation<class_GridMap_get_cell_item_orientation>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const |
  26. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Vector3<class_vector3>` | :ref:`get_cell_size<class_GridMap_get_cell_size>` **(** **)** const |
  28. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`get_center_x<class_GridMap_get_center_x>` **(** **)** const |
  30. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`get_center_y<class_GridMap_get_center_y>` **(** **)** const |
  32. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`get_center_z<class_GridMap_get_center_z>` **(** **)** const |
  34. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_GridMap_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** const |
  36. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_GridMap_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** const |
  38. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Array<class_array>` | :ref:`get_meshes<class_GridMap_get_meshes>` **(** **)** |
  40. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_octant_size<class_GridMap_get_octant_size>` **(** **)** const |
  42. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`MeshLibrary<class_meshlibrary>` | :ref:`get_theme<class_GridMap_get_theme>` **(** **)** const |
  44. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Array<class_array>` | :ref:`get_used_cells<class_GridMap_get_used_cells>` **(** **)** const |
  46. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`make_baked_meshes<class_GridMap_make_baked_meshes>` **(** :ref:`bool<class_bool>` gen_lightmap_uv=false, :ref:`float<class_float>` lightmap_uv_texel_size=0.1 **)** |
  48. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Vector3<class_vector3>` | :ref:`map_to_world<class_GridMap_map_to_world>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const |
  50. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`resource_changed<class_GridMap_resource_changed>` **(** :ref:`Resource<class_resource>` resource **)** |
  52. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_cell_item<class_GridMap_set_cell_item>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z, :ref:`int<class_int>` item, :ref:`int<class_int>` orientation=0 **)** |
  54. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_cell_size<class_GridMap_set_cell_size>` **(** :ref:`Vector3<class_vector3>` size **)** |
  56. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_center_x<class_GridMap_set_center_x>` **(** :ref:`bool<class_bool>` enable **)** |
  58. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_center_y<class_GridMap_set_center_y>` **(** :ref:`bool<class_bool>` enable **)** |
  60. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_center_z<class_GridMap_set_center_z>` **(** :ref:`bool<class_bool>` enable **)** |
  62. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_clip<class_GridMap_set_clip>` **(** :ref:`bool<class_bool>` enabled, :ref:`bool<class_bool>` clipabove=true, :ref:`int<class_int>` floor=0, :ref:`int<class_int>` axis=0 **)** |
  64. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`set_collision_layer_bit<class_GridMap_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  66. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_collision_mask_bit<class_GridMap_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  68. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`set_octant_size<class_GridMap_set_octant_size>` **(** :ref:`int<class_int>` size **)** |
  70. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`set_theme<class_GridMap_set_theme>` **(** :ref:`MeshLibrary<class_meshlibrary>` theme **)** |
  72. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`Vector3<class_vector3>` | :ref:`world_to_map<class_GridMap_world_to_map>` **(** :ref:`Vector3<class_vector3>` pos **)** const |
  74. +----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. Member Variables
  76. ----------------
  77. .. _class_GridMap_collision_layer:
  78. - :ref:`int<class_int>` **collision_layer**
  79. .. _class_GridMap_collision_mask:
  80. - :ref:`int<class_int>` **collision_mask**
  81. Numeric Constants
  82. -----------------
  83. - **INVALID_CELL_ITEM** = **-1** --- Invalid cell item that can be used in :ref:`set_cell_item<class_GridMap_set_cell_item>` to clear cells (or represent an empty cell in :ref:`get_cell_item<class_GridMap_get_cell_item>`).
  84. Description
  85. -----------
  86. GridMap lets you place meshes on a grid interactively. It works both from the editor and can help you create in-game level editors.
  87. GridMaps use a :ref:`MeshLibrary<class_meshlibrary>` which contain a list of tiles: meshes with materials plus optional collisions and extra elements.
  88. A GridMap contains a collection of cells. Each grid cell refers to a :ref:`MeshLibrary<class_meshlibrary>` item. All cells in the map have the same dimensions.
  89. 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.
  90. Member Function Description
  91. ---------------------------
  92. .. _class_GridMap_clear:
  93. - void **clear** **(** **)**
  94. Clear all cells.
  95. .. _class_GridMap_clear_baked_meshes:
  96. - void **clear_baked_meshes** **(** **)**
  97. .. _class_GridMap_get_bake_mesh_instance:
  98. - :ref:`RID<class_rid>` **get_bake_mesh_instance** **(** :ref:`int<class_int>` idx **)**
  99. .. _class_GridMap_get_bake_meshes:
  100. - :ref:`Array<class_array>` **get_bake_meshes** **(** **)**
  101. .. _class_GridMap_get_cell_item:
  102. - :ref:`int<class_int>` **get_cell_item** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  103. The :ref:`MeshLibrary<class_meshlibrary>` item index located at the grid-based X, Y and Z coordinates. If the cell is empty, INVALID_CELL_ITEM will be returned.
  104. .. _class_GridMap_get_cell_item_orientation:
  105. - :ref:`int<class_int>` **get_cell_item_orientation** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  106. The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is retuned if the cell is empty.
  107. .. _class_GridMap_get_cell_size:
  108. - :ref:`Vector3<class_vector3>` **get_cell_size** **(** **)** const
  109. The dimensions of the grid's cells.
  110. .. _class_GridMap_get_center_x:
  111. - :ref:`bool<class_bool>` **get_center_x** **(** **)** const
  112. Returns whether or not grid items are centered on the X axis.
  113. .. _class_GridMap_get_center_y:
  114. - :ref:`bool<class_bool>` **get_center_y** **(** **)** const
  115. Returns whether or not grid items are centered on the Y axis.
  116. .. _class_GridMap_get_center_z:
  117. - :ref:`bool<class_bool>` **get_center_z** **(** **)** const
  118. Returns whether or not grid items are centered on the Z axis.
  119. .. _class_GridMap_get_collision_layer_bit:
  120. - :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** const
  121. .. _class_GridMap_get_collision_mask_bit:
  122. - :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** const
  123. .. _class_GridMap_get_meshes:
  124. - :ref:`Array<class_array>` **get_meshes** **(** **)**
  125. Array of :ref:`Transform<class_transform>` and :ref:`Mesh<class_mesh>` references corresponding to the non empty cells in the grid. The transforms are specified in world space.
  126. .. _class_GridMap_get_octant_size:
  127. - :ref:`int<class_int>` **get_octant_size** **(** **)** const
  128. The size of each octant measured in number of cells. This applies to all three axis.
  129. .. _class_GridMap_get_theme:
  130. - :ref:`MeshLibrary<class_meshlibrary>` **get_theme** **(** **)** const
  131. The assigned :ref:`MeshLibrary<class_meshlibrary>`.
  132. .. _class_GridMap_get_used_cells:
  133. - :ref:`Array<class_array>` **get_used_cells** **(** **)** const
  134. Array of :ref:`Vector3<class_vector3>` with the non empty cell coordinates in the grid map.
  135. .. _class_GridMap_make_baked_meshes:
  136. - void **make_baked_meshes** **(** :ref:`bool<class_bool>` gen_lightmap_uv=false, :ref:`float<class_float>` lightmap_uv_texel_size=0.1 **)**
  137. .. _class_GridMap_map_to_world:
  138. - :ref:`Vector3<class_vector3>` **map_to_world** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  139. .. _class_GridMap_resource_changed:
  140. - void **resource_changed** **(** :ref:`Resource<class_resource>` resource **)**
  141. .. _class_GridMap_set_cell_item:
  142. - void **set_cell_item** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z, :ref:`int<class_int>` item, :ref:`int<class_int>` orientation=0 **)**
  143. Set the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.
  144. A negative item index will clear the cell.
  145. Optionally, the item's orientation can be passed.
  146. .. _class_GridMap_set_cell_size:
  147. - void **set_cell_size** **(** :ref:`Vector3<class_vector3>` size **)**
  148. Sets the height, width and depth of the grid's cells.
  149. .. _class_GridMap_set_center_x:
  150. - void **set_center_x** **(** :ref:`bool<class_bool>` enable **)**
  151. Set grid items to be centered on the X axis. By default it is enabled.
  152. .. _class_GridMap_set_center_y:
  153. - void **set_center_y** **(** :ref:`bool<class_bool>` enable **)**
  154. Set grid items to be centered on the Y axis. By default it is enabled.
  155. .. _class_GridMap_set_center_z:
  156. - void **set_center_z** **(** :ref:`bool<class_bool>` enable **)**
  157. Set grid items to be centered on the Z axis. By default it is enabled.
  158. .. _class_GridMap_set_clip:
  159. - void **set_clip** **(** :ref:`bool<class_bool>` enabled, :ref:`bool<class_bool>` clipabove=true, :ref:`int<class_int>` floor=0, :ref:`int<class_int>` axis=0 **)**
  160. .. _class_GridMap_set_collision_layer_bit:
  161. - void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  162. .. _class_GridMap_set_collision_mask_bit:
  163. - void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  164. .. _class_GridMap_set_octant_size:
  165. - void **set_octant_size** **(** :ref:`int<class_int>` size **)**
  166. Sets the size for each octant measured in number of cells. This applies to all three axis.
  167. .. _class_GridMap_set_theme:
  168. - void **set_theme** **(** :ref:`MeshLibrary<class_meshlibrary>` theme **)**
  169. Sets the collection of meshes for the map.
  170. .. _class_GridMap_world_to_map:
  171. - :ref:`Vector3<class_vector3>` **world_to_map** **(** :ref:`Vector3<class_vector3>` pos **)** const