class_meshlibrary.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the MeshLibrary.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_MeshLibrary:
  6. MeshLibrary
  7. ===========
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Library of meshes.
  10. Description
  11. -----------
  12. A library of meshes. Contains a list of :ref:`Mesh<class_Mesh>` resources, each with a name and ID. Each item can also include collision and navigation shapes. This resource is used in :ref:`GridMap<class_GridMap>`.
  13. Tutorials
  14. ---------
  15. - `3D Kinematic Character Demo <https://godotengine.org/asset-library/asset/126>`__
  16. - `3D Platformer Demo <https://godotengine.org/asset-library/asset/125>`__
  17. Methods
  18. -------
  19. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`clear<class_MeshLibrary_method_clear>` **(** **)** |
  21. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`create_item<class_MeshLibrary_method_create_item>` **(** :ref:`int<class_int>` id **)** |
  23. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`find_item_by_name<class_MeshLibrary_method_find_item_by_name>` **(** :ref:`String<class_String>` name **)** |const| |
  25. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`get_item_list<class_MeshLibrary_method_get_item_list>` **(** **)** |const| |
  27. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Mesh<class_Mesh>` | :ref:`get_item_mesh<class_MeshLibrary_method_get_item_mesh>` **(** :ref:`int<class_int>` id **)** |const| |
  29. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Transform<class_Transform>` | :ref:`get_item_mesh_transform<class_MeshLibrary_method_get_item_mesh_transform>` **(** :ref:`int<class_int>` id **)** |const| |
  31. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`String<class_String>` | :ref:`get_item_name<class_MeshLibrary_method_get_item_name>` **(** :ref:`int<class_int>` id **)** |const| |
  33. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`NavigationMesh<class_NavigationMesh>` | :ref:`get_item_navmesh<class_MeshLibrary_method_get_item_navmesh>` **(** :ref:`int<class_int>` id **)** |const| |
  35. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Transform<class_Transform>` | :ref:`get_item_navmesh_transform<class_MeshLibrary_method_get_item_navmesh_transform>` **(** :ref:`int<class_int>` id **)** |const| |
  37. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Texture<class_Texture>` | :ref:`get_item_preview<class_MeshLibrary_method_get_item_preview>` **(** :ref:`int<class_int>` id **)** |const| |
  39. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Array<class_Array>` | :ref:`get_item_shapes<class_MeshLibrary_method_get_item_shapes>` **(** :ref:`int<class_int>` id **)** |const| |
  41. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_last_unused_item_id<class_MeshLibrary_method_get_last_unused_item_id>` **(** **)** |const| |
  43. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`remove_item<class_MeshLibrary_method_remove_item>` **(** :ref:`int<class_int>` id **)** |
  45. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_item_mesh<class_MeshLibrary_method_set_item_mesh>` **(** :ref:`int<class_int>` id, :ref:`Mesh<class_Mesh>` mesh **)** |
  47. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_item_mesh_transform<class_MeshLibrary_method_set_item_mesh_transform>` **(** :ref:`int<class_int>` id, :ref:`Transform<class_Transform>` mesh_transform **)** |
  49. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_item_name<class_MeshLibrary_method_set_item_name>` **(** :ref:`int<class_int>` id, :ref:`String<class_String>` name **)** |
  51. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_item_navmesh<class_MeshLibrary_method_set_item_navmesh>` **(** :ref:`int<class_int>` id, :ref:`NavigationMesh<class_NavigationMesh>` navmesh **)** |
  53. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_item_navmesh_transform<class_MeshLibrary_method_set_item_navmesh_transform>` **(** :ref:`int<class_int>` id, :ref:`Transform<class_Transform>` navmesh **)** |
  55. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_item_preview<class_MeshLibrary_method_set_item_preview>` **(** :ref:`int<class_int>` id, :ref:`Texture<class_Texture>` texture **)** |
  57. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_item_shapes<class_MeshLibrary_method_set_item_shapes>` **(** :ref:`int<class_int>` id, :ref:`Array<class_Array>` shapes **)** |
  59. +---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. Method Descriptions
  61. -------------------
  62. .. _class_MeshLibrary_method_clear:
  63. - void **clear** **(** **)**
  64. Clears the library.
  65. ----
  66. .. _class_MeshLibrary_method_create_item:
  67. - void **create_item** **(** :ref:`int<class_int>` id **)**
  68. Creates a new item in the library with the given ID.
  69. You can get an unused ID from :ref:`get_last_unused_item_id<class_MeshLibrary_method_get_last_unused_item_id>`.
  70. ----
  71. .. _class_MeshLibrary_method_find_item_by_name:
  72. - :ref:`int<class_int>` **find_item_by_name** **(** :ref:`String<class_String>` name **)** |const|
  73. Returns the first item with the given name.
  74. ----
  75. .. _class_MeshLibrary_method_get_item_list:
  76. - :ref:`PoolIntArray<class_PoolIntArray>` **get_item_list** **(** **)** |const|
  77. Returns the list of item IDs in use.
  78. ----
  79. .. _class_MeshLibrary_method_get_item_mesh:
  80. - :ref:`Mesh<class_Mesh>` **get_item_mesh** **(** :ref:`int<class_int>` id **)** |const|
  81. Returns the item's mesh.
  82. ----
  83. .. _class_MeshLibrary_method_get_item_mesh_transform:
  84. - :ref:`Transform<class_Transform>` **get_item_mesh_transform** **(** :ref:`int<class_int>` id **)** |const|
  85. Returns the transform applied to the item's mesh.
  86. ----
  87. .. _class_MeshLibrary_method_get_item_name:
  88. - :ref:`String<class_String>` **get_item_name** **(** :ref:`int<class_int>` id **)** |const|
  89. Returns the item's name.
  90. ----
  91. .. _class_MeshLibrary_method_get_item_navmesh:
  92. - :ref:`NavigationMesh<class_NavigationMesh>` **get_item_navmesh** **(** :ref:`int<class_int>` id **)** |const|
  93. Returns the item's navigation mesh.
  94. ----
  95. .. _class_MeshLibrary_method_get_item_navmesh_transform:
  96. - :ref:`Transform<class_Transform>` **get_item_navmesh_transform** **(** :ref:`int<class_int>` id **)** |const|
  97. Returns the transform applied to the item's navigation mesh.
  98. ----
  99. .. _class_MeshLibrary_method_get_item_preview:
  100. - :ref:`Texture<class_Texture>` **get_item_preview** **(** :ref:`int<class_int>` id **)** |const|
  101. When running in the editor, returns a generated item preview (a 3D rendering in isometric perspective). When used in a running project, returns the manually-defined item preview which can be set using :ref:`set_item_preview<class_MeshLibrary_method_set_item_preview>`. Returns an empty :ref:`Texture<class_Texture>` if no preview was manually set in a running project.
  102. ----
  103. .. _class_MeshLibrary_method_get_item_shapes:
  104. - :ref:`Array<class_Array>` **get_item_shapes** **(** :ref:`int<class_int>` id **)** |const|
  105. Returns an item's collision shapes.
  106. The array consists of each :ref:`Shape<class_Shape>` followed by its :ref:`Transform<class_Transform>`.
  107. ----
  108. .. _class_MeshLibrary_method_get_last_unused_item_id:
  109. - :ref:`int<class_int>` **get_last_unused_item_id** **(** **)** |const|
  110. Gets an unused ID for a new item.
  111. ----
  112. .. _class_MeshLibrary_method_remove_item:
  113. - void **remove_item** **(** :ref:`int<class_int>` id **)**
  114. Removes the item.
  115. ----
  116. .. _class_MeshLibrary_method_set_item_mesh:
  117. - void **set_item_mesh** **(** :ref:`int<class_int>` id, :ref:`Mesh<class_Mesh>` mesh **)**
  118. Sets the item's mesh.
  119. ----
  120. .. _class_MeshLibrary_method_set_item_mesh_transform:
  121. - void **set_item_mesh_transform** **(** :ref:`int<class_int>` id, :ref:`Transform<class_Transform>` mesh_transform **)**
  122. Sets the transform to apply to the item's mesh.
  123. ----
  124. .. _class_MeshLibrary_method_set_item_name:
  125. - void **set_item_name** **(** :ref:`int<class_int>` id, :ref:`String<class_String>` name **)**
  126. Sets the item's name.
  127. This name is shown in the editor. It can also be used to look up the item later using :ref:`find_item_by_name<class_MeshLibrary_method_find_item_by_name>`.
  128. ----
  129. .. _class_MeshLibrary_method_set_item_navmesh:
  130. - void **set_item_navmesh** **(** :ref:`int<class_int>` id, :ref:`NavigationMesh<class_NavigationMesh>` navmesh **)**
  131. Sets the item's navigation mesh.
  132. ----
  133. .. _class_MeshLibrary_method_set_item_navmesh_transform:
  134. - void **set_item_navmesh_transform** **(** :ref:`int<class_int>` id, :ref:`Transform<class_Transform>` navmesh **)**
  135. Sets the transform to apply to the item's navigation mesh.
  136. ----
  137. .. _class_MeshLibrary_method_set_item_preview:
  138. - void **set_item_preview** **(** :ref:`int<class_int>` id, :ref:`Texture<class_Texture>` texture **)**
  139. Sets a texture to use as the item's preview icon in the editor.
  140. ----
  141. .. _class_MeshLibrary_method_set_item_shapes:
  142. - void **set_item_shapes** **(** :ref:`int<class_int>` id, :ref:`Array<class_Array>` shapes **)**
  143. Sets an item's collision shapes.
  144. The array should consist of :ref:`Shape<class_Shape>` objects, each followed by a :ref:`Transform<class_Transform>` that will be applied to it. For shapes that should not have a transform, use :ref:`Transform.IDENTITY<class_Transform_constant_IDENTITY>`.
  145. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  146. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  147. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`