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$(D 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.
Centers the geometry.
Remove all blend shapes from this ArrayMesh.
Returns the number of blend shapes that the ArrayMesh holds.
Returns the name of the blend shape at this index.
Will perform a UV unwrap on the ArrayMesh to prepare the mesh for lightmapping.
Will regenerate normal maps for the ArrayMesh.
Return the index of the first surface with this name held within this ArrayMesh. If none are found -1 is returned.
Return the length in indices of the index array in the requested surface (see addSurfaceFromArrays).
Return the length in vertices of the vertex array in the requested surface (see addSurfaceFromArrays).
Return the format mask of the requested surface (see addSurfaceFromArrays).
Get the name assigned to this surface.
Return the primitive type of the requested surface (see addSurfaceFromArrays).
Remove a surface at position surf_idx, shifting greater surfaces one surf_idx slot down.
Set a Material for a given surface. Surface will be rendered using this material.
Set a name for a given surface.
An overriding bounding box for this mesh.
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
The MeshInstance is ready to be added to the SceneTree to be shown.
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