class_meshinstance.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the MeshInstance.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_MeshInstance:
  6. MeshInstance
  7. ============
  8. **Inherits:** :ref:`GeometryInstance<class_GeometryInstance>` **<** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`SoftBody<class_SoftBody>`
  10. Node that instances meshes into a scenario.
  11. Description
  12. -----------
  13. MeshInstance 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 get 3D geometry rendered and can be used to instance a single :ref:`Mesh<class_Mesh>` in many places. This allows to reuse geometry and save on resources. When a :ref:`Mesh<class_Mesh>` has to be instanced more than thousands of times at close proximity, consider using a :ref:`MultiMesh<class_MultiMesh>` in a :ref:`MultiMeshInstance<class_MultiMeshInstance>` instead.
  14. Properties
  15. ----------
  16. +---------------------------------+-------------------------------------------------------+--------------------+
  17. | :ref:`Mesh<class_Mesh>` | :ref:`mesh<class_MeshInstance_property_mesh>` | |
  18. +---------------------------------+-------------------------------------------------------+--------------------+
  19. | :ref:`NodePath<class_NodePath>` | :ref:`skeleton<class_MeshInstance_property_skeleton>` | ``NodePath("..")`` |
  20. +---------------------------------+-------------------------------------------------------+--------------------+
  21. | :ref:`Skin<class_Skin>` | :ref:`skin<class_MeshInstance_property_skin>` | |
  22. +---------------------------------+-------------------------------------------------------+--------------------+
  23. Methods
  24. -------
  25. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`create_convex_collision<class_MeshInstance_method_create_convex_collision>` **(** **)** |
  27. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`create_debug_tangents<class_MeshInstance_method_create_debug_tangents>` **(** **)** |
  29. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`create_trimesh_collision<class_MeshInstance_method_create_trimesh_collision>` **(** **)** |
  31. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Material<class_Material>` | :ref:`get_surface_material<class_MeshInstance_method_get_surface_material>` **(** :ref:`int<class_int>` surface **)** |const| |
  33. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_surface_material_count<class_MeshInstance_method_get_surface_material_count>` **(** **)** |const| |
  35. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_surface_material<class_MeshInstance_method_set_surface_material>` **(** :ref:`int<class_int>` surface, :ref:`Material<class_Material>` material **)** |
  37. +---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. Property Descriptions
  39. ---------------------
  40. .. _class_MeshInstance_property_mesh:
  41. - :ref:`Mesh<class_Mesh>` **mesh**
  42. +----------+-----------------+
  43. | *Setter* | set_mesh(value) |
  44. +----------+-----------------+
  45. | *Getter* | get_mesh() |
  46. +----------+-----------------+
  47. The :ref:`Mesh<class_Mesh>` resource for the instance.
  48. ----
  49. .. _class_MeshInstance_property_skeleton:
  50. - :ref:`NodePath<class_NodePath>` **skeleton**
  51. +-----------+--------------------------+
  52. | *Default* | ``NodePath("..")`` |
  53. +-----------+--------------------------+
  54. | *Setter* | set_skeleton_path(value) |
  55. +-----------+--------------------------+
  56. | *Getter* | get_skeleton_path() |
  57. +-----------+--------------------------+
  58. :ref:`NodePath<class_NodePath>` to the :ref:`Skeleton<class_Skeleton>` associated with the instance.
  59. ----
  60. .. _class_MeshInstance_property_skin:
  61. - :ref:`Skin<class_Skin>` **skin**
  62. +----------+-----------------+
  63. | *Setter* | set_skin(value) |
  64. +----------+-----------------+
  65. | *Getter* | get_skin() |
  66. +----------+-----------------+
  67. Sets the skin to be used by this instance.
  68. Method Descriptions
  69. -------------------
  70. .. _class_MeshInstance_method_create_convex_collision:
  71. - void **create_convex_collision** **(** **)**
  72. This helper creates a :ref:`StaticBody<class_StaticBody>` child node with a :ref:`ConvexPolygonShape<class_ConvexPolygonShape>` collision shape calculated from the mesh geometry. It's mainly used for testing.
  73. ----
  74. .. _class_MeshInstance_method_create_debug_tangents:
  75. - void **create_debug_tangents** **(** **)**
  76. This helper creates a ``MeshInstance`` child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing.
  77. ----
  78. .. _class_MeshInstance_method_create_trimesh_collision:
  79. - void **create_trimesh_collision** **(** **)**
  80. This helper creates a :ref:`StaticBody<class_StaticBody>` child node with a :ref:`ConcavePolygonShape<class_ConcavePolygonShape>` collision shape calculated from the mesh geometry. It's mainly used for testing.
  81. ----
  82. .. _class_MeshInstance_method_get_surface_material:
  83. - :ref:`Material<class_Material>` **get_surface_material** **(** :ref:`int<class_int>` surface **)** |const|
  84. Returns the :ref:`Material<class_Material>` for a surface of the :ref:`Mesh<class_Mesh>` resource.
  85. ----
  86. .. _class_MeshInstance_method_get_surface_material_count:
  87. - :ref:`int<class_int>` **get_surface_material_count** **(** **)** |const|
  88. Returns the number of surface materials.
  89. ----
  90. .. _class_MeshInstance_method_set_surface_material:
  91. - void **set_surface_material** **(** :ref:`int<class_int>` surface, :ref:`Material<class_Material>` material **)**
  92. Sets the :ref:`Material<class_Material>` for a surface of the :ref:`Mesh<class_Mesh>` resource.
  93. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  94. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  95. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`