class_mesh.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Mesh.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Mesh:
  5. Mesh
  6. ====
  7. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  8. **Inherited By:** :ref:`ArrayMesh<class_ArrayMesh>`, :ref:`PrimitiveMesh<class_PrimitiveMesh>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A :ref:`Resource<class_Resource>` that contains vertex-array based geometry.
  13. Properties
  14. ----------
  15. +-------------------------------+-------------------------------------------------------------------+
  16. | :ref:`Vector2<class_Vector2>` | :ref:`lightmap_size_hint<class_Mesh_property_lightmap_size_hint>` |
  17. +-------------------------------+-------------------------------------------------------------------+
  18. Methods
  19. -------
  20. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Shape<class_Shape>` | :ref:`create_convex_shape<class_Mesh_method_create_convex_shape>` **(** **)** const |
  22. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Mesh<class_Mesh>` | :ref:`create_outline<class_Mesh_method_create_outline>` **(** :ref:`float<class_float>` margin **)** const |
  24. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Shape<class_Shape>` | :ref:`create_trimesh_shape<class_Mesh_method_create_trimesh_shape>` **(** **)** const |
  26. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`TriangleMesh<class_TriangleMesh>` | :ref:`generate_triangle_mesh<class_Mesh_method_generate_triangle_mesh>` **(** **)** const |
  28. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`PoolVector3Array<class_PoolVector3Array>` | :ref:`get_faces<class_Mesh_method_get_faces>` **(** **)** const |
  30. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_surface_count<class_Mesh_method_get_surface_count>` **(** **)** const |
  32. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Array<class_Array>` | :ref:`surface_get_arrays<class_Mesh_method_surface_get_arrays>` **(** :ref:`int<class_int>` surf_idx **)** const |
  34. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Array<class_Array>` | :ref:`surface_get_blend_shape_arrays<class_Mesh_method_surface_get_blend_shape_arrays>` **(** :ref:`int<class_int>` surf_idx **)** const |
  36. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Material<class_Material>` | :ref:`surface_get_material<class_Mesh_method_surface_get_material>` **(** :ref:`int<class_int>` surf_idx **)** const |
  38. +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  39. Enumerations
  40. ------------
  41. .. _enum_Mesh_PrimitiveType:
  42. .. _class_Mesh_constant_PRIMITIVE_POINTS:
  43. .. _class_Mesh_constant_PRIMITIVE_LINES:
  44. .. _class_Mesh_constant_PRIMITIVE_LINE_STRIP:
  45. .. _class_Mesh_constant_PRIMITIVE_LINE_LOOP:
  46. .. _class_Mesh_constant_PRIMITIVE_TRIANGLES:
  47. .. _class_Mesh_constant_PRIMITIVE_TRIANGLE_STRIP:
  48. .. _class_Mesh_constant_PRIMITIVE_TRIANGLE_FAN:
  49. enum **PrimitiveType**:
  50. - **PRIMITIVE_POINTS** = **0** --- Render array as points (one vertex equals one point).
  51. - **PRIMITIVE_LINES** = **1** --- Render array as lines (every two vertices a line is created).
  52. - **PRIMITIVE_LINE_STRIP** = **2** --- Render array as line strip.
  53. - **PRIMITIVE_LINE_LOOP** = **3** --- Render array as line loop (like line strip, but closed).
  54. - **PRIMITIVE_TRIANGLES** = **4** --- Render array as triangles (every three vertices a triangle is created).
  55. - **PRIMITIVE_TRIANGLE_STRIP** = **5** --- Render array as triangle strips.
  56. - **PRIMITIVE_TRIANGLE_FAN** = **6** --- Render array as triangle fans.
  57. .. _enum_Mesh_BlendShapeMode:
  58. .. _class_Mesh_constant_BLEND_SHAPE_MODE_NORMALIZED:
  59. .. _class_Mesh_constant_BLEND_SHAPE_MODE_RELATIVE:
  60. enum **BlendShapeMode**:
  61. - **BLEND_SHAPE_MODE_NORMALIZED** = **0**
  62. - **BLEND_SHAPE_MODE_RELATIVE** = **1**
  63. .. _enum_Mesh_ArrayFormat:
  64. .. _class_Mesh_constant_ARRAY_FORMAT_VERTEX:
  65. .. _class_Mesh_constant_ARRAY_FORMAT_NORMAL:
  66. .. _class_Mesh_constant_ARRAY_FORMAT_TANGENT:
  67. .. _class_Mesh_constant_ARRAY_FORMAT_COLOR:
  68. .. _class_Mesh_constant_ARRAY_FORMAT_TEX_UV:
  69. .. _class_Mesh_constant_ARRAY_FORMAT_TEX_UV2:
  70. .. _class_Mesh_constant_ARRAY_FORMAT_BONES:
  71. .. _class_Mesh_constant_ARRAY_FORMAT_WEIGHTS:
  72. .. _class_Mesh_constant_ARRAY_FORMAT_INDEX:
  73. .. _class_Mesh_constant_ARRAY_COMPRESS_BASE:
  74. .. _class_Mesh_constant_ARRAY_COMPRESS_VERTEX:
  75. .. _class_Mesh_constant_ARRAY_COMPRESS_NORMAL:
  76. .. _class_Mesh_constant_ARRAY_COMPRESS_TANGENT:
  77. .. _class_Mesh_constant_ARRAY_COMPRESS_COLOR:
  78. .. _class_Mesh_constant_ARRAY_COMPRESS_TEX_UV:
  79. .. _class_Mesh_constant_ARRAY_COMPRESS_TEX_UV2:
  80. .. _class_Mesh_constant_ARRAY_COMPRESS_BONES:
  81. .. _class_Mesh_constant_ARRAY_COMPRESS_WEIGHTS:
  82. .. _class_Mesh_constant_ARRAY_COMPRESS_INDEX:
  83. .. _class_Mesh_constant_ARRAY_FLAG_USE_2D_VERTICES:
  84. .. _class_Mesh_constant_ARRAY_FLAG_USE_16_BIT_BONES:
  85. .. _class_Mesh_constant_ARRAY_COMPRESS_DEFAULT:
  86. enum **ArrayFormat**:
  87. - **ARRAY_FORMAT_VERTEX** = **1**
  88. - **ARRAY_FORMAT_NORMAL** = **2**
  89. - **ARRAY_FORMAT_TANGENT** = **4**
  90. - **ARRAY_FORMAT_COLOR** = **8**
  91. - **ARRAY_FORMAT_TEX_UV** = **16**
  92. - **ARRAY_FORMAT_TEX_UV2** = **32**
  93. - **ARRAY_FORMAT_BONES** = **64**
  94. - **ARRAY_FORMAT_WEIGHTS** = **128**
  95. - **ARRAY_FORMAT_INDEX** = **256**
  96. - **ARRAY_COMPRESS_BASE** = **9**
  97. - **ARRAY_COMPRESS_VERTEX** = **512**
  98. - **ARRAY_COMPRESS_NORMAL** = **1024**
  99. - **ARRAY_COMPRESS_TANGENT** = **2048**
  100. - **ARRAY_COMPRESS_COLOR** = **4096**
  101. - **ARRAY_COMPRESS_TEX_UV** = **8192**
  102. - **ARRAY_COMPRESS_TEX_UV2** = **16384**
  103. - **ARRAY_COMPRESS_BONES** = **32768**
  104. - **ARRAY_COMPRESS_WEIGHTS** = **65536**
  105. - **ARRAY_COMPRESS_INDEX** = **131072**
  106. - **ARRAY_FLAG_USE_2D_VERTICES** = **262144**
  107. - **ARRAY_FLAG_USE_16_BIT_BONES** = **524288**
  108. - **ARRAY_COMPRESS_DEFAULT** = **97280**
  109. .. _enum_Mesh_ArrayType:
  110. .. _class_Mesh_constant_ARRAY_VERTEX:
  111. .. _class_Mesh_constant_ARRAY_NORMAL:
  112. .. _class_Mesh_constant_ARRAY_TANGENT:
  113. .. _class_Mesh_constant_ARRAY_COLOR:
  114. .. _class_Mesh_constant_ARRAY_TEX_UV:
  115. .. _class_Mesh_constant_ARRAY_TEX_UV2:
  116. .. _class_Mesh_constant_ARRAY_BONES:
  117. .. _class_Mesh_constant_ARRAY_WEIGHTS:
  118. .. _class_Mesh_constant_ARRAY_INDEX:
  119. .. _class_Mesh_constant_ARRAY_MAX:
  120. enum **ArrayType**:
  121. - **ARRAY_VERTEX** = **0** --- Array of vertices.
  122. - **ARRAY_NORMAL** = **1** --- Array of normals.
  123. - **ARRAY_TANGENT** = **2** --- Array of tangents as an array of floats, 4 floats per tangent.
  124. - **ARRAY_COLOR** = **3** --- Array of colors.
  125. - **ARRAY_TEX_UV** = **4** --- Array of UV coordinates.
  126. - **ARRAY_TEX_UV2** = **5** --- Array of second set of UV coordinates.
  127. - **ARRAY_BONES** = **6** --- Array of bone data.
  128. - **ARRAY_WEIGHTS** = **7** --- Array of weights.
  129. - **ARRAY_INDEX** = **8** --- Array of indices.
  130. - **ARRAY_MAX** = **9**
  131. Description
  132. -----------
  133. Mesh is a type of :ref:`Resource<class_Resource>` that contains vertex-array based geometry, divided in *surfaces*. Each surface contains a completely separate array and a material used to draw it. Design wise, a mesh with multiple surfaces is preferred to a single surface, because objects created in 3D editing software commonly contain multiple materials.
  134. Property Descriptions
  135. ---------------------
  136. .. _class_Mesh_property_lightmap_size_hint:
  137. - :ref:`Vector2<class_Vector2>` **lightmap_size_hint**
  138. +----------+-------------------------------+
  139. | *Setter* | set_lightmap_size_hint(value) |
  140. +----------+-------------------------------+
  141. | *Getter* | get_lightmap_size_hint() |
  142. +----------+-------------------------------+
  143. Method Descriptions
  144. -------------------
  145. .. _class_Mesh_method_create_convex_shape:
  146. - :ref:`Shape<class_Shape>` **create_convex_shape** **(** **)** const
  147. Calculate a :ref:`ConvexPolygonShape<class_ConvexPolygonShape>` from the mesh.
  148. .. _class_Mesh_method_create_outline:
  149. - :ref:`Mesh<class_Mesh>` **create_outline** **(** :ref:`float<class_float>` margin **)** const
  150. Calculate an outline mesh at a defined offset (margin) from the original mesh. Note: Typically returns the vertices in reverse order (e.g. clockwise to anti-clockwise).
  151. .. _class_Mesh_method_create_trimesh_shape:
  152. - :ref:`Shape<class_Shape>` **create_trimesh_shape** **(** **)** const
  153. Calculate a :ref:`ConcavePolygonShape<class_ConcavePolygonShape>` from the mesh.
  154. .. _class_Mesh_method_generate_triangle_mesh:
  155. - :ref:`TriangleMesh<class_TriangleMesh>` **generate_triangle_mesh** **(** **)** const
  156. Generate a :ref:`TriangleMesh<class_TriangleMesh>` from the mesh.
  157. .. _class_Mesh_method_get_faces:
  158. - :ref:`PoolVector3Array<class_PoolVector3Array>` **get_faces** **(** **)** const
  159. Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle.
  160. .. _class_Mesh_method_get_surface_count:
  161. - :ref:`int<class_int>` **get_surface_count** **(** **)** const
  162. Returns the amount of surfaces that the ``Mesh`` holds.
  163. .. _class_Mesh_method_surface_get_arrays:
  164. - :ref:`Array<class_Array>` **surface_get_arrays** **(** :ref:`int<class_int>` surf_idx **)** const
  165. Returns the arrays for the vertices, normals, uvs, etc. that make up the requested surface (see :ref:`ArrayMesh.add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>`).
  166. .. _class_Mesh_method_surface_get_blend_shape_arrays:
  167. - :ref:`Array<class_Array>` **surface_get_blend_shape_arrays** **(** :ref:`int<class_int>` surf_idx **)** const
  168. Returns the blend shape arrays for the requested surface.
  169. .. _class_Mesh_method_surface_get_material:
  170. - :ref:`Material<class_Material>` **surface_get_material** **(** :ref:`int<class_int>` surf_idx **)** const
  171. Returns a :ref:`Material<class_Material>` in a given surface. Surface is rendered using this material.