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; }

An overriding bounding box for this mesh.

Methods

    public void AddBlendShape(string name)

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

Creates a new surface.

Surfaces are created to be rendered using a “primitive”, which may be PRIMITIVE_POINTS, PRIMITIVE_LINES, PRIMITIVE_LINE_STRIP, PRIMITIVE_LINE_LOOP, PRIMITIVE_TRIANGLES, PRIMITIVE_TRIANGLE_STRIP, PRIMITIVE_TRIANGLE_FAN. See Mesh for details. (As a note, when using indices, it is recommended to only use points, lines or triangles). Mesh.GetSurfaceCount() will become the surf_idx for this new surface.

The arrays argument is an array of arrays. See ArrayType for the values used in this array. For example, arrays[0] is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this function into “index mode” where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array or be empty, except for ARRAY_INDEX if it is used.

Adding an index array puts this function into “index mode” where the vertex and other arrays become the sources of data, and the index array defines the order of the vertices.

Godot uses clockwise winding order for front faces of triangle primitive modes.

    public void CenterGeometry()

Centers the geometry.

    public void ClearBlendShapes()

Remove all blend shapes from this ArrayMesh.

    public int GetBlendShapeCount()

Returns the number of blend shapes that the ArrayMesh holds.

    public BlendShapeMode GetBlendShapeMode()

Getter for BlendShapeMode

    public string GetBlendShapeName(int index)

Returns the name of the blend shape at this index.

    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.

    public void SetBlendShapeMode(BlendShapeMode mode)

Setter for BlendShapeMode

    public void SetCustomAabb(AABB aabb)

Setter for CustomAabb

    public int SurfaceFindByName(string name)

Return 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)

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

    public int SurfaceGetArrayLen(int surfIdx)

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

    public int SurfaceGetFormat(int surfIdx)

Return the format mask of the requested surface (see AddSurfaceFromArrays(Godot.Mesh.PrimitiveType, Godot.Collections.Array, Godot.Collections.Array, int)).

    public string SurfaceGetName(int surfIdx)

Get the name assigned to this surface.

    public PrimitiveType SurfaceGetPrimitiveType(int surfIdx)

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

    public void SurfaceRemove(int surfIdx)

Remove a surface at position surf_idx, shifting greater surfaces one surf_idx slot down.

    public void SurfaceSetMaterial(int surfIdx, Material material)

Set a Material for a given surface. Surface will be rendered using this material.

    public void SurfaceSetName(int surfIdx, string name)

Set a name for a given surface.

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

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 Vertex array (array of [Vector3] vertices).
Normal 1 Normal array (array of [Vector3] normals).
Tangent 2 Tangent array, array of groups of 4 floats. first 3 floats determine the tangent, and the last the binormal direction as -1 or 1.
Color 3 Vertex array (array of [Color] colors).
TexUv 4 UV array (array of [Vector3] UVs or float array of groups of 2 floats (u,v)).
TexUv2 5 Second UV array (array of [Vector3] UVs or float array of groups of 2 floats (u,v)).
Bones 6 Array of bone indices, as a float array. Each element in groups of 4 floats.
Weights 7 Array of bone weights, as a float array. Each element in groups of 4 floats.
Index 8 [Array] 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  
Tags: