ImporterMesh
Hereda: Resource < RefCounted < Object
Un Resource que contiene geometría basada en un array de vértices durante el proceso de importación.
Descripción
ImporterMesh is a type of Resource analogous to ArrayMesh. It contains vertex array-based geometry, divided in surfaces. Each surface contains a completely separate array and a material used to draw it. Design wise, a mesh with multiple surfaces is preferred to a single surface, because objects created in 3D editing software commonly contain multiple materials.
Unlike its runtime counterpart, ImporterMesh contains mesh data before various import steps, such as lod and shadow mesh generation, have taken place. Modify surface data by calling clear(), followed by add_surface() for each surface.
Métodos
void |
add_blend_shape(name: String) |
void |
add_surface(primitive: PrimitiveType, arrays: Array, blend_shapes: Array[Array] = [], lods: Dictionary = {}, material: Material = null, name: String = "", flags: int = 0) |
void |
clear() |
void |
generate_lods(normal_merge_angle: float, normal_split_angle: float, bone_transform_array: Array) |
get_blend_shape_count() const |
|
get_blend_shape_mode() const |
|
get_blend_shape_name(blend_shape_idx: int) const |
|
get_lightmap_size_hint() const |
|
get_surface_arrays(surface_idx: int) const |
|
get_surface_blend_shape_arrays(surface_idx: int, blend_shape_idx: int) const |
|
get_surface_count() const |
|
get_surface_format(surface_idx: int) const |
|
get_surface_lod_count(surface_idx: int) const |
|
get_surface_lod_indices(surface_idx: int, lod_idx: int) const |
|
get_surface_lod_size(surface_idx: int, lod_idx: int) const |
|
get_surface_material(surface_idx: int) const |
|
get_surface_name(surface_idx: int) const |
|
get_surface_primitive_type(surface_idx: int) |
|
void |
|
void |
set_lightmap_size_hint(size: Vector2i) |
void |
set_surface_material(surface_idx: int, material: Material) |
void |
set_surface_name(surface_idx: int, name: String) |
Descripciones de Métodos
void add_blend_shape(name: String) 🔗
Añade un nombre para una blend shape que se añadirá con add_surface(). Debe ser llamado antes de añadir la superficie.
void add_surface(primitive: PrimitiveType, arrays: Array, blend_shapes: Array[Array] = [], lods: Dictionary = {}, material: Material = null, name: String = "", flags: int = 0) 🔗
Creates a new surface. Mesh.get_surface_count() will become the surf_idx for this new surface.
Surfaces are created to be rendered using a primitive, which may be any of the values defined in PrimitiveType.
The arrays argument is an array of arrays. Each of the Mesh.ARRAY_MAX elements contains an array with some of the mesh data for this surface as described by the corresponding member of ArrayType or null if it is not used by the surface. 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 surface 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 an exact multiple of the vertex array's length, when multiple elements of a sub-array correspond to a single vertex) or be empty, except for Mesh.ARRAY_INDEX if it is used.
The blend_shapes argument is an array of vertex data for each blend shape. Each element is an array of the same structure as arrays, but Mesh.ARRAY_VERTEX, Mesh.ARRAY_NORMAL, and Mesh.ARRAY_TANGENT are set if and only if they are set in arrays and all other entries are null.
The lods argument is a dictionary with float keys and PackedInt32Array values. Each entry in the dictionary represents an LOD level of the surface, where the value is the Mesh.ARRAY_INDEX array to use for the LOD level and the key is roughly proportional to the distance at which the LOD stats being used. I.e., increasing the key of an LOD also increases the distance that the objects has to be from the camera before the LOD is used.
The flags argument is the bitwise OR of, as required: One value of ArrayCustomFormat left shifted by ARRAY_FORMAT_CUSTOMn_SHIFT for each custom channel in use, Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE, Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS, or Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY.
Note: When using indices, it is recommended to only use points, lines, or triangles.
void clear() 🔗
Elimina todas las superficies y las blendshapes de este ImporterMesh.
void generate_lods(normal_merge_angle: float, normal_split_angle: float, bone_transform_array: Array) 🔗
Generates all lods for this ImporterMesh.
normal_merge_angle is in degrees and used in the same way as the importer settings in lods.
normal_split_angle is not used and only remains for compatibility with older versions of the API.
The number of generated lods can be accessed using get_surface_lod_count(), and each LOD is available in get_surface_lod_size() and get_surface_lod_indices().
bone_transform_array is an Array which can be either empty or contain Transform3Ds which, for each of the mesh's bone IDs, will apply mesh skinning when generating the LOD mesh variations. This is usually used to account for discrepancies in scale between the mesh itself and its skinning data.
int get_blend_shape_count() const 🔗
Devuelve el número de blend shapes que la malla contiene.
BlendShapeMode get_blend_shape_mode() const 🔗
Devuelve el modo de blend shape para esta malla.
String get_blend_shape_name(blend_shape_idx: int) const 🔗
Devuelve el nombre de la forma de mezcla de este indice.
Vector2i get_lightmap_size_hint() const 🔗
Devuelve la sugerencia de tamaño de esta malla para el desempaquetado de lightmap en el espacio UV.
ArrayMesh get_mesh(base_mesh: ArrayMesh = null) 🔗
Devuelve los datos de la malla representados por este ImporterMesh como un ArrayMesh utilizable.
Este método almacena en caché la malla devuelta, y las llamadas posteriores devolverán los datos almacenados en caché hasta que se llame a clear().
Si aún no está en caché y se proporciona base_mesh, se utilizará y modificará base_mesh.
Array get_surface_arrays(surface_idx: int) const 🔗
Devuelve los arrays para los vértices, normales, UVs, etc. que conforman la superficie solicitada. Véase add_surface().
Array get_surface_blend_shape_arrays(surface_idx: int, blend_shape_idx: int) const 🔗
Devuelve un único conjunto de arrays de blend shape para el índice de blend shape solicitado para una superficie.
int get_surface_count() const 🔗
Devuelve el número de superficies que contiene la malla.
int get_surface_format(surface_idx: int) const 🔗
Devuelve el formato de la superficie que contiene la malla.
int get_surface_lod_count(surface_idx: int) const 🔗
Devuelve el número de LODs que la malla contiene en una superficie determinada.
PackedInt32Array get_surface_lod_indices(surface_idx: int, lod_idx: int) const 🔗
Devuelve el búfer de índices de un LOD para una superficie.
float get_surface_lod_size(surface_idx: int, lod_idx: int) const 🔗
Devuelve la proporción de pantalla que activa un LOD para una superficie.
Material get_surface_material(surface_idx: int) const 🔗
Devuelve un Material en una superficie determinada. La superficie se renderiza usando este material.
String get_surface_name(surface_idx: int) const 🔗
Obtiene el nombre asignado a esta superficie.
PrimitiveType get_surface_primitive_type(surface_idx: int) 🔗
Devuelve el tipo primitivo de la superficie solicitada (véase add_surface()).
void set_blend_shape_mode(mode: BlendShapeMode) 🔗
Establece el modo de blend shape.
void set_lightmap_size_hint(size: Vector2i) 🔗
Establece la sugerencia de tamaño de esta malla para el desempaquetado de lightmap en el espacio UV.
void set_surface_material(surface_idx: int, material: Material) 🔗
Establece un Material para una superficie determinada. La superficie se renderizará usando este material.
void set_surface_name(surface_idx: int, name: String) 🔗
Obtiene un nombre para una superficie dada.