ImporterMesh¶
继承: Resource < RefCounted < Object
在导入过程中包含基于顶点数组的几何的Resource。
描述¶
ImporterMesh是一种类似于ArrayMesh的Resource。它包含基于顶点数组的几何体,在表面中划分。每个表面都包含一个完全独立的数组和用于绘制它的材质。在设计方面,具有多个表面的网格比单个表面更受欢迎,因为在3D编辑软件中创建的对象通常包含多个材质。
与它的运行时对应物不同,ImporterMesh在各种导入步骤(例如lod和阴影网格生成)发生之前包含网格数据。
方法¶
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) |
方法说明¶
void add_blend_shape(name: String) 🔗
为将使用add_surface()添加的混合形状添加名称。必须在添加表面之前调用。
void add_surface(primitive: PrimitiveType, arrays: Array, blend_shapes: Array[Array] = [], lods: Dictionary = {}, material: Material = null, name: String = "", flags: int = 0) 🔗
创建一个新表面。Mesh.get_surface_count()将成为这个新表面的surf_idx。
创建曲面是为了使用primitive进行渲染,该原语可以是PrimitiveType中定义的任何值。
arrays参数是数组的数组。每个Mesh.ARRAY_MAX元素包含一个数组,其中包含该曲面的一些网格数据,如ArrayType或null的相应成员所描述的,如果曲面没有使用它。例如,数组[0]是顶点数组。第一个顶点子数组总是必需的;其他的是可选的。添加索引数组会使该曲面进入“索引模式”,其中顶点和其他数组成为数据源,索引数组定义顶点顺序。所有子数组必须与顶点数组具有相同的长度(或者是顶点数组长度的精确倍数,当子数组的多个元素对应于单个顶点时)或为空,如果使用Mesh.ARRAY_INDEX除外。
blend_shapes参数是每个混合形状的顶点数据数组。每个元素都是一个与arrays结构相同的数组,但是当且仅当它们在arrays中设置时才设置Mesh.ARRAY_VERTEX、Mesh.ARRAY_NORMAL和Mesh.ARRAY_TANGENT,所有其他条目都是空。
lods是一个带有float键和PackedInt32Array值的字典。字典中的每个条目代表表面的LOD级别,其中值是用于LOD级别的Mesh.ARRAY_INDEX数组,键与使用LOD统计数据的距离大致成正比。也就是说,增加LOD的键也会增加对象在使用LOD之前与摄像机的距离。
flags参数是按位或,根据需要:ArrayCustomFormat的一个值左移ARRAY_FORMAT_CUSTOMn_SHIFT对于使用中的每个自定义通道,Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE,Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS或Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY。
注意:使用索引时,建议仅使用点、线或三角形。
void clear() 🔗
从此ImporterMesh中删除所有表面并混合形状。
void generate_lods(normal_merge_angle: float, normal_split_angle: float, bone_transform_array: Array) 🔗
生成此ImporterMesh的所有lod。
normal_merge_angle以度为单位,使用方式与lods中的导入器设置相同。
normal_split_angle未使用,仅保留用于与旧版本的API兼容。
可以使用get_surface_lod_count()访问生成的lod的数量,并且每个LOD在get_surface_lod_size()和get_surface_lod_indices()中可用。
bone_transform_array是一个Array,它可以是空的,也可以包含Transform3D,对于每个网格的骨ID,在生成LOD网格变化时将应用网格蒙皮。这通常用于说明网格本身及其蒙皮数据之间的比例差异。
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 🔗
返回此网格的大小提示,以便在UV空间中进行光照贴图展开。
ArrayMesh get_mesh(base_mesh: ArrayMesh = null) 🔗
将此ImporterMesh表示的网格数据返回为可用的ArrayMesh。
此方法缓存返回的网格,后续调用将返回缓存的数据,直到调用clear()。
如果尚未缓存并且提供了base_mesh,则将使用base_mesh并进行变异。
Array get_surface_arrays(surface_idx: int) const 🔗
返回构成请求曲面的顶点、法线、UV等的数组。参见add_surface()。
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 🔗
返回网格在给定表面上的lod数。
PackedInt32Array get_surface_lod_indices(surface_idx: int, lod_idx: int) const 🔗
返回曲面的lod的索引缓冲区。
float get_surface_lod_size(surface_idx: int, lod_idx: int) const 🔗
返回激活表面lod的屏幕比例。
Material get_surface_material(surface_idx: int) const 🔗
返回给定表面中的Material。使用此材质渲染表面。
String get_surface_name(surface_idx: int) const 🔗
获取分配给此曲面的名称。
PrimitiveType get_surface_primitive_type(surface_idx: int) 🔗
返回请求表面的基本类型(参见add_surface())。
void set_blend_shape_mode(mode: BlendShapeMode) 🔗
将混合形状模式设置为BlendShapeMode之一。
void set_lightmap_size_hint(size: Vector2i) 🔗
为UV空间中的光照贴图展开设置此网格的大小提示。
void set_surface_material(surface_idx: int, material: Material) 🔗
为给定表面设置Material。表面将使用此材质渲染。
void set_surface_name(surface_idx: int, name: String) 🔗
设置给定曲面的名称。