Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Mesh

Inherits: Resource < RefCounted < Object

Inherited By: ArrayMesh, ImmediateMesh, PlaceholderMesh, PrimitiveMesh

A Resource that contains vertex array-based geometry.

Description

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.

Tutorials

Properties

Vector2i

lightmap_size_hint

Vector2i(0, 0)

Methods

AABB

_get_aabb ( ) virtual const

int

_get_blend_shape_count ( ) virtual const

StringName

_get_blend_shape_name ( int index ) virtual const

int

_get_surface_count ( ) virtual const

void

_set_blend_shape_name ( int index, StringName name ) virtual

int

_surface_get_array_index_len ( int index ) virtual const

int

_surface_get_array_len ( int index ) virtual const

Array

_surface_get_arrays ( int index ) virtual const

Array[]

_surface_get_blend_shape_arrays ( int index ) virtual const

int

_surface_get_format ( int index ) virtual const

Dictionary

_surface_get_lods ( int index ) virtual const

Material

_surface_get_material ( int index ) virtual const

int

_surface_get_primitive_type ( int index ) virtual const

void

_surface_set_material ( int index, Material material ) virtual

ConvexPolygonShape3D

create_convex_shape ( bool clean=true, bool simplify=false ) const

Mesh

create_outline ( float margin ) const

Resource

create_placeholder ( ) const

ConcavePolygonShape3D

create_trimesh_shape ( ) const

TriangleMesh

generate_triangle_mesh ( ) const

AABB

get_aabb ( ) const

PackedVector3Array

get_faces ( ) const

int

get_surface_count ( ) const

Array

surface_get_arrays ( int surf_idx ) const

Array[]

surface_get_blend_shape_arrays ( int surf_idx ) const

Material

surface_get_material ( int surf_idx ) const

void

surface_set_material ( int surf_idx, Material material )


Enumerations

enum PrimitiveType:

PrimitiveType PRIMITIVE_POINTS = 0

Render array as points (one vertex equals one point).

PrimitiveType PRIMITIVE_LINES = 1

Render array as lines (every two vertices a line is created).

PrimitiveType PRIMITIVE_LINE_STRIP = 2

Render array as line strip.

PrimitiveType PRIMITIVE_TRIANGLES = 3

Render array as triangles (every three vertices a triangle is created).

PrimitiveType PRIMITIVE_TRIANGLE_STRIP = 4

Render array as triangle strips.


enum ArrayType:

ArrayType ARRAY_VERTEX = 0

PackedVector3Array, PackedVector2Array, or Array of vertex positions.

ArrayType ARRAY_NORMAL = 1

PackedVector3Array of vertex normals.

ArrayType ARRAY_TANGENT = 2

PackedFloat32Array of vertex tangents. Each element in groups of 4 floats, first 3 floats determine the tangent, and the last the binormal direction as -1 or 1.

ArrayType ARRAY_COLOR = 3

PackedColorArray of vertex colors.

ArrayType ARRAY_TEX_UV = 4

PackedVector2Array for UV coordinates.

ArrayType ARRAY_TEX_UV2 = 5

PackedVector2Array for second UV coordinates.

ArrayType ARRAY_CUSTOM0 = 6

Contains custom color channel 0. PackedByteArray if (format >> Mesh.ARRAY_FORMAT_CUSTOM0_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK is ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RG_HALF or ARRAY_CUSTOM_RGBA_HALF. PackedFloat32Array otherwise.

ArrayType ARRAY_CUSTOM1 = 7

Contains custom color channel 1. PackedByteArray if (format >> Mesh.ARRAY_FORMAT_CUSTOM1_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK is ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RG_HALF or ARRAY_CUSTOM_RGBA_HALF. PackedFloat32Array otherwise.

ArrayType ARRAY_CUSTOM2 = 8

Contains custom color channel 2. PackedByteArray if (format >> Mesh.ARRAY_FORMAT_CUSTOM2_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK is ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RG_HALF or ARRAY_CUSTOM_RGBA_HALF. PackedFloat32Array otherwise.

ArrayType ARRAY_CUSTOM3 = 9

Contains custom color channel 3. PackedByteArray if (format >> Mesh.ARRAY_FORMAT_CUSTOM3_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK is ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RGBA8_UNORM, ARRAY_CUSTOM_RG_HALF or ARRAY_CUSTOM_RGBA_HALF. PackedFloat32Array otherwise.

ArrayType ARRAY_BONES = 10

PackedFloat32Array or PackedInt32Array of bone indices. Contains either 4 or 8 numbers per vertex depending on the presence of the ARRAY_FLAG_USE_8_BONE_WEIGHTS flag.

ArrayType ARRAY_WEIGHTS = 11

PackedFloat32Array or PackedFloat64Array of bone weights in the range 0.0 to 1.0 (inclusive). Contains either 4 or 8 numbers per vertex depending on the presence of the ARRAY_FLAG_USE_8_BONE_WEIGHTS flag.

ArrayType ARRAY_INDEX = 12

PackedInt32Array of integers used as indices referencing vertices, colors, normals, tangents, and textures. All of those arrays must have the same number of elements as the vertex array. No index can be beyond the vertex array size. When this index array is present, it puts the function into "index mode," where the index selects the i'th vertex, normal, tangent, color, UV, etc. This means if you want to have different normals or colors along an edge, you have to duplicate the vertices.

For triangles, the index array is interpreted as triples, referring to the vertices of each triangle. For lines, the index array is in pairs indicating the start and end of each line.

ArrayType ARRAY_MAX = 13

Represents the size of the ArrayType enum.


enum ArrayCustomFormat:

ArrayCustomFormat ARRAY_CUSTOM_RGBA8_UNORM = 0

Indicates this custom channel contains unsigned normalized byte colors from 0 to 1, encoded as PackedByteArray.

ArrayCustomFormat ARRAY_CUSTOM_RGBA8_SNORM = 1

Indicates this custom channel contains signed normalized byte colors from -1 to 1, encoded as PackedByteArray.

ArrayCustomFormat ARRAY_CUSTOM_RG_HALF = 2

Indicates this custom channel contains half precision float colors, encoded as PackedByteArray. Only red and green channels are used.

ArrayCustomFormat