Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
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¶
|
Methods¶
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.