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.
Checking the stable version of the documentation...
ArrayMesh¶
Inherits: Mesh < Resource < RefCounted < Object
Mesh type that provides utility for constructing a surface from arrays.
Description¶
The ArrayMesh is used to construct a Mesh by specifying the attributes as arrays.
The most basic example is the creation of a single triangle:
var vertices = PackedVector3Array()
vertices.push_back(Vector3(0, 1, 0))
vertices.push_back(Vector3(1, 0, 0))
vertices.push_back(Vector3(0, 0, 1))
# Initialize the ArrayMesh.
var arr_mesh = ArrayMesh.new()
var arrays = []
arrays.resize(Mesh.ARRAY_MAX)
arrays[Mesh.ARRAY_VERTEX] = vertices
# Create the Mesh.
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
var m = MeshInstance3D.new()
m.mesh = arr_mesh
var vertices = new Vector3[]
{
new Vector3(0, 1, 0),
new Vector3(1, 0, 0),
new Vector3(0, 0, 1),
};
// Initialize the ArrayMesh.
var arrMesh = new ArrayMesh();
var arrays = new Godot.Collections.Array();
arrays.Resize((int)Mesh.ArrayType.Max);
arrays[(int)Mesh.ArrayType.Vertex] = vertices;
// Create the Mesh.
arrMesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, arrays);
var m = new MeshInstance3D();
m.Mesh = arrMesh;
The MeshInstance3D is ready to be added to the SceneTree to be shown.
See also ImmediateMesh, MeshDataTool and SurfaceTool for procedural geometry generation.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Tutorials¶
Properties¶
|
||
|
||
Methods¶
void |
add_blend_shape ( StringName name ) |
void |
add_surface_from_arrays ( PrimitiveType primitive, Array arrays, Array[] blend_shapes=[], Dictionary lods={}, BitField<ArrayFormat> flags=0 ) |
void |
|
void |
clear_surfaces ( ) |
get_blend_shape_count ( ) const |
|
get_blend_shape_name ( int index ) const |
|
lightmap_unwrap ( Transform3D transform, float texel_size ) |
|
void |
|
void |
set_blend_shape_name ( int index, StringName name ) |