class_gridmap.rst 19 KB

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