Table of Contents

Class Mesh

Namespace
Godot
Assembly
GodotSharp.dll

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.

public class Mesh : Resource, IDisposable
Inheritance
Mesh
Implements
Derived
Inherited Members

Constructors

Mesh()

public Mesh()

Properties

LightmapSizeHint

Sets a hint to be used for lightmap resolution.

public Vector2I LightmapSizeHint { get; set; }

Property Value

Vector2I

Methods

CreateConvexShape(bool, bool)

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.

public ConvexPolygonShape3D CreateConvexShape(bool clean = true, bool simplify = false)

Parameters

clean bool
simplify bool

Returns

ConvexPolygonShape3D

CreateOutline(float)

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).

public Mesh CreateOutline(float margin)

Parameters

margin float

Returns

Mesh

CreatePlaceholder()

Creates a placeholder version of this resource (PlaceholderMesh).

public Resource CreatePlaceholder()

Returns

Resource

CreateTrimeshShape()

Calculate a ConcavePolygonShape3D from the mesh.

public ConcavePolygonShape3D CreateTrimeshShape()

Returns

ConcavePolygonShape3D

GenerateTriangleMesh()

Generate a TriangleMesh from the mesh. Considers only surfaces using one of these primitive types: Triangles, TriangleStrip.

public TriangleMesh GenerateTriangleMesh()

Returns

TriangleMesh

GetAabb()

Returns the smallest Aabb enclosing this mesh in local space. Not affected by custom_aabb.

Note: This is only implemented for ArrayMesh and PrimitiveMesh.

public Aabb GetAabb()

Returns

Aabb

GetFaces()

Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle.

public Vector3[] GetFaces()

Returns

Vector3[]

GetSurfaceCount()

Returns the number of surfaces that the Mesh holds. This is equivalent to GetSurfaceOverrideMaterialCount().

public int GetSurfaceCount()

Returns

int

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SurfaceGetArrays(int)

Returns the arrays for the vertices, normals, UVs, etc. that make up the requested surface (see AddSurfaceFromArrays(PrimitiveType, Array, Array<Array>, Dictionary, ArrayFormat)).

public Array SurfaceGetArrays(int surfIdx)

Parameters

surfIdx int

Returns

Array

SurfaceGetBlendShapeArrays(int)

Returns the blend shape arrays for the requested surface.

public Array<Array> SurfaceGetBlendShapeArrays(int surfIdx)

Parameters

surfIdx int

Returns

Array<Array>

SurfaceGetMaterial(int)

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 GetSurfaceOverrideMaterial(int) instead.

public Material SurfaceGetMaterial(int surfIdx)

Parameters

surfIdx int

Returns

Material

SurfaceSetMaterial(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 SetSurfaceOverrideMaterial(int, Material) instead.

public void SurfaceSetMaterial(int surfIdx, Material material)

Parameters

surfIdx int
material Material

_GetAabb()

Virtual method to override the Aabb for a custom class extending Mesh.

public virtual Aabb _GetAabb()

Returns

Aabb

_GetBlendShapeCount()

Virtual method to override the number of blend shapes for a custom class extending Mesh.

public virtual int _GetBlendShapeCount()

Returns

int

_GetBlendShapeName(int)

Virtual method to override the retrieval of blend shape names for a custom class extending Mesh.

public virtual StringName _GetBlendShapeName(int index)

Parameters

index int

Returns

StringName

_GetSurfaceCount()

Virtual method to override the surface count for a custom class extending Mesh.

public virtual int _GetSurfaceCount()

Returns

int

_SetBlendShapeName(int, StringName)

Virtual method to override the names of blend shapes for a custom class extending Mesh.

public virtual void _SetBlendShapeName(int index, StringName name)

Parameters

index int
name StringName

_SurfaceGetArrayIndexLen(int)

Virtual method to override the surface array index length for a custom class extending Mesh.

public virtual int _SurfaceGetArrayIndexLen(int index)

Parameters

index int

Returns

int

_SurfaceGetArrayLen(int)

Virtual method to override the surface array length for a custom class extending Mesh.

public virtual int _SurfaceGetArrayLen(int index)

Parameters

index int

Returns

int

_SurfaceGetArrays(int)

Virtual method to override the surface arrays for a custom class extending Mesh.

public virtual Array _SurfaceGetArrays(int index)

Parameters

index int

Returns

Array

_SurfaceGetBlendShapeArrays(int)

Virtual method to override the blend shape arrays for a custom class extending Mesh.

public virtual Array<Array> _SurfaceGetBlendShapeArrays(int index)

Parameters

index int

Returns

Array<Array>

_SurfaceGetFormat(int)

Virtual method to override the surface format for a custom class extending Mesh.

public virtual uint _SurfaceGetFormat(int index)

Parameters

index int

Returns

uint

_SurfaceGetLods(int)

Virtual method to override the surface LODs for a custom class extending Mesh.

public virtual Dictionary _SurfaceGetLods(int index)

Parameters

index int

Returns

Dictionary

_SurfaceGetMaterial(int)

Virtual method to override the surface material for a custom class extending Mesh.

public virtual Material _SurfaceGetMaterial(int index)

Parameters

index int

Returns

Material

_SurfaceGetPrimitiveType(int)

Virtual method to override the surface primitive type for a custom class extending Mesh.

public virtual uint _SurfaceGetPrimitiveType(int index)

Parameters

index int

Returns

uint

_SurfaceSetMaterial(int, Material)

Virtual method to override the setting of a material at the given index for a custom class extending Mesh.

public virtual void _SurfaceSetMaterial(int index, Material material)

Parameters

index int
material Material