class_meshinstance3d.rst 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/MeshInstance3D.xml.
  6. .. _class_MeshInstance3D:
  7. MeshInstance3D
  8. ==============
  9. **Inherits:** :ref:`GeometryInstance3D<class_GeometryInstance3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`SoftBody3D<class_SoftBody3D>`
  11. Node that instances meshes into a scenario.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. MeshInstance3D is a node that takes a :ref:`Mesh<class_Mesh>` resource and adds it to the current scenario by creating an instance of it. This is the class most often used to render 3D geometry and can be used to instance a single :ref:`Mesh<class_Mesh>` in many places. This allows reusing geometry, which can save on resources. When a :ref:`Mesh<class_Mesh>` has to be instantiated more than thousands of times at close proximity, consider using a :ref:`MultiMesh<class_MultiMesh>` in a :ref:`MultiMeshInstance3D<class_MultiMeshInstance3D>` instead.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - `3D Material Testers Demo <https://godotengine.org/asset-library/asset/2742>`__
  20. - `3D Kinematic Character Demo <https://godotengine.org/asset-library/asset/2739>`__
  21. - `3D Platformer Demo <https://godotengine.org/asset-library/asset/2748>`__
  22. - `Third Person Shooter (TPS) Demo <https://godotengine.org/asset-library/asset/2710>`__
  23. .. rst-class:: classref-reftable-group
  24. Properties
  25. ----------
  26. .. table::
  27. :widths: auto
  28. +---------------------------------+---------------------------------------------------------+--------------------+
  29. | :ref:`Mesh<class_Mesh>` | :ref:`mesh<class_MeshInstance3D_property_mesh>` | |
  30. +---------------------------------+---------------------------------------------------------+--------------------+
  31. | :ref:`NodePath<class_NodePath>` | :ref:`skeleton<class_MeshInstance3D_property_skeleton>` | ``NodePath("..")`` |
  32. +---------------------------------+---------------------------------------------------------+--------------------+
  33. | :ref:`Skin<class_Skin>` | :ref:`skin<class_MeshInstance3D_property_skin>` | |
  34. +---------------------------------+---------------------------------------------------------+--------------------+
  35. .. rst-class:: classref-reftable-group
  36. Methods
  37. -------
  38. .. table::
  39. :widths: auto
  40. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`ArrayMesh<class_ArrayMesh>` | :ref:`bake_mesh_from_current_blend_shape_mix<class_MeshInstance3D_method_bake_mesh_from_current_blend_shape_mix>`\ (\ existing\: :ref:`ArrayMesh<class_ArrayMesh>` = null\ ) |
  42. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`ArrayMesh<class_ArrayMesh>` | :ref:`bake_mesh_from_current_skeleton_pose<class_MeshInstance3D_method_bake_mesh_from_current_skeleton_pose>`\ (\ existing\: :ref:`ArrayMesh<class_ArrayMesh>` = null\ ) |
  44. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | |void| | :ref:`create_convex_collision<class_MeshInstance3D_method_create_convex_collision>`\ (\ clean\: :ref:`bool<class_bool>` = true, simplify\: :ref:`bool<class_bool>` = false\ ) |
  46. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | |void| | :ref:`create_debug_tangents<class_MeshInstance3D_method_create_debug_tangents>`\ (\ ) |
  48. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | |void| | :ref:`create_multiple_convex_collisions<class_MeshInstance3D_method_create_multiple_convex_collisions>`\ (\ settings\: :ref:`MeshConvexDecompositionSettings<class_MeshConvexDecompositionSettings>` = null\ ) |
  50. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | |void| | :ref:`create_trimesh_collision<class_MeshInstance3D_method_create_trimesh_collision>`\ (\ ) |
  52. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`find_blend_shape_by_name<class_MeshInstance3D_method_find_blend_shape_by_name>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
  54. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Material<class_Material>` | :ref:`get_active_material<class_MeshInstance3D_method_get_active_material>`\ (\ surface\: :ref:`int<class_int>`\ ) |const| |
  56. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_blend_shape_count<class_MeshInstance3D_method_get_blend_shape_count>`\ (\ ) |const| |
  58. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`float<class_float>` | :ref:`get_blend_shape_value<class_MeshInstance3D_method_get_blend_shape_value>`\ (\ blend_shape_idx\: :ref:`int<class_int>`\ ) |const| |
  60. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`SkinReference<class_SkinReference>` | :ref:`get_skin_reference<class_MeshInstance3D_method_get_skin_reference>`\ (\ ) |const| |
  62. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Material<class_Material>` | :ref:`get_surface_override_material<class_MeshInstance3D_method_get_surface_override_material>`\ (\ surface\: :ref:`int<class_int>`\ ) |const| |
  64. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`get_surface_override_material_count<class_MeshInstance3D_method_get_surface_override_material_count>`\ (\ ) |const| |
  66. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | |void| | :ref:`set_blend_shape_value<class_MeshInstance3D_method_set_blend_shape_value>`\ (\ blend_shape_idx\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
  68. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | |void| | :ref:`set_surface_override_material<class_MeshInstance3D_method_set_surface_override_material>`\ (\ surface\: :ref:`int<class_int>`, material\: :ref:`Material<class_Material>`\ ) |
  70. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. .. rst-class:: classref-section-separator
  72. ----
  73. .. rst-class:: classref-descriptions-group
  74. Property Descriptions
  75. ---------------------
  76. .. _class_MeshInstance3D_property_mesh:
  77. .. rst-class:: classref-property
  78. :ref:`Mesh<class_Mesh>` **mesh** :ref:`🔗<class_MeshInstance3D_property_mesh>`
  79. .. rst-class:: classref-property-setget
  80. - |void| **set_mesh**\ (\ value\: :ref:`Mesh<class_Mesh>`\ )
  81. - :ref:`Mesh<class_Mesh>` **get_mesh**\ (\ )
  82. The :ref:`Mesh<class_Mesh>` resource for the instance.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_MeshInstance3D_property_skeleton:
  86. .. rst-class:: classref-property
  87. :ref:`NodePath<class_NodePath>` **skeleton** = ``NodePath("..")`` :ref:`🔗<class_MeshInstance3D_property_skeleton>`
  88. .. rst-class:: classref-property-setget
  89. - |void| **set_skeleton_path**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
  90. - :ref:`NodePath<class_NodePath>` **get_skeleton_path**\ (\ )
  91. :ref:`NodePath<class_NodePath>` to the :ref:`Skeleton3D<class_Skeleton3D>` associated with the instance.
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_MeshInstance3D_property_skin:
  95. .. rst-class:: classref-property
  96. :ref:`Skin<class_Skin>` **skin** :ref:`🔗<class_MeshInstance3D_property_skin>`
  97. .. rst-class:: classref-property-setget
  98. - |void| **set_skin**\ (\ value\: :ref:`Skin<class_Skin>`\ )
  99. - :ref:`Skin<class_Skin>` **get_skin**\ (\ )
  100. The :ref:`Skin<class_Skin>` to be used by this instance.
  101. .. rst-class:: classref-section-separator
  102. ----
  103. .. rst-class:: classref-descriptions-group
  104. Method Descriptions
  105. -------------------
  106. .. _class_MeshInstance3D_method_bake_mesh_from_current_blend_shape_mix:
  107. .. rst-class:: classref-method
  108. :ref:`ArrayMesh<class_ArrayMesh>` **bake_mesh_from_current_blend_shape_mix**\ (\ existing\: :ref:`ArrayMesh<class_ArrayMesh>` = null\ ) :ref:`🔗<class_MeshInstance3D_method_bake_mesh_from_current_blend_shape_mix>`
  109. Takes a snapshot from the current :ref:`ArrayMesh<class_ArrayMesh>` with all blend shapes applied according to their current weights and bakes it to the provided ``existing`` mesh. If no ``existing`` mesh is provided a new :ref:`ArrayMesh<class_ArrayMesh>` is created, baked and returned. Mesh surface materials are not copied.
  110. \ **Performance:** :ref:`Mesh<class_Mesh>` data needs to be received from the GPU, stalling the :ref:`RenderingServer<class_RenderingServer>` in the process.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_MeshInstance3D_method_bake_mesh_from_current_skeleton_pose:
  114. .. rst-class:: classref-method
  115. :ref:`ArrayMesh<class_ArrayMesh>` **bake_mesh_from_current_skeleton_pose**\ (\ existing\: :ref:`ArrayMesh<class_ArrayMesh>` = null\ ) :ref:`🔗<class_MeshInstance3D_method_bake_mesh_from_current_skeleton_pose>`
  116. Takes a snapshot of the current animated skeleton pose of the skinned mesh and bakes it to the provided ``existing`` mesh. If no ``existing`` mesh is provided a new :ref:`ArrayMesh<class_ArrayMesh>` is created, baked, and returned. Requires a skeleton with a registered skin to work. Blendshapes are ignored. Mesh surface materials are not copied.
  117. \ **Performance:** :ref:`Mesh<class_Mesh>` data needs to be retrieved from the GPU, stalling the :ref:`RenderingServer<class_RenderingServer>` in the process.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_MeshInstance3D_method_create_convex_collision:
  121. .. rst-class:: classref-method
  122. |void| **create_convex_collision**\ (\ clean\: :ref:`bool<class_bool>` = true, simplify\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_MeshInstance3D_method_create_convex_collision>`
  123. This helper creates a :ref:`StaticBody3D<class_StaticBody3D>` child node with a :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>` collision shape calculated from the mesh geometry. It's mainly used for testing.
  124. If ``clean`` is ``true`` (default), duplicate and interior vertices are removed automatically. You can set it to ``false`` to make the process faster if not needed.
  125. If ``simplify`` is ``true``, the geometry can be further simplified to reduce the number of vertices. Disabled by default.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_MeshInstance3D_method_create_debug_tangents:
  129. .. rst-class:: classref-method
  130. |void| **create_debug_tangents**\ (\ ) :ref:`🔗<class_MeshInstance3D_method_create_debug_tangents>`
  131. This helper creates a **MeshInstance3D** child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing.
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _class_MeshInstance3D_method_create_multiple_convex_collisions:
  135. .. rst-class:: classref-method
  136. |void| **create_multiple_convex_collisions**\ (\ settings\: :ref:`MeshConvexDecompositionSettings<class_MeshConvexDecompositionSettings>` = null\ ) :ref:`🔗<class_MeshInstance3D_method_create_multiple_convex_collisions>`
  137. This helper creates a :ref:`StaticBody3D<class_StaticBody3D>` child node with multiple :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>` collision shapes calculated from the mesh geometry via convex decomposition. The convex decomposition operation can be controlled with parameters from the optional ``settings``.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_MeshInstance3D_method_create_trimesh_collision:
  141. .. rst-class:: classref-method
  142. |void| **create_trimesh_collision**\ (\ ) :ref:`🔗<class_MeshInstance3D_method_create_trimesh_collision>`
  143. This helper creates a :ref:`StaticBody3D<class_StaticBody3D>` child node with a :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` collision shape calculated from the mesh geometry. It's mainly used for testing.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_MeshInstance3D_method_find_blend_shape_by_name:
  147. .. rst-class:: classref-method
  148. :ref:`int<class_int>` **find_blend_shape_by_name**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_MeshInstance3D_method_find_blend_shape_by_name>`
  149. Returns the index of the blend shape with the given ``name``. Returns ``-1`` if no blend shape with this name exists, including when :ref:`mesh<class_MeshInstance3D_property_mesh>` is ``null``.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_MeshInstance3D_method_get_active_material:
  153. .. rst-class:: classref-method
  154. :ref:`Material<class_Material>` **get_active_material**\ (\ surface\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MeshInstance3D_method_get_active_material>`
  155. Returns the :ref:`Material<class_Material>` that will be used by the :ref:`Mesh<class_Mesh>` when drawing. This can return the :ref:`GeometryInstance3D.material_override<class_GeometryInstance3D_property_material_override>`, the surface override :ref:`Material<class_Material>` defined in this **MeshInstance3D**, or the surface :ref:`Material<class_Material>` defined in the :ref:`mesh<class_MeshInstance3D_property_mesh>`. For example, if :ref:`GeometryInstance3D.material_override<class_GeometryInstance3D_property_material_override>` is used, all surfaces will return the override material.
  156. Returns ``null`` if no material is active, including when :ref:`mesh<class_MeshInstance3D_property_mesh>` is ``null``.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_MeshInstance3D_method_get_blend_shape_count:
  160. .. rst-class:: classref-method
  161. :ref:`int<class_int>` **get_blend_shape_count**\ (\ ) |const| :ref:`🔗<class_MeshInstance3D_method_get_blend_shape_count>`
  162. Returns the number of blend shapes available. Produces an error if :ref:`mesh<class_MeshInstance3D_property_mesh>` is ``null``.
  163. .. rst-class:: classref-item-separator
  164. ----
  165. .. _class_MeshInstance3D_method_get_blend_shape_value:
  166. .. rst-class:: classref-method
  167. :ref:`float<class_float>` **get_blend_shape_value**\ (\ blend_shape_idx\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MeshInstance3D_method_get_blend_shape_value>`
  168. Returns the value of the blend shape at the given ``blend_shape_idx``. Returns ``0.0`` and produces an error if :ref:`mesh<class_MeshInstance3D_property_mesh>` is ``null`` or doesn't have a blend shape at that index.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_MeshInstance3D_method_get_skin_reference:
  172. .. rst-class:: classref-method
  173. :ref:`SkinReference<class_SkinReference>` **get_skin_reference**\ (\ ) |const| :ref:`🔗<class_MeshInstance3D_method_get_skin_reference>`
  174. Returns the internal :ref:`SkinReference<class_SkinReference>` containing the skeleton's :ref:`RID<class_RID>` attached to this RID. See also :ref:`Resource.get_rid()<class_Resource_method_get_rid>`, :ref:`SkinReference.get_skeleton()<class_SkinReference_method_get_skeleton>`, and :ref:`RenderingServer.instance_attach_skeleton()<class_RenderingServer_method_instance_attach_skeleton>`.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_MeshInstance3D_method_get_surface_override_material:
  178. .. rst-class:: classref-method
  179. :ref:`Material<class_Material>` **get_surface_override_material**\ (\ surface\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MeshInstance3D_method_get_surface_override_material>`
  180. Returns the override :ref:`Material<class_Material>` for the specified ``surface`` of the :ref:`Mesh<class_Mesh>` resource. See also :ref:`get_surface_override_material_count()<class_MeshInstance3D_method_get_surface_override_material_count>`.
  181. \ **Note:** This returns the :ref:`Material<class_Material>` associated to the **MeshInstance3D**'s Surface Material Override properties, not the material within the :ref:`Mesh<class_Mesh>` resource. To get the material within the :ref:`Mesh<class_Mesh>` resource, use :ref:`Mesh.surface_get_material()<class_Mesh_method_surface_get_material>` instead.
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. _class_MeshInstance3D_method_get_surface_override_material_count:
  185. .. rst-class:: classref-method
  186. :ref:`int<class_int>` **get_surface_override_material_count**\ (\ ) |const| :ref:`🔗<class_MeshInstance3D_method_get_surface_override_material_count>`
  187. Returns the number of surface override materials. This is equivalent to :ref:`Mesh.get_surface_count()<class_Mesh_method_get_surface_count>`. See also :ref:`get_surface_override_material()<class_MeshInstance3D_method_get_surface_override_material>`.
  188. .. rst-class:: classref-item-separator
  189. ----
  190. .. _class_MeshInstance3D_method_set_blend_shape_value:
  191. .. rst-class:: classref-method
  192. |void| **set_blend_shape_value**\ (\ blend_shape_idx\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_MeshInstance3D_method_set_blend_shape_value>`
  193. Sets the value of the blend shape at ``blend_shape_idx`` to ``value``. Produces an error if :ref:`mesh<class_MeshInstance3D_property_mesh>` is ``null`` or doesn't have a blend shape at that index.
  194. .. rst-class:: classref-item-separator
  195. ----
  196. .. _class_MeshInstance3D_method_set_surface_override_material:
  197. .. rst-class:: classref-method
  198. |void| **set_surface_override_material**\ (\ surface\: :ref:`int<class_int>`, material\: :ref:`Material<class_Material>`\ ) :ref:`🔗<class_MeshInstance3D_method_set_surface_override_material>`
  199. Sets the override ``material`` for the specified ``surface`` of the :ref:`Mesh<class_Mesh>` resource. This material is associated with this **MeshInstance3D** rather than with :ref:`mesh<class_MeshInstance3D_property_mesh>`.
  200. \ **Note:** This assigns the :ref:`Material<class_Material>` associated to the **MeshInstance3D**'s Surface Material Override properties, not the material within the :ref:`Mesh<class_Mesh>` resource. To set the material within the :ref:`Mesh<class_Mesh>` resource, use :ref:`Mesh.surface_set_material()<class_Mesh_method_surface_set_material>` instead.
  201. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  202. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  203. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  204. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  205. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  206. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  207. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  208. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  209. .. |void| replace:: :abbr:`void (No return value.)`