ArrayMesh¶
Inherits: Mesh < Resource < Reference < Object
Tipo Mesh que provee la funcionalidad para construir una superficie desde arrays.
Descripción¶
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
The MeshInstance is ready to be added to the SceneTree to be shown.
See also ImmediateGeometry, MeshDataTool and SurfaceTool for procedural geometry generation.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Tutoriales¶
Propiedades¶
|
||
|
Métodos¶
void |
add_blend_shape ( String name ) |
void |
add_surface_from_arrays ( PrimitiveType primitive, Array arrays, Array blend_shapes=[ ], int compress_flags=2194432 ) |
void |
|
void |
clear_surfaces ( ) |
get_blend_shape_count ( ) const |
|
get_blend_shape_name ( int index ) const |
|
lightmap_unwrap ( Transform transform, float texel_size ) |
|
void |
regen_normalmaps ( ) |
void |
set_blend_shape_name ( int index, String name ) |
surface_find_by_name ( String name ) const |
|
surface_get_array_index_len ( int surf_idx ) const |
|
surface_get_array_len ( int surf_idx ) const |
|
surface_get_format ( int surf_idx ) const |
|
surface_get_name ( int surf_idx ) const |
|
surface_get_primitive_type ( int surf_idx ) const |
|
void |
surface_remove ( int surf_idx ) |
void |
surface_set_name ( int surf_idx, String name ) |
void |
surface_update_region ( int surf_idx, int offset, PoolByteArray data ) |
Enumeraciones¶
enum ArrayType:
ARRAY_VERTEX = 0 --- PoolVector3Array, PoolVector2Array, or Array of vertex positions.
ARRAY_NORMAL = 1 --- PoolVector3Array of vertex normals.
ARRAY_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.
ARRAY_COLOR = 3 --- PoolColorArray of vertex colors.
ARRAY_TEX_UV = 4 --- PoolVector2Array for UV coordinates.
ARRAY_TEX_UV2 = 5 --- PoolVector2Array for second UV coordinates.
ARRAY_BONES = 6 --- PoolRealArray or PoolIntArray of bone indices. Each element in groups of 4 floats.
ARRAY_WEIGHTS = 7 --- PoolRealArray of bone weights. Each element in groups of 4 floats.
ARRAY_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.
ARRAY_MAX = 9 --- Representa el tamaño del enum ArrayType.
enum ArrayFormat:
ARRAY_FORMAT_VERTEX = 1 --- El formato de Arary incluira vertices (obligatorio).
ARRAY_FORMAT_NORMAL = 2 --- El format de array incluira normales.
ARRAY_FORMAT_TANGENT = 4 --- El formato de array incluira tangentes.
ARRAY_FORMAT_COLOR = 8 --- El formato de array incluira un array de colores.
ARRAY_FORMAT_TEX_UV = 16 --- El formato de array incluira UVs.
ARRAY_FORMAT_TEX_UV2 = 32 --- El formato de array incluira otr array de UVs.
ARRAY_FORMAT_BONES = 64 --- El formato de array incluira indices de hueso.
ARRAY_FORMAT_WEIGHTS = 128 --- El formato de array incluira pesos de hueso.
ARRAY_FORMAT_INDEX = 256 --- El array de indices sera utilizado.
Constantes¶
NO_INDEX_ARRAY = -1 --- Valor por defecto usado para un index_array_len cuando no hay indices.
ARRAY_WEIGHTS_SIZE = 4 --- Cantidad de pesos/hueso indices por vertice (siempre 4).
Descripciones de Propiedades¶
BlendShapeMode blend_shape_mode
Default |
|
Setter |
set_blend_shape_mode(value) |
Getter |
get_blend_shape_mode() |
Coloca el modo de mezcla de forma a BlendShapeMode.
AABB custom_aabb
Default |
|
Setter |
set_custom_aabb(value) |
Getter |
get_custom_aabb() |
Sobreescribe el AABB con uno definido por usuario para el uso con el tronco(frustum). Especialmente util para evitar inesperadas selecciones cuando se use un shader a vertices desplazados.
Descripciones de Métodos¶
void add_blend_shape ( String name )
Añade un nombre a una forma de mezcla que se añadira con add_surface_from_arrays. Debe ser llamada antes que la superficie sea añadida.
void add_surface_from_arrays ( PrimitiveType primitive, Array arrays, Array blend_shapes=[ ], int compress_flags=2194432 )
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.
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.
void clear_blend_shapes ( )
Elimina todos las formas de mezcla de este ArrayMesh
.
void clear_surfaces ( )
Elimina todas las superificies de este ArrayMesh
.
int get_blend_shape_count ( ) const
Devuelve el numero de formas de mezcla que el ArrayMesh
posee.
Devuelve el nombre de la forma de mezcla de este indice.
Ejecutara un desenvolver UV en el ArrayMesh
para preparar la malla para iluminacion de mapas.
void regen_normalmaps ( )
Regenerara los mapas de normales para el ArrayMesh
.
Devuelve el indice de la primer superficie con este nombre mantenido dentro de este ArrayMesh
. Si no es encontrado, -1 es devuelto.
Devuelve la longitud en indices del array de indices de la superificie solicitada( ver add_surface_from_arrays).
Devuelve la longitud en vertices del array de vertice en la superficie solicitada (veradd_surface_from_arrays).
Devuelve la mascara de formato de la superficie solicitada (veradd_surface_from_arrays).
Obtiene el nombre asignado a esta superficie.
PrimitiveType surface_get_primitive_type ( int surf_idx ) const
Devuelve el tipo primitivo de la superficie solicitada (ver 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.
Obtiene un nombre para una superficie dada.
void surface_update_region ( int surf_idx, int offset, PoolByteArray data )
Actualiza una region especifica de la malla de arrays en la GPU.
Aviso: Solo usarlo si sabes lo que haces. Puedes causar el programa deje de funcionar al llamar esta funcion con argumentos incorrectos.