class_gridmap.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the GridMap.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_GridMap:
  6. GridMap
  7. =======
  8. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Node for 3D tile-based maps.
  13. Properties
  14. ----------
  15. +---------------------------------------+------------------------------------------------------------------+--------------------+
  16. | :ref:`bool<class_bool>` | :ref:`cell_center_x<class_GridMap_property_cell_center_x>` | true |
  17. +---------------------------------------+------------------------------------------------------------------+--------------------+
  18. | :ref:`bool<class_bool>` | :ref:`cell_center_y<class_GridMap_property_cell_center_y>` | true |
  19. +---------------------------------------+------------------------------------------------------------------+--------------------+
  20. | :ref:`bool<class_bool>` | :ref:`cell_center_z<class_GridMap_property_cell_center_z>` | true |
  21. +---------------------------------------+------------------------------------------------------------------+--------------------+
  22. | :ref:`int<class_int>` | :ref:`cell_octant_size<class_GridMap_property_cell_octant_size>` | 8 |
  23. +---------------------------------------+------------------------------------------------------------------+--------------------+
  24. | :ref:`float<class_float>` | :ref:`cell_scale<class_GridMap_property_cell_scale>` | 1.0 |
  25. +---------------------------------------+------------------------------------------------------------------+--------------------+
  26. | :ref:`Vector3<class_Vector3>` | :ref:`cell_size<class_GridMap_property_cell_size>` | Vector3( 2, 2, 2 ) |
  27. +---------------------------------------+------------------------------------------------------------------+--------------------+
  28. | :ref:`int<class_int>` | :ref:`collision_layer<class_GridMap_property_collision_layer>` | 1 |
  29. +---------------------------------------+------------------------------------------------------------------+--------------------+
  30. | :ref:`int<class_int>` | :ref:`collision_mask<class_GridMap_property_collision_mask>` | 1 |
  31. +---------------------------------------+------------------------------------------------------------------+--------------------+
  32. | :ref:`MeshLibrary<class_MeshLibrary>` | :ref:`mesh_library<class_GridMap_property_mesh_library>` | |
  33. +---------------------------------------+------------------------------------------------------------------+--------------------+
  34. Methods
  35. -------
  36. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`clear<class_GridMap_method_clear>` **(** **)** |
  38. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`clear_baked_meshes<class_GridMap_method_clear_baked_meshes>` **(** **)** |
  40. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`RID<class_RID>` | :ref:`get_bake_mesh_instance<class_GridMap_method_get_bake_mesh_instance>` **(** :ref:`int<class_int>` idx **)** |
  42. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Array<class_Array>` | :ref:`get_bake_meshes<class_GridMap_method_get_bake_meshes>` **(** **)** |
  44. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`get_cell_item<class_GridMap_method_get_cell_item>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const |
  46. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_cell_item_orientation<class_GridMap_method_get_cell_item_orientation>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const |
  48. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_GridMap_method_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** const |
  50. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_GridMap_method_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** const |
  52. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Array<class_Array>` | :ref:`get_meshes<class_GridMap_method_get_meshes>` **(** **)** |
  54. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Array<class_Array>` | :ref:`get_used_cells<class_GridMap_method_get_used_cells>` **(** **)** const |
  56. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`make_baked_meshes<class_GridMap_method_make_baked_meshes>` **(** :ref:`bool<class_bool>` gen_lightmap_uv=false, :ref:`float<class_float>` lightmap_uv_texel_size=0.1 **)** |
  58. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Vector3<class_Vector3>` | :ref:`map_to_world<class_GridMap_method_map_to_world>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const |
  60. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`resource_changed<class_GridMap_method_resource_changed>` **(** :ref:`Resource<class_Resource>` resource **)** |
  62. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_cell_item<class_GridMap_method_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 **)** |
  64. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`set_clip<class_GridMap_method_set_clip>` **(** :ref:`bool<class_bool>` enabled, :ref:`bool<class_bool>` clipabove=true, :ref:`int<class_int>` floor=0, Vector3.Axis axis=0 **)** |
  66. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_collision_layer_bit<class_GridMap_method_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  68. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`set_collision_mask_bit<class_GridMap_method_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  70. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector3<class_Vector3>` | :ref:`world_to_map<class_GridMap_method_world_to_map>` **(** :ref:`Vector3<class_Vector3>` pos **)** const |
  72. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. Signals
  74. -------
  75. .. _class_GridMap_signal_cell_size_changed:
  76. - **cell_size_changed** **(** :ref:`Vector3<class_Vector3>` cell_size **)**
  77. Constants
  78. ---------
  79. .. _class_GridMap_constant_INVALID_CELL_ITEM:
  80. - **INVALID_CELL_ITEM** = **-1** --- Invalid cell item that can be used in :ref:`set_cell_item<class_GridMap_method_set_cell_item>` to clear cells (or represent an empty cell in :ref:`get_cell_item<class_GridMap_method_get_cell_item>`).
  81. Description
  82. -----------
  83. GridMap lets you place meshes on a grid interactively. It works both from the editor and can help you create in-game level editors.
  84. GridMaps use a :ref:`MeshLibrary<class_MeshLibrary>` which contain a list of tiles: meshes with materials plus optional collisions and extra elements.
  85. 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.
  86. 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.
  87. Tutorials
  88. ---------
  89. - :doc:`../tutorials/3d/using_gridmaps`
  90. Property Descriptions
  91. ---------------------
  92. .. _class_GridMap_property_cell_center_x:
  93. - :ref:`bool<class_bool>` **cell_center_x**
  94. +-----------+---------------------+
  95. | *Default* | true |
  96. +-----------+---------------------+
  97. | *Setter* | set_center_x(value) |
  98. +-----------+---------------------+
  99. | *Getter* | get_center_x() |
  100. +-----------+---------------------+
  101. If ``true``, grid items are centered on the X axis.
  102. ----
  103. .. _class_GridMap_property_cell_center_y:
  104. - :ref:`bool<class_bool>` **cell_center_y**
  105. +-----------+---------------------+
  106. | *Default* | true |
  107. +-----------+---------------------+
  108. | *Setter* | set_center_y(value) |
  109. +-----------+---------------------+
  110. | *Getter* | get_center_y() |
  111. +-----------+---------------------+
  112. If ``true``, grid items are centered on the Y axis.
  113. ----
  114. .. _class_GridMap_property_cell_center_z:
  115. - :ref:`bool<class_bool>` **cell_center_z**
  116. +-----------+---------------------+
  117. | *Default* | true |
  118. +-----------+---------------------+
  119. | *Setter* | set_center_z(value) |
  120. +-----------+---------------------+
  121. | *Getter* | get_center_z() |
  122. +-----------+---------------------+
  123. If ``true``, grid items are centered on the Z axis.
  124. ----
  125. .. _class_GridMap_property_cell_octant_size:
  126. - :ref:`int<class_int>` **cell_octant_size**
  127. +-----------+------------------------+
  128. | *Default* | 8 |
  129. +-----------+------------------------+
  130. | *Setter* | set_octant_size(value) |
  131. +-----------+------------------------+
  132. | *Getter* | get_octant_size() |
  133. +-----------+------------------------+
  134. The size of each octant measured in number of cells. This applies to all three axis.
  135. ----
  136. .. _class_GridMap_property_cell_scale:
  137. - :ref:`float<class_float>` **cell_scale**
  138. +-----------+-----------------------+
  139. | *Default* | 1.0 |
  140. +-----------+-----------------------+
  141. | *Setter* | set_cell_scale(value) |
  142. +-----------+-----------------------+
  143. | *Getter* | get_cell_scale() |
  144. +-----------+-----------------------+
  145. ----
  146. .. _class_GridMap_property_cell_size:
  147. - :ref:`Vector3<class_Vector3>` **cell_size**
  148. +-----------+----------------------+
  149. | *Default* | Vector3( 2, 2, 2 ) |
  150. +-----------+----------------------+
  151. | *Setter* | set_cell_size(value) |
  152. +-----------+----------------------+
  153. | *Getter* | get_cell_size() |
  154. +-----------+----------------------+
  155. The dimensions of the grid's cells.
  156. ----
  157. .. _class_GridMap_property_collision_layer:
  158. - :ref:`int<class_int>` **collision_layer**
  159. +-----------+----------------------------+
  160. | *Default* | 1 |
  161. +-----------+----------------------------+
  162. | *Setter* | set_collision_layer(value) |
  163. +-----------+----------------------------+
  164. | *Getter* | get_collision_layer() |
  165. +-----------+----------------------------+
  166. ----
  167. .. _class_GridMap_property_collision_mask:
  168. - :ref:`int<class_int>` **collision_mask**
  169. +-----------+---------------------------+
  170. | *Default* | 1 |
  171. +-----------+---------------------------+
  172. | *Setter* | set_collision_mask(value) |
  173. +-----------+---------------------------+
  174. | *Getter* | get_collision_mask() |
  175. +-----------+---------------------------+
  176. ----
  177. .. _class_GridMap_property_mesh_library:
  178. - :ref:`MeshLibrary<class_MeshLibrary>` **mesh_library**
  179. +----------+-------------------------+
  180. | *Setter* | set_mesh_library(value) |
  181. +----------+-------------------------+
  182. | *Getter* | get_mesh_library() |
  183. +----------+-------------------------+
  184. The assigned :ref:`MeshLibrary<class_MeshLibrary>`.
  185. Method Descriptions
  186. -------------------
  187. .. _class_GridMap_method_clear:
  188. - void **clear** **(** **)**
  189. Clear all cells.
  190. ----
  191. .. _class_GridMap_method_clear_baked_meshes:
  192. - void **clear_baked_meshes** **(** **)**
  193. ----
  194. .. _class_GridMap_method_get_bake_mesh_instance:
  195. - :ref:`RID<class_RID>` **get_bake_mesh_instance** **(** :ref:`int<class_int>` idx **)**
  196. ----
  197. .. _class_GridMap_method_get_bake_meshes:
  198. - :ref:`Array<class_Array>` **get_bake_meshes** **(** **)**
  199. ----
  200. .. _class_GridMap_method_get_cell_item:
  201. - :ref:`int<class_int>` **get_cell_item** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  202. The :ref:`MeshLibrary<class_MeshLibrary>` item index located at the grid-based X, Y and Z coordinates. If the cell is empty, :ref:`INVALID_CELL_ITEM<class_GridMap_constant_INVALID_CELL_ITEM>` will be returned.
  203. ----
  204. .. _class_GridMap_method_get_cell_item_orientation:
  205. - :ref:`int<class_int>` **get_cell_item_orientation** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  206. The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is returned if the cell is empty.
  207. ----
  208. .. _class_GridMap_method_get_collision_layer_bit:
  209. - :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** const
  210. ----
  211. .. _class_GridMap_method_get_collision_mask_bit:
  212. - :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** const
  213. ----
  214. .. _class_GridMap_method_get_meshes:
  215. - :ref:`Array<class_Array>` **get_meshes** **(** **)**
  216. 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.
  217. ----
  218. .. _class_GridMap_method_get_used_cells:
  219. - :ref:`Array<class_Array>` **get_used_cells** **(** **)** const
  220. Array of :ref:`Vector3<class_Vector3>` with the non-empty cell coordinates in the grid map.
  221. ----
  222. .. _class_GridMap_method_make_baked_meshes:
  223. - void **make_baked_meshes** **(** :ref:`bool<class_bool>` gen_lightmap_uv=false, :ref:`float<class_float>` lightmap_uv_texel_size=0.1 **)**
  224. ----
  225. .. _class_GridMap_method_map_to_world:
  226. - :ref:`Vector3<class_Vector3>` **map_to_world** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  227. ----
  228. .. _class_GridMap_method_resource_changed:
  229. - void **resource_changed** **(** :ref:`Resource<class_Resource>` resource **)**
  230. ----
  231. .. _class_GridMap_method_set_cell_item:
  232. - 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 **)**
  233. Set the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.
  234. A negative item index will clear the cell.
  235. Optionally, the item's orientation can be passed.
  236. ----
  237. .. _class_GridMap_method_set_clip:
  238. - void **set_clip** **(** :ref:`bool<class_bool>` enabled, :ref:`bool<class_bool>` clipabove=true, :ref:`int<class_int>` floor=0, Vector3.Axis axis=0 **)**
  239. ----
  240. .. _class_GridMap_method_set_collision_layer_bit:
  241. - void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  242. ----
  243. .. _class_GridMap_method_set_collision_mask_bit:
  244. - void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  245. ----
  246. .. _class_GridMap_method_world_to_map:
  247. - :ref:`Vector3<class_Vector3>` **world_to_map** **(** :ref:`Vector3<class_Vector3>` pos **)** const