Mesh type that provides utility for constructing a surface from arrays.
    public class ArrayMesh : Mesh

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

[codeblock]

var vertices = PoolVector3Array()

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(ArrayMesh.ARRAY_MAX)

arraysArrayMesh.ARRAY_VERTEX = vertices

Create the Mesh.

arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)

var m = MeshInstance.new()

m.mesh = arr_mesh

[/codeblock]

The MeshInstance is ready to be added to the SceneTree to be shown.

Inheritance Chain

Static Fields

    public const Int32 ArrayWeightsSize = 4

    public const Int32 NoIndexArray = -1

Constructors

    public ArrayMesh()

Properties

    public Mesh.BlendShapeMode BlendShapeMode { get; set; }

    public AABB CustomAabb { get; set; }

Overrides the AABB with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.

Methods

    public void AddBlendShape(string name)

Adds name for a blend shape that will be added with AddSurfaceFromArrays(Godot.Mesh.PrimitiveType, Godot.Collections.Array, Godot.Collections.Array, uint). Must be called before surface is added.

    public void AddSurfaceFromArrays(PrimitiveType primitive, Godot.Collections.Array arrays, Godot.Collections.Array blendShapes = null, uint compressFlags = 97280u)

    public void ClearBlendShapes()

Removes all blend shapes from this ArrayMesh.

    public int GetBlendShapeCount()

Returns the number of blend shapes that the ArrayMesh holds.

    [Obsolete("GetBlendShapeMode is deprecated. Use the BlendShapeMode property instead.")]
    public BlendShapeMode GetBlendShapeMode()

Getter for BlendShapeMode

    public string GetBlendShapeName(int index)

Returns the name of the blend shape at this index.

    [Obsolete("GetCustomAabb is deprecated. Use the CustomAabb property instead.")]
    public AABB GetCustomAabb()

Getter for CustomAabb

    public Error LightmapUnwrap(Transform transform, float texelSize)

Will perform a UV unwrap on the ArrayMesh to prepare the mesh for lightmapping.

    public void RegenNormalmaps()

Will regenerate normal maps for the ArrayMesh.

    [Obsolete("SetBlendShapeMode is deprecated. Use the BlendShapeMode property instead.")]
    public void SetBlendShapeMode(BlendShapeMode mode)

Setter for BlendShapeMode

    [Obsolete("SetCustomAabb is deprecated. Use the CustomAabb property instead.")]
    public void SetCustomAabb(AABB aabb)

Setter for CustomAabb

    public int SurfaceFindByName(string name)

Returns the index of the first surface with this name held within this ArrayMesh. If none are found, -1 is returned.

    public int SurfaceGetArrayIndexLen(int surfIdx)

Returns the length in indices of the index array in the requested surface (see AddSurfaceFromArrays(Godot.Mesh.PrimitiveType, Godot.Collections.Array, Godot.Collections.Array, uint)).

    public int SurfaceGetArrayLen(int surfIdx)

Returns the length in vertices of the vertex array in the requested surface (see AddSurfaceFromArrays(Godot.Mesh.PrimitiveType, Godot.Collections.Array, Godot.Collections.Array, uint)).

    public uint SurfaceGetFormat(int surfIdx)

    public string SurfaceGetName(int surfIdx)

Gets the name assigned to this surface.

    public PrimitiveType SurfaceGetPrimitiveType(int surfIdx)

Returns the primitive type of the requested surface (see AddSurfaceFromArrays(Godot.Mesh.PrimitiveType, Godot.Collections.Array, Godot.Collections.Array, uint)).

    public void SurfaceRemove(int surfIdx)

Removes a surface at position surfIdx, shifting greater surfaces one surfIdx slot down.

    public void SurfaceSetName(int surfIdx, string name)

Sets a name for a given surface.

    public void SurfaceUpdateRegion(int surfIdx, int offset, byte[] data)

Updates a specified region of mesh arrays on the GPU.

Warning: Only use if you know what you are doing. You can easily cause crashes by calling this function with improper arguments.

Inner Types

ArrayFormat

Name Value Description
Vertex 1 Array format will include vertices (mandatory).
Normal 2 Array format will include normals
Tangent 4 Array format will include tangents
Color 8 Array format will include a color array.
TexUv 16 Array format will include UVs.
TexUv2 32 Array format will include another set of UVs.
Bones 64 Array format will include bone indices.
Weights 128 Array format will include bone weights.
Index 256 Index array will be used.

ArrayType

Name Value Description
Vertex 0 [PoolVector3Array], [PoolVector2Array], or [Array] of vertex positions.
Normal 1 [PoolVector3Array] of vertex normals.
Tangent 2 [PoolRealArray] 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.
Color 3 [PoolColorArray] of vertex colors.
TexUv 4 [PoolVector2Array] for UV coordinates.
TexUv2 5 [PoolVector2Array] for second UV coordinates.
Bones 6 [PoolRealArray] or [PoolIntArray] of bone indices. Each element in groups of 4 floats.
Weights 7 [PoolRealArray] of bone weights. Each element in groups of 4 floats.
Index 8 [PoolIntArray] 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.    
Max 9 Represents the size of the [enum ArrayType] enum.
Tags: