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.
Checking the stable version of the documentation...
ImporterMesh¶
继承: Resource < RefCounted < Object
在导入过程中,包含基于顶点数组的几何体的 Resource。
描述¶
ImporterMesh 是一种类似于 ArrayMesh 的 Resource。它包含基于顶点数组的几何体,被分为表面。每个表面都包含一个完全独立的数组和一个用于绘制它的材质。在设计方面,具有多个表面的网格优于单个表面,因为在 3D 编辑软件中创建的对象通常包含多种材质。
与其运行时对应物不同,ImporterMesh 在各种导入步骤(例如 lod 和阴影网格生成)发生之前包含网格数据。修改表面数据时,通过先调用 clear ,然后为每个表面调用 add_surface。
属性¶
|
方法¶
void |
add_blend_shape ( String name ) |
void |
add_surface ( PrimitiveType primitive, Array arrays, Array[] blend_shapes=[], Dictionary lods={}, Material material=null, String name="", int flags=0 ) |
void |
clear ( ) |
void |
generate_lods ( float normal_merge_angle, float normal_split_angle, Array bone_transform_array ) |
get_blend_shape_count ( ) const |
|
get_blend_shape_mode ( ) const |
|
get_blend_shape_name ( int blend_shape_idx ) const |
|
get_lightmap_size_hint ( ) const |
|
get_surface_arrays ( int surface_idx ) const |
|
get_surface_blend_shape_arrays ( int surface_idx, int blend_shape_idx ) const |
|
get_surface_count ( ) const |
|
get_surface_format ( int surface_idx ) const |
|
get_surface_lod_count ( int surface_idx ) const |
|
get_surface_lod_indices ( int surface_idx, int lod_idx ) const |
|
get_surface_lod_size ( int surface_idx, int lod_idx ) const |
|
get_surface_material ( int surface_idx ) const |
|
get_surface_name ( int surface_idx ) const |
|
get_surface_primitive_type ( int surface_idx ) |
|
void |
set_blend_shape_mode ( BlendShapeMode mode ) |
void |
set_lightmap_size_hint ( Vector2i size ) |
void |
set_surface_material ( int surface_idx, Material material ) |
void |
set_surface_name ( int surface_idx, String name ) |
属性说明¶
Dictionary _data = { "surfaces": [] }
目前没有这个属性的描述。请帮我们贡献一个!
方法说明¶
void add_blend_shape ( String name )
为将使用 add_surface 添加的混合形状添加名称。必须在表面被添加之前调用。
void add_surface ( PrimitiveType primitive, Array arrays, Array[] blend_shapes=[], Dictionary lods={}, Material material=null, String name="", int flags=0 )
创建一个新的表面。Mesh.get_surface_count 将成为这个新表面的 surf_idx
。
创建表面以使用 primitive
进行渲染,它可以是 PrimitiveType 中定义的任何值。
arrays
参数是数组的数组。每个 Mesh.ARRAY_MAX 元素都包含一个数组,其中包含此表面的一些网格数据,如 ArrayType 的相应成员所描述的一样;如果它未被使用,则为 null
。例如,arrays[0]
是顶点数组。始终需要第一个顶点子数组;其他的是可选的。添加索引数组会将此表面置于“索引模式”,其中顶点和其他数组成为数据源,索引数组定义顶点顺序。所有子数组的长度必须与顶点数组的长度相同(或者是顶点数组长度的精确倍数,当子数组的多个元素对应于单个顶点时);或者为空,如果使用了 Mesh.ARRAY_INDEX 则除外。
blend_shapes
参数是每个混合形状的顶点数据数组。 每个元素都是与 arrays
具有相同结构的数组,但是 Mesh.ARRAY_VERTEX、Mesh.ARRAY_NORMAL 和 Mesh.ARRAY_TANGENT 这些条目,当且仅当在 arrays
被设置且所有其他条目都是 null
时,会被设置。
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 ( float normal_merge_angle, float normal_split_angle, Array bone_transform_array )
为这个 ImporterMesh 生成所有 lod。
normal_merge_angle
和 normal_split_angle
以度为单位,并以与 lods
中的导入器设置相同的方式使用。作为一个好的默认值,分别使用 25 和 60。
生成的 LOD 的数量可以使用 get_surface_lod_count 访问,并且每个 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 ( int blend_shape_idx ) const
返回此索引处的混合形状的名称。
Vector2i get_lightmap_size_hint ( ) const
返回该网格的大小提示,用于在 UV 空间中展开光照贴图。
ArrayMesh get_mesh ( ArrayMesh base_mesh=null )
将该 ImporterMesh 表示的网格数据作为一个可用的 ArrayMesh 返回。
这个方法缓存了返回的网格,后续的调用将返回缓存的数据,直到 clear 被调用。
如果还没有缓存并且提供了 base_mesh
,则 base_mesh
将被使用并被改变。
Array get_surface_arrays ( int surface_idx ) const
返回构成请求表面的顶点、法线、UV 等的数组。参见 add_surface。
Array get_surface_blend_shape_arrays ( int surface_idx, int blend_shape_idx ) const
为一个表面请求的混合形状索引,返回一组混合形状数组。
int get_surface_count ( ) const
返回该网格拥有的表面数。
int get_surface_format ( int surface_idx ) const
返回该网格拥有的表面的格式。
int get_surface_lod_count ( int surface_idx ) const
返回该网格在给定表面上保留的 lod 数。
PackedInt32Array get_surface_lod_indices ( int surface_idx, int lod_idx ) const
返回表面的 lod 的索引缓冲区。
float get_surface_lod_size ( int surface_idx, int lod_idx ) const
返回为一个表面激活 lod 的屏幕比率。
Material get_surface_material ( int surface_idx ) const
返回给定面的 Material 材质。面将由该材质来渲染。
String get_surface_name ( int surface_idx ) const
获取分配给此表面的名称。
PrimitiveType get_surface_primitive_type ( int surface_idx )
返回所请求表面的基元类型(参见 add_surface)。
void set_blend_shape_mode ( BlendShapeMode mode )
将混合形状模式设置为 BlendShapeMode 之一。
void set_lightmap_size_hint ( Vector2i size )
设置该网格的大小提示,以便在 UV 空间中展开光照贴图。
void set_surface_material ( int surface_idx, Material material )
设置给定面的 Material 材质。该面将会使用此材质渲染。
void set_surface_name ( int surface_idx, String name )
设置给定曲面的名称。