:github_url: hide .. Generated automatically by doc/tools/make_rst.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//doc_classes. .. _class_Mesh: Mesh ==== **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` **Inherited By:** :ref:`ArrayMesh`, :ref:`PrimitiveMesh` A :ref:`Resource` that contains vertex array-based geometry. Description ----------- Mesh is a type of :ref:`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. Tutorials --------- - `3D Material Testers Demo `__ - `3D Kinematic Character Demo `__ - `3D Platformer Demo `__ - `Third Person Shooter Demo `__ Properties ---------- +-------------------------------+-------------------------------------------------------------------+---------------------+ | :ref:`Vector2` | :ref:`lightmap_size_hint` | ``Vector2( 0, 0 )`` | +-------------------------------+-------------------------------------------------------------------+---------------------+ Methods ------- +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Shape` | :ref:`create_convex_shape` **(** :ref:`bool` clean=true, :ref:`bool` simplify=false **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Mesh` | :ref:`create_outline` **(** :ref:`float` margin **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Shape` | :ref:`create_trimesh_shape` **(** **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TriangleMesh` | :ref:`generate_triangle_mesh` **(** **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`AABB` | :ref:`get_aabb` **(** **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolVector3Array` | :ref:`get_faces` **(** **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_surface_count` **(** **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`surface_get_arrays` **(** :ref:`int` surf_idx **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`surface_get_blend_shape_arrays` **(** :ref:`int` surf_idx **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Material` | :ref:`surface_get_material` **(** :ref:`int` surf_idx **)** |const| | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`surface_set_material` **(** :ref:`int` surf_idx, :ref:`Material` material **)** | +-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Enumerations ------------ .. _enum_Mesh_PrimitiveType: .. _class_Mesh_constant_PRIMITIVE_POINTS: .. _class_Mesh_constant_PRIMITIVE_LINES: .. _class_Mesh_constant_PRIMITIVE_LINE_STRIP: .. _class_Mesh_constant_PRIMITIVE_LINE_LOOP: .. _class_Mesh_constant_PRIMITIVE_TRIANGLES: .. _class_Mesh_constant_PRIMITIVE_TRIANGLE_STRIP: .. _class_Mesh_constant_PRIMITIVE_TRIANGLE_FAN: 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: .. _class_Mesh_constant_BLEND_SHAPE_MODE_NORMALIZED: .. _class_Mesh_constant_BLEND_SHAPE_MODE_RELATIVE: enum **BlendShapeMode**: - **BLEND_SHAPE_MODE_NORMALIZED** = **0** --- Blend shapes are normalized. - **BLEND_SHAPE_MODE_RELATIVE** = **1** --- Blend shapes are relative to base weight. ---- .. _enum_Mesh_ArrayFormat: .. _class_Mesh_constant_ARRAY_FORMAT_VERTEX: .. _class_Mesh_constant_ARRAY_FORMAT_NORMAL: .. _class_Mesh_constant_ARRAY_FORMAT_TANGENT: .. _class_Mesh_constant_ARRAY_FORMAT_COLOR: .. _class_Mesh_constant_ARRAY_FORMAT_TEX_UV: .. _class_Mesh_constant_ARRAY_FORMAT_TEX_UV2: .. _class_Mesh_constant_ARRAY_FORMAT_BONES: .. _class_Mesh_constant_ARRAY_FORMAT_WEIGHTS: .. _class_Mesh_constant_ARRAY_FORMAT_INDEX: .. _class_Mesh_constant_ARRAY_COMPRESS_BASE: .. _class_Mesh_constant_ARRAY_COMPRESS_VERTEX: .. _class_Mesh_constant_ARRAY_COMPRESS_NORMAL: .. _class_Mesh_constant_ARRAY_COMPRESS_TANGENT: .. _class_Mesh_constant_ARRAY_COMPRESS_COLOR: .. _class_Mesh_constant_ARRAY_COMPRESS_TEX_UV: .. _class_Mesh_constant_ARRAY_COMPRESS_TEX_UV2: .. _class_Mesh_constant_ARRAY_COMPRESS_BONES: .. _class_Mesh_constant_ARRAY_COMPRESS_WEIGHTS: .. _class_Mesh_constant_ARRAY_COMPRESS_INDEX: .. _class_Mesh_constant_ARRAY_FLAG_USE_2D_VERTICES: .. _class_Mesh_constant_ARRAY_FLAG_USE_16_BIT_BONES: .. _class_Mesh_constant_ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION: .. _class_Mesh_constant_ARRAY_COMPRESS_DEFAULT: enum **ArrayFormat**: - **ARRAY_FORMAT_VERTEX** = **1** --- Mesh array contains vertices. All meshes require a vertex array so this should always be present. - **ARRAY_FORMAT_NORMAL** = **2** --- Mesh array contains normals. - **ARRAY_FORMAT_TANGENT** = **4** --- Mesh array contains tangents. - **ARRAY_FORMAT_COLOR** = **8** --- Mesh array contains colors. - **ARRAY_FORMAT_TEX_UV** = **16** --- Mesh array contains UVs. - **ARRAY_FORMAT_TEX_UV2** = **32** --- Mesh array contains second UV. - **ARRAY_FORMAT_BONES** = **64** --- Mesh array contains bones. - **ARRAY_FORMAT_WEIGHTS** = **128** --- Mesh array contains bone weights. - **ARRAY_FORMAT_INDEX** = **256** --- Mesh array uses indices. - **ARRAY_COMPRESS_BASE** = **9** --- Used internally to calculate other ``ARRAY_COMPRESS_*`` enum values. Do not use. - **ARRAY_COMPRESS_VERTEX** = **512** --- Flag used to mark a compressed (half float) vertex array. - **ARRAY_COMPRESS_NORMAL** = **1024** --- Flag used to mark a compressed (half float) normal array. - **ARRAY_COMPRESS_TANGENT** = **2048** --- Flag used to mark a compressed (half float) tangent array. - **ARRAY_COMPRESS_COLOR** = **4096** --- Flag used to mark a compressed (half float) color array. - **ARRAY_COMPRESS_TEX_UV** = **8192** --- Flag used to mark a compressed (half float) UV coordinates array. - **ARRAY_COMPRESS_TEX_UV2** = **16384** --- Flag used to mark a compressed (half float) UV coordinates array for the second UV coordinates. - **ARRAY_COMPRESS_BONES** = **32768** --- Flag used to mark a compressed bone array. - **ARRAY_COMPRESS_WEIGHTS** = **65536** --- Flag used to mark a compressed (half float) weight array. - **ARRAY_COMPRESS_INDEX** = **131072** --- Flag used to mark a compressed index array. - **ARRAY_FLAG_USE_2D_VERTICES** = **262144** --- Flag used to mark that the array contains 2D vertices. - **ARRAY_FLAG_USE_16_BIT_BONES** = **524288** --- Flag used to mark that the array uses 16-bit bones instead of 8-bit. - **ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION** = **2097152** --- Flag used to mark that the array uses an octahedral representation of normal and tangent vectors rather than cartesian. - **ARRAY_COMPRESS_DEFAULT** = **2194432** --- Used to set flags :ref:`ARRAY_COMPRESS_VERTEX`, :ref:`ARRAY_COMPRESS_NORMAL`, :ref:`ARRAY_COMPRESS_TANGENT`, :ref:`ARRAY_COMPRESS_COLOR`, :ref:`ARRAY_COMPRESS_TEX_UV`, :ref:`ARRAY_COMPRESS_TEX_UV2`, :ref:`ARRAY_COMPRESS_WEIGHTS`, and :ref:`ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION` quickly. ---- .. _enum_Mesh_ArrayType: .. _class_Mesh_constant_ARRAY_VERTEX: .. _class_Mesh_constant_ARRAY_NORMAL: .. _class_Mesh_constant_ARRAY_TANGENT: .. _class_Mesh_constant_ARRAY_COLOR: .. _class_Mesh_constant_ARRAY_TEX_UV: .. _class_Mesh_constant_ARRAY_TEX_UV2: .. _class_Mesh_constant_ARRAY_BONES: .. _class_Mesh_constant_ARRAY_WEIGHTS: .. _class_Mesh_constant_ARRAY_INDEX: .. _class_Mesh_constant_ARRAY_MAX: 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** --- Represents the size of the :ref:`ArrayType` enum. Property Descriptions --------------------- .. _class_Mesh_property_lightmap_size_hint: - :ref:`Vector2` **lightmap_size_hint** +-----------+-------------------------------+ | *Default* | ``Vector2( 0, 0 )`` | +-----------+-------------------------------+ | *Setter* | set_lightmap_size_hint(value) | +-----------+-------------------------------+ | *Getter* | get_lightmap_size_hint() | +-----------+-------------------------------+ Sets a hint to be used for lightmap resolution in :ref:`BakedLightmap`. Overrides :ref:`BakedLightmap.default_texels_per_unit`. Method Descriptions ------------------- .. _class_Mesh_method_create_convex_shape: - :ref:`Shape` **create_convex_shape** **(** :ref:`bool` clean=true, :ref:`bool` simplify=false **)** |const| Calculate a :ref:`ConvexPolygonShape` from the mesh. 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_Mesh_method_create_outline: - :ref:`Mesh` **create_outline** **(** :ref:`float` margin **)** |const| Calculate an outline mesh at a defined offset (margin) from the original mesh. **Note:** This method typically returns the vertices in reverse order (e.g. clockwise to counterclockwise). ---- .. _class_Mesh_method_create_trimesh_shape: - :ref:`Shape` **create_trimesh_shape** **(** **)** |const| Calculate a :ref:`ConcavePolygonShape` from the mesh. ---- .. _class_Mesh_method_generate_triangle_mesh: - :ref:`TriangleMesh` **generate_triangle_mesh** **(** **)** |const| Generate a :ref:`TriangleMesh` from the mesh. ---- .. _class_Mesh_method_get_aabb: - :ref:`AABB` **get_aabb** **(** **)** |const| Returns the smallest :ref:`AABB` enclosing this mesh in local space. Not affected by ``custom_aabb``. See also :ref:`VisualInstance.get_transformed_aabb`. **Note:** This is only implemented for :ref:`ArrayMesh` and :ref:`PrimitiveMesh`. ---- .. _class_Mesh_method_get_faces: - :ref:`PoolVector3Array` **get_faces** **(** **)** |const| Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle. ---- .. _class_Mesh_method_get_surface_count: - :ref:`int` **get_surface_count** **(** **)** |const| Returns the amount of surfaces that the ``Mesh`` holds. ---- .. _class_Mesh_method_surface_get_arrays: - :ref:`Array` **surface_get_arrays** **(** :ref:`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_Mesh_method_surface_get_blend_shape_arrays: - :ref:`Array` **surface_get_blend_shape_arrays** **(** :ref:`int` surf_idx **)** |const| Returns the blend shape arrays for the requested surface. ---- .. _class_Mesh_method_surface_get_material: - :ref:`Material` **surface_get_material** **(** :ref:`int` surf_idx **)** |const| Returns a :ref:`Material` in a given surface. Surface is rendered using this material. ---- .. _class_Mesh_method_surface_set_material: - void **surface_set_material** **(** :ref:`int` surf_idx, :ref:`Material` material **)** Sets a :ref:`Material` for a given surface. Surface will be rendered using this material. .. |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.)`