Class Mesh
A Resource that contains vertex array-based geometry.
- Inheritance
-
Mesh
- Derived
Remarks
Mesh is a type of 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. The maximum number of surfaces per mesh is MAX_MESH_SURFACES.
See Also
Properties
lightmap_size_hint
Sets a hint to be used for lightmap resolution.
var lightmap_size_hint : Vector2i = Vector2i(0, 0)
Property Value
Remarks
Methods
_get_aabb
Qualifiers: virtualconst
Virtual method to override the AABB for a custom class extending Mesh.
AABB _get_aabb
_get_blend_shape_count
Qualifiers: virtualconst
Virtual method to override the number of blend shapes for a custom class extending Mesh.
int _get_blend_shape_count
_get_blend_shape_name(int)
Qualifiers: virtualconst
Virtual method to override the retrieval of blend shape names for a custom class extending Mesh.
StringName _get_blend_shape_name(int index)
Parameters
index
int
_get_surface_count
Qualifiers: virtualconst
Virtual method to override the surface count for a custom class extending Mesh.
int _get_surface_count
_set_blend_shape_name(int, StringName)
Qualifiers: virtual
Virtual method to override the names of blend shapes for a custom class extending Mesh.
void _set_blend_shape_name(int index, StringName name)
Parameters
index
intname
StringName
_surface_get_array_index_len(int)
Qualifiers: virtualconst
Virtual method to override the surface array index length for a custom class extending Mesh.
int _surface_get_array_index_len(int index)
Parameters
index
int
_surface_get_array_len(int)
Qualifiers: virtualconst
Virtual method to override the surface array length for a custom class extending Mesh.
int _surface_get_array_len(int index)
Parameters
index
int
_surface_get_arrays(int)
Qualifiers: virtualconst
Virtual method to override the surface arrays for a custom class extending Mesh.
Array _surface_get_arrays(int index)
Parameters
index
int
_surface_get_blend_shape_arrays(int)
Qualifiers: virtualconst
Virtual method to override the blend shape arrays for a custom class extending Mesh.
Array[] _surface_get_blend_shape_arrays(int index)
Parameters
index
int
_surface_get_format(int)
Qualifiers: virtualconst
Virtual method to override the surface format for a custom class extending Mesh.
int _surface_get_format(int index)
Parameters
index
int
_surface_get_lods(int)
Qualifiers: virtualconst
Virtual method to override the surface LODs for a custom class extending Mesh.
Dictionary _surface_get_lods(int index)
Parameters
index
int
_surface_get_material(int)
Qualifiers: virtualconst
Virtual method to override the surface material for a custom class extending Mesh.
Material _surface_get_material(int index)
Parameters
index
int
_surface_get_primitive_type(int)
Qualifiers: virtualconst
Virtual method to override the surface primitive type for a custom class extending Mesh.
int _surface_get_primitive_type(int index)
Parameters
index
int
_surface_set_material(int, Material)
Qualifiers: virtual
Virtual method to override the setting of a material
at the given index
for a custom class extending Mesh.
void _surface_set_material(int index, Material material)
Parameters
create_convex_shape(bool, bool)
Qualifiers: const
Calculate a ConvexPolygonShape3D 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 number of vertices. Disabled by default.
ConvexPolygonShape3D create_convex_shape(bool clean, bool simplify)
Parameters
create_outline(float)
Qualifiers: 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).
Mesh create_outline(float margin)
Parameters
margin
float
create_placeholder
Qualifiers: const
Creates a placeholder version of this resource (PlaceholderMesh).
Resource create_placeholder
create_trimesh_shape
Qualifiers: const
Calculate a ConcavePolygonShape3D from the mesh.
ConcavePolygonShape3D create_trimesh_shape
generate_triangle_mesh
Qualifiers: const
Generate a TriangleMesh from the mesh. Considers only surfaces using one of these primitive types: Mesh.PRIMITIVE_TRIANGLES, Mesh.PRIMITIVE_TRIANGLE_STRIP.
TriangleMesh generate_triangle_mesh
get_aabb
Qualifiers: const
Returns the smallest AABB enclosing this mesh in local space. Not affected by custom_aabb
.
Note: This is only implemented for ArrayMesh and PrimitiveMesh.
AABB get_aabb
get_faces
Qualifiers: const
Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle.
PackedVector3Array get_faces
get_surface_count
Qualifiers: const
Returns the number of surfaces that the Mesh holds. This is equivalent to get_surface_override_material_count.
int get_surface_count
surface_get_arrays(int)
Qualifiers: const
Returns the arrays for the vertices, normals, UVs, etc. that make up the requested surface (see ArrayMesh.add_surface_from_arrays).
Array surface_get_arrays(int surf_idx)
Parameters
surf_idx
int
surface_get_blend_shape_arrays(int)
Qualifiers: const
Returns the blend shape arrays for the requested surface.
Array[] surface_get_blend_shape_arrays(int surf_idx)
Parameters
surf_idx
int
surface_get_material(int)
Qualifiers: const
Returns a Material in a given surface. Surface is rendered using this material.
Note: This returns the material within the Mesh resource, not the Material associated to the MeshInstance3D's Surface Material Override properties. To get the Material associated to the MeshInstance3D's Surface Material Override properties, use MeshInstance3D.get_surface_override_material instead.
Material surface_get_material(int surf_idx)
Parameters
surf_idx
int
surface_set_material(int, Material)
Sets a Material for a given surface. Surface will be rendered using this material.
Note: This assigns the material within the Mesh resource, not the Material associated to the MeshInstance3D's Surface Material Override properties. To set the Material associated to the MeshInstance3D's Surface Material Override properties, use MeshInstance3D.set_surface_override_material instead.
void surface_set_material(int surf_idx, Material material)