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
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
Returns
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
CreatePlaceholder()
Creates a placeholder version of this resource (PlaceholderMesh).
public Resource CreatePlaceholder()
Returns
CreateTrimeshShape()
Calculate a ConcavePolygonShape3D from the mesh.
public ConcavePolygonShape3D CreateTrimeshShape()
Returns
GenerateTriangleMesh()
Generate a TriangleMesh from the mesh. Considers only surfaces using one of these primitive types: Triangles, TriangleStrip.
public TriangleMesh GenerateTriangleMesh()
Returns
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
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
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
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
SurfaceGetBlendShapeArrays(int)
Returns the blend shape arrays for the requested surface.
public Array<Array> SurfaceGetBlendShapeArrays(int surfIdx)
Parameters
surfIdx
int
Returns
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
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
_GetAabb()
public virtual Aabb _GetAabb()
Returns
_GetBlendShapeCount()
Virtual method to override the number of blend shapes for a custom class extending Mesh.
public virtual int _GetBlendShapeCount()
Returns
_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
_GetSurfaceCount()
Virtual method to override the surface count for a custom class extending Mesh.
public virtual int _GetSurfaceCount()
Returns
_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
intname
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
_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
_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
_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
_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
_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
_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
_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
_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)