class_gridmap.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. | :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. | *Default* | true |
  94. +-----------+---------------------+
  95. | *Setter* | set_center_x(value) |
  96. +-----------+---------------------+
  97. | *Getter* | get_center_x() |
  98. +-----------+---------------------+
  99. If ``true``, grid items are centered on the X axis.
  100. .. _class_GridMap_property_cell_center_y:
  101. - :ref:`bool<class_bool>` **cell_center_y**
  102. +-----------+---------------------+
  103. | *Default* | true |
  104. +-----------+---------------------+
  105. | *Setter* | set_center_y(value) |
  106. +-----------+---------------------+
  107. | *Getter* | get_center_y() |
  108. +-----------+---------------------+
  109. If ``true``, grid items are centered on the Y axis.
  110. .. _class_GridMap_property_cell_center_z:
  111. - :ref:`bool<class_bool>` **cell_center_z**
  112. +-----------+---------------------+
  113. | *Default* | true |
  114. +-----------+---------------------+
  115. | *Setter* | set_center_z(value) |
  116. +-----------+---------------------+
  117. | *Getter* | get_center_z() |
  118. +-----------+---------------------+
  119. If ``true``, grid items are centered on the Z axis.
  120. .. _class_GridMap_property_cell_octant_size:
  121. - :ref:`int<class_int>` **cell_octant_size**
  122. +-----------+------------------------+
  123. | *Default* | 8 |
  124. +-----------+------------------------+
  125. | *Setter* | set_octant_size(value) |
  126. +-----------+------------------------+
  127. | *Getter* | get_octant_size() |
  128. +-----------+------------------------+
  129. The size of each octant measured in number of cells. This applies to all three axis.
  130. .. _class_GridMap_property_cell_scale:
  131. - :ref:`float<class_float>` **cell_scale**
  132. +-----------+-----------------------+
  133. | *Default* | 1.0 |
  134. +-----------+-----------------------+
  135. | *Setter* | set_cell_scale(value) |
  136. +-----------+-----------------------+
  137. | *Getter* | get_cell_scale() |
  138. +-----------+-----------------------+
  139. .. _class_GridMap_property_cell_size:
  140. - :ref:`Vector3<class_Vector3>` **cell_size**
  141. +-----------+----------------------+
  142. | *Default* | Vector3( 2, 2, 2 ) |
  143. +-----------+----------------------+
  144. | *Setter* | set_cell_size(value) |
  145. +-----------+----------------------+
  146. | *Getter* | get_cell_size() |
  147. +-----------+----------------------+
  148. The dimensions of the grid's cells.
  149. .. _class_GridMap_property_collision_layer:
  150. - :ref:`int<class_int>` **collision_layer**
  151. +-----------+----------------------------+
  152. | *Default* | 1 |
  153. +-----------+----------------------------+
  154. | *Setter* | set_collision_layer(value) |
  155. +-----------+----------------------------+
  156. | *Getter* | get_collision_layer() |
  157. +-----------+----------------------------+
  158. .. _class_GridMap_property_collision_mask:
  159. - :ref:`int<class_int>` **collision_mask**
  160. +-----------+---------------------------+
  161. | *Default* | 1 |
  162. +-----------+---------------------------+
  163. | *Setter* | set_collision_mask(value) |
  164. +-----------+---------------------------+
  165. | *Getter* | get_collision_mask() |
  166. +-----------+---------------------------+
  167. .. _class_GridMap_property_mesh_library:
  168. - :ref:`MeshLibrary<class_MeshLibrary>` **mesh_library**
  169. +----------+-------------------------+
  170. | *Setter* | set_mesh_library(value) |
  171. +----------+-------------------------+
  172. | *Getter* | get_mesh_library() |
  173. +----------+-------------------------+
  174. The assigned :ref:`MeshLibrary<class_MeshLibrary>`.
  175. .. _class_GridMap_property_theme:
  176. - :ref:`MeshLibrary<class_MeshLibrary>` **theme**
  177. +----------+------------------+
  178. | *Setter* | set_theme(value) |
  179. +----------+------------------+
  180. | *Getter* | get_theme() |
  181. +----------+------------------+
  182. Deprecated, use :ref:`mesh_library<class_GridMap_property_mesh_library>` instead.
  183. Method Descriptions
  184. -------------------
  185. .. _class_GridMap_method_clear:
  186. - void **clear** **(** **)**
  187. Clear all cells.
  188. .. _class_GridMap_method_clear_baked_meshes:
  189. - void **clear_baked_meshes** **(** **)**
  190. .. _class_GridMap_method_get_bake_mesh_instance:
  191. - :ref:`RID<class_RID>` **get_bake_mesh_instance** **(** :ref:`int<class_int>` idx **)**
  192. .. _class_GridMap_method_get_bake_meshes:
  193. - :ref:`Array<class_Array>` **get_bake_meshes** **(** **)**
  194. .. _class_GridMap_method_get_cell_item:
  195. - :ref:`int<class_int>` **get_cell_item** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  196. 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.
  197. .. _class_GridMap_method_get_cell_item_orientation:
  198. - :ref:`int<class_int>` **get_cell_item_orientation** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  199. The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is returned if the cell is empty.
  200. .. _class_GridMap_method_get_collision_layer_bit:
  201. - :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** const
  202. .. _class_GridMap_method_get_collision_mask_bit:
  203. - :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** const
  204. .. _class_GridMap_method_get_meshes:
  205. - :ref:`Array<class_Array>` **get_meshes** **(** **)**
  206. 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.
  207. .. _class_GridMap_method_get_used_cells:
  208. - :ref:`Array<class_Array>` **get_used_cells** **(** **)** const
  209. Array of :ref:`Vector3<class_Vector3>` with the non-empty cell coordinates in the grid map.
  210. .. _class_GridMap_method_make_baked_meshes:
  211. - void **make_baked_meshes** **(** :ref:`bool<class_bool>` gen_lightmap_uv=false, :ref:`float<class_float>` lightmap_uv_texel_size=0.1 **)**
  212. .. _class_GridMap_method_map_to_world:
  213. - :ref:`Vector3<class_Vector3>` **map_to_world** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** const
  214. .. _class_GridMap_method_resource_changed:
  215. - void **resource_changed** **(** :ref:`Resource<class_Resource>` resource **)**
  216. .. _class_GridMap_method_set_cell_item:
  217. - 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 **)**
  218. Set the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.
  219. A negative item index will clear the cell.
  220. Optionally, the item's orientation can be passed.
  221. .. _class_GridMap_method_set_clip:
  222. - void **set_clip** **(** :ref:`bool<class_bool>` enabled, :ref:`bool<class_bool>` clipabove=true, :ref:`int<class_int>` floor=0, Vector3.Axis axis=0 **)**
  223. .. _class_GridMap_method_set_collision_layer_bit:
  224. - void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  225. .. _class_GridMap_method_set_collision_mask_bit:
  226. - void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  227. .. _class_GridMap_method_world_to_map:
  228. - :ref:`Vector3<class_Vector3>` **world_to_map** **(** :ref:`Vector3<class_Vector3>` pos **)** const