Mesh type that provides utility for constructing a surface from arrays.
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 = 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) arrays[ArrayMesh.ARRAY_VERTEX] = vertices # Create the Mesh. arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays) var m = MeshInstance.new() m.mesh = arr_mesh
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
clear_surfaces ( )
get_blend_shape_count ( ) const
regen_normalmaps ( )
ArrayType ARRAY_VERTEX =
ArrayType ARRAY_NORMAL =
PoolVector3Array of vertex normals.
ArrayType ARRAY_TANGENT =
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.
ArrayType ARRAY_COLOR =
PoolColorArray of vertex colors.
ArrayType ARRAY_TEX_UV =
PoolVector2Array for UV coordinates.
ArrayType ARRAY_TEX_UV2 =
PoolVector2Array for second UV coordinates.
ArrayType ARRAY_BONES =
ArrayType ARRAY_WEIGHTS =
PoolRealArray of bone weights. Each element in groups of 4 floats.
ArrayType ARRAY_INDEX =
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.
ArrayType ARRAY_MAX =
Represents the size of the ArrayType enum.
ArrayFormat ARRAY_FORMAT_VERTEX =
Array format will include vertices (mandatory).
ArrayFormat ARRAY_FORMAT_NORMAL =
Array format will include normals.
ArrayFormat ARRAY_FORMAT_TANGENT =
Array format will include tangents.
ArrayFormat ARRAY_FORMAT_COLOR =
Array format will include a color array.
ArrayFormat ARRAY_FORMAT_TEX_UV =
Array format will include UVs.
ArrayFormat ARRAY_FORMAT_TEX_UV2 =
Array format will include another set of UVs.
ArrayFormat ARRAY_FORMAT_BONES =
Array format will include bone indices.
ArrayFormat ARRAY_FORMAT_WEIGHTS =
Array format will include bone weights.
ArrayFormat ARRAY_FORMAT_INDEX =
Index array will be used.
Value used internally when no indices are present.
Amount of weights/bone indices per vertex (always 4).
BlendShapeMode blend_shape_mode =
Sets the blend shape mode to one of BlendShapeMode.
AABB custom_aabb =
AABB( 0, 0, 0, 0, 0, 0 )
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.
void add_blend_shape ( String name )
Adds name for a blend shape that will be added with add_surface_from_arrays. Must be called before surface is added.
Creates a new surface.
Surfaces are created to be rendered using a
primitive, which may be any of the types defined in PrimitiveType. (As a note, when using indices, it is recommended to only use points, lines, or triangles.) Mesh.get_surface_count will become the
surf_idx for this new surface.
arrays argument is an array of arrays. See ArrayType for the values used in this array. For example,
arrays 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.
Note: The default
compress_flags enable Mesh.ARRAY_COMPRESS_COLOR, which makes vertex colors stored as 8-bit unsigned integers. This will clamp overbright vertex colors to
Color(1, 1, 1, 1) and reduce their precision. To store HDR vertex colors, remove the vertex color compression flag by passing
Mesh.ARRAY_COMPRESS_DEFAULT ^ Mesh.ARRAY_COMPRESS_COLOR as the value of
void clear_blend_shapes ( )
Removes all blend shapes from this ArrayMesh.
void clear_surfaces ( )
Removes all surfaces from this ArrayMesh.
int get_blend_shape_count ( ) const
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.
void regen_normalmaps ( )
Will regenerate normal maps for the ArrayMesh.
There is currently no description for this method. Please help us by contributing one!
Returns the index of the first surface with this name held within this ArrayMesh. If none are found, -1 is returned.
Returns the length in indices of the index array in the requested surface (see add_surface_from_arrays).
Returns the length in vertices of the vertex array in the requested surface (see add_surface_from_arrays).
Returns the format mask of the requested surface (see add_surface_from_arrays).
Gets the name assigned to this surface.
Returns the primitive type of the requested surface (see add_surface_from_arrays).
void surface_remove ( int surf_idx )
Removes a surface at position
surf_idx, shifting greater surfaces one
surf_idx slot down.
Sets a name for a given surface.
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.