Files
godot-docs/classes/class_meshinstance3d.rst
2021-11-15 12:28:38 +01:00

218 lines
14 KiB
ReStructuredText

:github_url: hide
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the MeshInstance3D.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_MeshInstance3D:
MeshInstance3D
==============
**Inherits:** :ref:`GeometryInstance3D<class_GeometryInstance3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
**Inherited By:** :ref:`SoftDynamicBody3D<class_SoftDynamicBody3D>`
Node that instances meshes into a scenario.
Description
-----------
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 render 3D geometry and can be used to instance a single :ref:`Mesh<class_Mesh>` in many places. This allows reuse of 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.
Tutorials
---------
- `3D Material Testers Demo <https://godotengine.org/asset-library/asset/123>`__
- `3D Kinematic Character Demo <https://godotengine.org/asset-library/asset/126>`__
- `3D Platformer Demo <https://godotengine.org/asset-library/asset/125>`__
- `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
Properties
----------
+---------------------------------+---------------------------------------------------------+--------------------+
| :ref:`Mesh<class_Mesh>` | :ref:`mesh<class_MeshInstance3D_property_mesh>` | |
+---------------------------------+---------------------------------------------------------+--------------------+
| :ref:`NodePath<class_NodePath>` | :ref:`skeleton<class_MeshInstance3D_property_skeleton>` | ``NodePath("..")`` |
+---------------------------------+---------------------------------------------------------+--------------------+
| :ref:`Skin<class_Skin>` | :ref:`skin<class_MeshInstance3D_property_skin>` | |
+---------------------------------+---------------------------------------------------------+--------------------+
Methods
-------
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_convex_collision<class_MeshInstance3D_method_create_convex_collision>` **(** :ref:`bool<class_bool>` clean=true, :ref:`bool<class_bool>` simplify=false **)** |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_debug_tangents<class_MeshInstance3D_method_create_debug_tangents>` **(** **)** |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_multiple_convex_collisions<class_MeshInstance3D_method_create_multiple_convex_collisions>` **(** **)** |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_trimesh_collision<class_MeshInstance3D_method_create_trimesh_collision>` **(** **)** |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`find_blend_shape_by_name<class_MeshInstance3D_method_find_blend_shape_by_name>` **(** :ref:`StringName<class_StringName>` name **)** |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Material<class_Material>` | :ref:`get_active_material<class_MeshInstance3D_method_get_active_material>` **(** :ref:`int<class_int>` surface **)** |const| |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_blend_shape_count<class_MeshInstance3D_method_get_blend_shape_count>` **(** **)** |const| |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_blend_shape_value<class_MeshInstance3D_method_get_blend_shape_value>` **(** :ref:`int<class_int>` blend_shape_idx **)** |const| |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Material<class_Material>` | :ref:`get_surface_override_material<class_MeshInstance3D_method_get_surface_override_material>` **(** :ref:`int<class_int>` surface **)** |const| |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_surface_override_material_count<class_MeshInstance3D_method_get_surface_override_material_count>` **(** **)** |const| |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_blend_shape_value<class_MeshInstance3D_method_set_blend_shape_value>` **(** :ref:`int<class_int>` blend_shape_idx, :ref:`float<class_float>` value **)** |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_surface_override_material<class_MeshInstance3D_method_set_surface_override_material>` **(** :ref:`int<class_int>` surface, :ref:`Material<class_Material>` material **)** |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Property Descriptions
---------------------
.. _class_MeshInstance3D_property_mesh:
- :ref:`Mesh<class_Mesh>` **mesh**
+----------+-----------------+
| *Setter* | set_mesh(value) |
+----------+-----------------+
| *Getter* | get_mesh() |
+----------+-----------------+
The :ref:`Mesh<class_Mesh>` resource for the instance.
----
.. _class_MeshInstance3D_property_skeleton:
- :ref:`NodePath<class_NodePath>` **skeleton**
+-----------+--------------------------+
| *Default* | ``NodePath("..")`` |
+-----------+--------------------------+
| *Setter* | set_skeleton_path(value) |
+-----------+--------------------------+
| *Getter* | get_skeleton_path() |
+-----------+--------------------------+
:ref:`NodePath<class_NodePath>` to the :ref:`Skeleton3D<class_Skeleton3D>` associated with the instance.
----
.. _class_MeshInstance3D_property_skin:
- :ref:`Skin<class_Skin>` **skin**
+----------+-----------------+
| *Setter* | set_skin(value) |
+----------+-----------------+
| *Getter* | get_skin() |
+----------+-----------------+
Sets the skin to be used by this instance.
Method Descriptions
-------------------
.. _class_MeshInstance3D_method_create_convex_collision:
- void **create_convex_collision** **(** :ref:`bool<class_bool>` clean=true, :ref:`bool<class_bool>` simplify=false **)**
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.
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.
If ``simplify`` is ``true``, the geometry can be further simplified to reduce the amount of vertices. Disabled by default.
----
.. _class_MeshInstance3D_method_create_debug_tangents:
- void **create_debug_tangents** **(** **)**
This helper creates a ``MeshInstance3D`` child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing.
----
.. _class_MeshInstance3D_method_create_multiple_convex_collisions:
- void **create_multiple_convex_collisions** **(** **)**
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. It's mainly used for testing.
----
.. _class_MeshInstance3D_method_create_trimesh_collision:
- void **create_trimesh_collision** **(** **)**
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.
----
.. _class_MeshInstance3D_method_find_blend_shape_by_name:
- :ref:`int<class_int>` **find_blend_shape_by_name** **(** :ref:`StringName<class_StringName>` name **)**
----
.. _class_MeshInstance3D_method_get_active_material:
- :ref:`Material<class_Material>` **get_active_material** **(** :ref:`int<class_int>` surface **)** |const|
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_Mesh>`. For example, if :ref:`GeometryInstance3D.material_override<class_GeometryInstance3D_property_material_override>` is used, all surfaces will return the override material.
----
.. _class_MeshInstance3D_method_get_blend_shape_count:
- :ref:`int<class_int>` **get_blend_shape_count** **(** **)** |const|
----
.. _class_MeshInstance3D_method_get_blend_shape_value:
- :ref:`float<class_float>` **get_blend_shape_value** **(** :ref:`int<class_int>` blend_shape_idx **)** |const|
----
.. _class_MeshInstance3D_method_get_surface_override_material:
- :ref:`Material<class_Material>` **get_surface_override_material** **(** :ref:`int<class_int>` surface **)** |const|
Returns the override :ref:`Material<class_Material>` for the specified surface of the :ref:`Mesh<class_Mesh>` resource.
----
.. _class_MeshInstance3D_method_get_surface_override_material_count:
- :ref:`int<class_int>` **get_surface_override_material_count** **(** **)** |const|
Returns the number of surface override materials. This is equivalent to :ref:`Mesh.get_surface_count<class_Mesh_method_get_surface_count>`.
----
.. _class_MeshInstance3D_method_set_blend_shape_value:
- void **set_blend_shape_value** **(** :ref:`int<class_int>` blend_shape_idx, :ref:`float<class_float>` value **)**
----
.. _class_MeshInstance3D_method_set_surface_override_material:
- void **set_surface_override_material** **(** :ref:`int<class_int>` surface, :ref:`Material<class_Material>` material **)**
Sets the override :ref:`Material<class_Material>` for the specified surface of the :ref:`Mesh<class_Mesh>` resource. This material is associated with this ``MeshInstance3D`` rather than with the :ref:`Mesh<class_Mesh>` resource.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`