class_gridmap.rst 19 KB

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