跳转至

ArrayMesh

继承

Mesh

简要描述

Mesh类型,提供了从数组构造surface的接口。

描述

ArrayMesh用于通过将属性指定为数组来构造Mesh

最基本的示例是创建单个三角形:

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

MeshInstance准备添加到SceneTree中显示。

成员

类型 属性名 默认值
int blend_shape_mode 1
AABB custom_aabb AABB( 0, 0, 0, 0, 0, 0 )

方法

返回值类型 方法名称
void add_blend_shape(name: String)
void add_surface_from_arrays(primitive: int, arrays: Array, blend_shapes: Array = [], compress_flags: int = 97280)
void clear_blend_shapes()
int get_blend_shape_count() const
String get_blend_shape_name(index: int) const
int lightmap_unwrap(transform: Transform, texel_size: float)
void regen_normalmaps()
int surface_find_by_name(name: String) const
int surface_get_array_index_len(surf_idx: int) const
int surface_get_array_len(surf_idx: int) const
int surface_get_format(surf_idx: int) const
String surface_get_name(surf_idx: int) const
int surface_get_primitive_type(surf_idx: int) const
void surface_remove(surf_idx: int)
void surface_set_name(surf_idx: int, name: String)
void surface_update_region(surf_idx: int, offset: int, data: PoolByteArray)
##枚举
enum ArrayType:
- ARRAY_VERTEX = 0

顶点位置的PoolVector3ArrayPoolVector2ArrayArray

  • ARRAY_NORMAL = 1

顶点法线的PoolVector3Array

  • ARRAY_TANGENT = 2

顶点切线的PoolRealArray

  • ARRAY_COLOR = 3

顶点颜色的PoolColorArray

  • ARRAY_TEX_UV = 4

PoolVector2Array用于UV坐标。

  • ARRAY_TEX_UV2 = 5

PoolVector2Array用于第二个UV坐标。

  • ARRAY_BONES = 6

骨骼索引的PoolRealArrayPoolIntArray

  • ARRAY_WEIGHTS = 7

骨骼权重的PoolRealArray

  • ARRAY_INDEX = 8

整数PoolIntArray用作引用顶点,颜色,法线,切线和纹理的索引。

对于三角形,索引数组被解释为三元组,指的是每个三角形的顶点。

  • ARRAY_MAX = 9

表示ArrayType枚举的大小。


enum ArrayFormat: - ARRAY_FORMAT_VERTEX = 1

数组格式将包括顶点(强制性)。

  • ARRAY_FORMAT_NORMAL = 2

数组格式将包括法线。

  • ARRAY_FORMAT_TANGENT = 4

数组格式将包含切线。

  • ARRAY_FORMAT_COLOR = 8

阵列格式将包括颜色阵列。

  • ARRAY_FORMAT_TEX_UV = 16

数组格式将包括UV。

  • ARRAY_FORMAT_TEX_UV2 = 32

数组格式将包括另一组UV。

  • ARRAY_FORMAT_BONES = 64

数组格式将包括骨骼索引。

  • ARRAY_FORMAT_WEIGHTS = 128

数组格式将包括骨骼权重。

  • ARRAY_FORMAT_INDEX = 256

将使用索引数组。


常量

  • NO_INDEX_ARRAY = -1

不存在索引时用于index_array_len的默认值。

  • ARRAY_WEIGHTS_SIZE = 4

每个顶点的权重/骨骼索引的数量(总是4)。

成员说明

  • int blend_shape_mode
Default 1
setter set_blend_shape_mode(value)
getter get_blend_shape_mode
  • AABB custom_aabb
Default AABB( 0, 0, 0, 0, 0, 0 )
setter set_custom_aabb(value)
getter get_custom_aabb

方法说明

  • add_blend_shape add_blend_shape(name: String)

add_surface_from_arrays添加的blend_shape添加名称。


  • add_surface_from_arrays add_surface_from_arrays(primitive: int, arrays: Array, blend_shapes: Array = [], compress_flags: int = 97280)

创建一个新surface。

创建surface以使用primitive进行渲染,该surface可以是Mesh.PrimitiveType中定义的任何类型。

arrays参数是一个数组。

添加索引数组会使此函数进入“索引模式”,在该模式下,顶点和其他数组成为数据源,并且索引数组定义了顶点的顺序。

IdeaVR对三角形基本模式的正面使用顺时针缠绕顺序。


  • clear_blend_shapes clear_blend_shapes()

从此ArrayMesh中删除所有blend_shapes。


  • get_blend_shape_count get_blend_shape_count() const

返回ArrayMesh保留的blend_shapes的数量。


  • get_blend_shape_name get_blend_shape_name(index: int) const

返回此索引处的blend_shapes的名称。


  • lightmap_unwrap lightmap_unwrap(transform: Transform, texel_size: float)

将在ArrayMesh上执行UV展开,以准备用于光照贴图的网格。


  • regen_normalmaps regen_normalmaps()

将为ArrayMesh重新生成法线贴图。


  • surface_find_by_name surface_find_by_name(name: String) const

返回具有此名称的第一个surface的索引,该名称保留在此ArrayMesh中。


  • surface_get_array_index_len surface_get_array_index_len(surf_idx: int) const

返回所请求表面中索引数组的索引长度(请参见add_surface_from_arrays)。


  • surface_get_array_len surface_get_array_len(surf_idx: int) const

返回所请求surface中顶点数组的顶点长度(请参见add_surface_from_arrays)。


  • surface_get_format surface_get_format(surf_idx: int) const

返回所请求surface的格式掩码(请参见add_surface_from_arrays)。


  • surface_get_name surface_get_name(surf_idx: int) const

获取分配给此surface的名称。


  • surface_get_primitive_type surface_get_primitive_type(surf_idx: int) const

返回所请求surface的基本类型(请参见add_surface_from_arrays)。


  • surface_remove surface_remove(surf_idx: int)

移除位置surf_idx处的surface,向下移动一个surf_idx插槽较大的表面。


  • surface_set_name surface_set_name(surf_idx: int, name: String)

设置给定surface的名称。


  • surface_update_region surface_update_region(surf_idx: int, offset: int, data: PoolByteArray)

更新GPU上网格阵列的指定区域。

**警告:**仅在知道自己在做什么时使用。