class_gridmap.rst 20 KB

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