Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

ImporterMesh

Eredita: Resource < RefCounted < Object

Una Resource che contiene la geometria basata su array di vertici durante il processo di importazione.

Descrizione

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.

Metodi

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

ImporterMesh

from_mesh(mesh: Mesh) static

void

generate_lods(normal_merge_angle: float, normal_split_angle: float, bone_transform_array: Array)

int

get_blend_shape_count() const

BlendShapeMode

get_blend_shape_mode() const

String

get_blend_shape_name(blend_shape_idx: int) const

Vector2i

get_lightmap_size_hint() const

ArrayMesh

get_mesh(base_mesh: ArrayMesh = null)

Array

get_surface_arrays(surface_idx: int) const

Array

get_surface_blend_shape_arrays(surface_idx: int, blend_shape_idx: int) const

int

get_surface_count() const

int

get_surface_format(surface_idx: int) const

int

get_surface_lod_count(surface_idx: int) const

PackedInt32Array

get_surface_lod_indices(surface_idx: int, lod_idx: int) const

float

get_surface_lod_size(surface_idx: int, lod_idx: int) const

Material

get_surface_material(surface_idx: int) const

String

get_surface_name(surface_idx: int) const

PrimitiveType

get_surface_primitive_type(surface_idx: int)

ImporterMesh

merge_importer_meshes(importer_meshes: Array[ImporterMesh], relative_transforms: Array[Transform3D], deduplicate_surfaces: bool = true) static

void

set_blend_shape_mode(mode: BlendShapeMode)

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)


Descrizioni dei metodi

void add_blend_shape(name: String) 🔗

Aggiunge un nome per una forma di fusione che sarà aggiunta con add_surface(). Deve essere chiamato prima di aggiungere la superficie.


void add_surface(primitive: PrimitiveType, arrays: Array, blend_shapes: Array[Array] = [], lods: Dictionary = {}, material: Material = null, name: String = "", flags: int = 0) 🔗

Crea una nuova superficie. Mesh.get_surface_count() diventerà il surf_idx per questa nuova superficie.

Le superfici sono renderizzate tramite un primitive, che può essere uno qualsiasi dei valori definiti in PrimitiveType.

L'argomento arrays è un array di array. Ciascuno degli elementi Mesh.ARRAY_MAX contiene un array con alcuni dei dati della mesh per questa superficie, come descritto dal membro corrispondente di ArrayType o null se non è utilizzato dalla superficie. Ad esempio, arrays[0] è l'array dei vertici. Il primo sottoarray di vertici è sempre obbligatorio; gli altri sono facoltativi. L'aggiunta di un array di indici mette questa superficie in "modalità indice", dove i vertici e gli altri array diventano le sorgenti di dati e l'array di indici definisce l'ordine dei vertici. Tutti i sottoarray devono avere la stessa lunghezza dell'array dei vertici (o essere un multiplo esatto della lunghezza dell'array dei vertici, quando più elementi di un sottoarray corrispondono a un singolo vertice) oppure essere vuoti, ad eccezione di Mesh.ARRAY_INDEX, se utilizzato.

L'argomento blend_shapes è un array di dati dei vertici per ogni forma di fusione. Ogni elemento è un array con la stessa struttura di arrays, ma Mesh.ARRAY_VERTEX, Mesh.ARRAY_NORMAL e Mesh.ARRAY_TANGENT sono impostati solo se sono impostati in arrays e tutte le altre voci sono null.

L'argomento lods è un dizionario con chiavi float e valori PackedInt32Array. Ogni voce nel dizionario rappresenta un livello LOD della superficie, dove il valore è l'array Mesh.ARRAY_INDEX da utilizzare per il livello LOD e la chiave è approssimativamente proporzionale alla distanza a cui vengono utilizzate le statistiche LOD. Ad esempio, aumentando la chiave di un LOD aumenta anche la distanza che gli oggetti devono avere dalla telecamera prima che il LOD venga utilizzato.

L'argomento flags è l'OR bit a bit di, a seconda delle esigenze: un valore di ArrayCustomFormat spostato a sinistra di ARRAY_FORMAT_CUSTOMn_SHIFT per ogni canale personalizzato in uso, Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE, Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS o Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY.

Nota: Quando si utilizzano indici, si consiglia di usare solo punti, linee o triangoli.


void clear() 🔗

Rimuove tutte le superfici e le forme di fusione da questo ImporterMesh.


ImporterMesh from_mesh(mesh: Mesh) static 🔗

Converts the given Mesh into an ImporterMesh by copying all its surfaces, blend shapes, materials, and metadata into a new ImporterMesh object.


void generate_lods(normal_merge_angle: float, normal_split_angle: float, bone_transform_array: Array) 🔗

Genera tutti i LOD per questo ImporterMesh.

normal_merge_angle è in gradi e utilizzato nello stesso modo delle impostazioni d'importazione in lods.

normal_split_angle non viene utilizzato e rimane solo per compatibilità con le versioni precedenti dell'API.

È possibile accedere al numero di lod generati tramite get_surface_lod_count() e ogni LOD è disponibile in get_surface_lod_size() e get_surface_lod_indices().

bone_transform_array è un Array che può essere vuoto o contenere Transform3D che, per ciascuno degli ID osso della mesh, applicherà lo skinning della mesh durante la generazione delle variazioni LOD della mesh. Questo viene solitamente utilizzato per tenere conto delle discrepanze di scala tra la mesh stessa e i suoi dati di skinning.


int get_blend_shape_count() const 🔗

Restituisce il numero di forme di fusione contenute nella mesh.


BlendShapeMode get_blend_shape_mode() const 🔗

Restituisce la modalità delle forme di fusione per questa Mesh.


String get_blend_shape_name(blend_shape_idx: int) const 🔗

Restituisce il nome della forma di fusione a questo indice.


Vector2i get_lightmap_size_hint() const 🔗

Restituisce il suggerimento delle dimensioni di questa mesh per l'unwrapping della lightmap nello spazio UV.


ArrayMesh get_mesh(base_mesh: ArrayMesh = null) 🔗

Restituisce i dati della mesh rappresentati da questo ImporterMesh come un ArrayMesh utilizzabile.

Questo metodo memorizza nella cache i dati restituiti della mesh, e le chiamate successive restituiranno i dati nella cache finché non viene chiamato clear().

Se i dati non sono ancora memorizzati nella cache e viene fornito base_mesh, base_mesh verrà utilizzato e modificato.


Array get_surface_arrays(surface_idx: int) const 🔗

Restituisce gli array per i vertici, normali, UV, ecc. che compongono la superficie richiesta. Vedi add_surface().


Array get_surface_blend_shape_arrays(surface_idx: int, blend_shape_idx: int) const 🔗

Restituisce una singola serie di array di forme di fusione per l'indice di forma di fusione richiesto per una superficie.


int get_surface_count() const 🔗

Restituisce il numero di superfici che la mesh mantiene.


int get_surface_format(surface_idx: int) const 🔗

Restituisce il formato della superficie che la mesh tiene.


int get_surface_lod_count(surface_idx: int) const 🔗

Restituisce il numero di LOD che la mesh mantiene su una data superficie.


PackedInt32Array get_surface_lod_indices(surface_idx: int, lod_idx: int) const 🔗

Restituisce il buffer di indice di un LOD per una superficie.


float get_surface_lod_size(surface_idx: int, lod_idx: int) const 🔗

Restituisce il rapporto schermo che attiva un LOD per una superficie.


Material get_surface_material(surface_idx: int) const 🔗

Restituisce un Material per una determinata superficie. La superficie è renderizzata utilizzando questo materiale.


String get_surface_name(surface_idx: int) const 🔗

Ottiene il nome assegnato a questa superficie.


PrimitiveType get_surface_primitive_type(surface_idx: int) 🔗

Restituisce il tipo di primitiva della superficie richiesta (vedi add_surface()).


ImporterMesh merge_importer_meshes(importer_meshes: Array[ImporterMesh], relative_transforms: Array[Transform3D], deduplicate_surfaces: bool = true) static 🔗

Merges multiple ImporterMeshes into a single ImporterMesh. Each input mesh is transformed by the corresponding Transform3D in the relative_transforms array, which must be the same size as importer_meshes. Negative scales are supported, and the winding order in the mesh data will be corrected to account for this.

If deduplicate_surfaces is true and multiple meshes have surfaces with the same names and formats, the surfaces will be merged together when the meshes are merged, and will use the material from the first matching surface. This is useful for reducing the number of surfaces in the resulting mesh, and avoids duplicating materials. Surfaces with bone weights will never be deduplicated. If deduplicate_surfaces is false, the surfaces will always be kept separate, and will be given unique names.

Warning: Blend shapes and LODs are not supported and will be discarded. Do not use this function to discard blend shapes and LODs, as support for these may be added in the future.


void set_blend_shape_mode(mode: BlendShapeMode) 🔗

Imposta la modalità delle forme di fusione.


void set_lightmap_size_hint(size: Vector2i) 🔗

Imposta il suggerimento sulla dimensione di questa mesh per l'unwrapping della lightmap nello spazio UV.


void set_surface_material(surface_idx: int, material: Material) 🔗

Imposta un Material per una determinata superficie. La superficie sarà renderizzata utilizzando questo materiale.


void set_surface_name(surface_idx: int, name: String) 🔗

Imposta un nome per una determinata superficie.