Files
godot-docs/classes/class_mesh.rst

227 lines
9.4 KiB
ReStructuredText

.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the Mesh.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_Mesh:
Mesh
====
**Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
**Inherited By:** :ref:`ArrayMesh<class_ArrayMesh>`, :ref:`PrimitiveMesh<class_PrimitiveMesh>`
**Category:** Core
Brief Description
-----------------
A :ref:`Resource<class_Resource>` that contains vertex-array based geometry.
Properties
----------
+-------------------------------+----------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`lightmap_size_hint<class_Mesh_lightmap_size_hint>` |
+-------------------------------+----------------------------------------------------------+
Methods
-------
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Shape<class_Shape>` | :ref:`create_convex_shape<class_Mesh_create_convex_shape>` **(** **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Mesh<class_Mesh>` | :ref:`create_outline<class_Mesh_create_outline>` **(** :ref:`float<class_float>` margin **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Shape<class_Shape>` | :ref:`create_trimesh_shape<class_Mesh_create_trimesh_shape>` **(** **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`TriangleMesh<class_TriangleMesh>` | :ref:`generate_triangle_mesh<class_Mesh_generate_triangle_mesh>` **(** **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PoolVector3Array<class_PoolVector3Array>` | :ref:`get_faces<class_Mesh_get_faces>` **(** **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_surface_count<class_Mesh_get_surface_count>` **(** **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`surface_get_arrays<class_Mesh_surface_get_arrays>` **(** :ref:`int<class_int>` surf_idx **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`surface_get_blend_shape_arrays<class_Mesh_surface_get_blend_shape_arrays>` **(** :ref:`int<class_int>` surf_idx **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Material<class_Material>` | :ref:`surface_get_material<class_Mesh_surface_get_material>` **(** :ref:`int<class_int>` surf_idx **)** const |
+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
Enumerations
------------
.. _enum_Mesh_PrimitiveType:
enum **PrimitiveType**:
- **PRIMITIVE_POINTS** = **0** --- Render array as points (one vertex equals one point).
- **PRIMITIVE_LINES** = **1** --- Render array as lines (every two vertices a line is created).
- **PRIMITIVE_LINE_STRIP** = **2** --- Render array as line strip.
- **PRIMITIVE_LINE_LOOP** = **3** --- Render array as line loop (like line strip, but closed).
- **PRIMITIVE_TRIANGLES** = **4** --- Render array as triangles (every three vertices a triangle is created).
- **PRIMITIVE_TRIANGLE_STRIP** = **5** --- Render array as triangle strips.
- **PRIMITIVE_TRIANGLE_FAN** = **6** --- Render array as triangle fans.
.. _enum_Mesh_BlendShapeMode:
enum **BlendShapeMode**:
- **BLEND_SHAPE_MODE_NORMALIZED** = **0**
- **BLEND_SHAPE_MODE_RELATIVE** = **1**
.. _enum_Mesh_ArrayFormat:
enum **ArrayFormat**:
- **ARRAY_FORMAT_VERTEX** = **1**
- **ARRAY_FORMAT_NORMAL** = **2**
- **ARRAY_FORMAT_TANGENT** = **4**
- **ARRAY_FORMAT_COLOR** = **8**
- **ARRAY_FORMAT_TEX_UV** = **16**
- **ARRAY_FORMAT_TEX_UV2** = **32**
- **ARRAY_FORMAT_BONES** = **64**
- **ARRAY_FORMAT_WEIGHTS** = **128**
- **ARRAY_FORMAT_INDEX** = **256**
- **ARRAY_COMPRESS_BASE** = **9**
- **ARRAY_COMPRESS_VERTEX** = **512**
- **ARRAY_COMPRESS_NORMAL** = **1024**
- **ARRAY_COMPRESS_TANGENT** = **2048**
- **ARRAY_COMPRESS_COLOR** = **4096**
- **ARRAY_COMPRESS_TEX_UV** = **8192**
- **ARRAY_COMPRESS_TEX_UV2** = **16384**
- **ARRAY_COMPRESS_BONES** = **32768**
- **ARRAY_COMPRESS_WEIGHTS** = **65536**
- **ARRAY_COMPRESS_INDEX** = **131072**
- **ARRAY_FLAG_USE_2D_VERTICES** = **262144**
- **ARRAY_FLAG_USE_16_BIT_BONES** = **524288**
- **ARRAY_COMPRESS_DEFAULT** = **97280**
.. _enum_Mesh_ArrayType:
enum **ArrayType**:
- **ARRAY_VERTEX** = **0** --- Array of vertices.
- **ARRAY_NORMAL** = **1** --- Array of normals.
- **ARRAY_TANGENT** = **2** --- Array of tangents as an array of floats, 4 floats per tangent.
- **ARRAY_COLOR** = **3** --- Array of colors.
- **ARRAY_TEX_UV** = **4** --- Array of UV coordinates.
- **ARRAY_TEX_UV2** = **5** --- Array of second set of UV coordinates.
- **ARRAY_BONES** = **6** --- Array of bone data.
- **ARRAY_WEIGHTS** = **7** --- Array of weights.
- **ARRAY_INDEX** = **8** --- Array of indices.
- **ARRAY_MAX** = **9**
Description
-----------
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.
Property Descriptions
---------------------
.. _class_Mesh_lightmap_size_hint:
- :ref:`Vector2<class_Vector2>` **lightmap_size_hint**
+----------+-------------------------------+
| *Setter* | set_lightmap_size_hint(value) |
+----------+-------------------------------+
| *Getter* | get_lightmap_size_hint() |
+----------+-------------------------------+
Method Descriptions
-------------------
.. _class_Mesh_create_convex_shape:
- :ref:`Shape<class_Shape>` **create_convex_shape** **(** **)** const
Calculate a :ref:`ConvexPolygonShape<class_ConvexPolygonShape>` from the mesh.
.. _class_Mesh_create_outline:
- :ref:`Mesh<class_Mesh>` **create_outline** **(** :ref:`float<class_float>` margin **)** const
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).
.. _class_Mesh_create_trimesh_shape:
- :ref:`Shape<class_Shape>` **create_trimesh_shape** **(** **)** const
Calculate a :ref:`ConcavePolygonShape<class_ConcavePolygonShape>` from the mesh.
.. _class_Mesh_generate_triangle_mesh:
- :ref:`TriangleMesh<class_TriangleMesh>` **generate_triangle_mesh** **(** **)** const
Generate a :ref:`TriangleMesh<class_TriangleMesh>` from the mesh.
.. _class_Mesh_get_faces:
- :ref:`PoolVector3Array<class_PoolVector3Array>` **get_faces** **(** **)** const
Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle.
.. _class_Mesh_get_surface_count:
- :ref:`int<class_int>` **get_surface_count** **(** **)** const
Return the amount of surfaces that the ``Mesh`` holds.
.. _class_Mesh_surface_get_arrays:
- :ref:`Array<class_Array>` **surface_get_arrays** **(** :ref:`int<class_int>` surf_idx **)** const
Returns the arrays for the vertices, normals, uvs, etc. that make up the requested surface (see :ref:`ArrayMesh.add_surface_from_arrays<class_ArrayMesh_add_surface_from_arrays>`).
.. _class_Mesh_surface_get_blend_shape_arrays:
- :ref:`Array<class_Array>` **surface_get_blend_shape_arrays** **(** :ref:`int<class_int>` surf_idx **)** const
Returns the blend shape arrays for the requested surface.
.. _class_Mesh_surface_get_material:
- :ref:`Material<class_Material>` **surface_get_material** **(** :ref:`int<class_int>` surf_idx **)** const
Return a :ref:`Material<class_Material>` in a given surface. Surface is rendered using this material.