目录

Mesh

Class Info

class Mesh

网格类,主要提供子网格的添加、删除、查询和网格包围盒的获取等功能。

Public Field Summary

Qualifier and Type

Field and Description

vector<SubMesh*>

m_subMeshes

子网格列表。

注意:

该接口已废弃。

Public Constructor Summary

Constructor Name

Mesh(const GraphicsRenderer* graphicsRenderer)

构造函数。

Public Destructor Summary

Destructor Name

~Mesh()

析构函数。

Public Method Summary

Qualifier and Type

Method Name and Description

SubMesh*

AddSubMesh()

添加子网格。

const SubMesh*

GetSubMesh(u32 index) const

获取指定索引的子网格。

u32

GetSubMeshCount() const

获取子网格总数。

void

RemoveSubMesh(u32 index)

删除指定子网格。

bool

HasSubMesh(u32 index) const

判断是否存在指定索引的子网格。

void

CreateVertexDeclaration(VertexLayout layout)

根据参数生成顶点声明。

注意:

该接口已废弃,请使用UpdateVertexDeclaration接口替代。

bool

CreateVertexBuffer(const void* buffer, u64 count, u64 stride)

根据参数生成顶点数据缓存。

注意:

该接口已废弃,请使用FillVertexData接口替代。

bool

CreateIndexBuffer(const void* buffer, u64 count, u64 stride)

根据参数生成顶点数据的索引缓存。

注意:

该接口已废弃,请使用FillIndexData接口替代。

u32

GetTriangleCount() const

获取所有子网格中三角形总数。

const AABB&

GetAABB()

获取当前网格的包围盒。

bool

Resume()

应用程序从后台切到前台时,完成网格资源的重建。

注意:

该接口已废弃。

void

Pause()

应用程序从前台切到后台时,完成网格资源的销毁。

注意:

该接口已废弃。

void

SetMaterialInstance(u32 index, MaterialInstance* materialInstance) const

设置指定索引子网格中的材质实例指针。

注意:

该接口已废弃。

const MaterialInstance*

GetMaterialInstance(u32 index) const

获取指定索引子网格中的材质实例指针。

注意:

该接口已废弃。

void

AddVertex(const T* data, u32 count)

向顶点缓存添加类型为T的顶点数据。

注意:

该接口已废弃,请使用FillVertexData接口替代。

void

ReserveVertexCount(u32 count)

为顶点缓存预申请count个字节的空间。

注意:

该接口已废弃。

u64

GetVertexSize() const

获取实际顶点数据缓存的字节大小。

注意:

该接口已废弃。

void

AddIndex(const T* data, u32 count)

向索引缓存添加数据类型为T的索引数据。

注意:

该接口已废弃,请使用FillIndexData接口替代。

void

ReserveIndexCount(u32 count)

为索引缓存预申请count个字节的空间。

注意:

该接口已废弃。

u64

GetIndexSize() const

获取实际索引缓存的字节大小。

注意:

该接口已废弃。

void

Clear()

清空顶点缓存和索引缓存。

注意:

该接口已废弃。

template<typename T> bool

FillVertexData(const T* data, u64 count, const String& name)

填充顶点数据。

void

SetVertexCount(u64 count)

设置顶点的总数。

u64

GetVertexCount() const

获取顶点的总数。

template<typename T> bool

FillIndexData(const T* data, u64 count)

填充索引数据。

void

SetIndexCount(u64 count)

设置索引的总数。

u64

GetIndexCount() const

获取索引的总数。

void

SetIndexStride(u32 stride)

设置索引的步长。

u32

GetIndexStride() const

获取索引的步长。

void

UpdateVertexDeclaration(const std::vector<VertexAttribute>& vertexAttributes)

通过参数vertexAttributes更新顶点声明。

bool

Update()

更新顶点和索引的缓存。

注意:

该接口已废弃。

bool

IsEmpty() const

如果顶点缓存中的数据为空则返回true。否则返回false。

注意:

该接口已废弃。

Public Constructors

[h2]Mesh

Constructor

Mesh(const GraphicsRenderer* graphicsRenderer)

构造函数。

Parameters

Name

Description

graphicsRenderer

GraphicsRenderer指针,可以从BaseApplication中获取。

Public Destructors

[h2]~Mesh

Destructor

~Mesh()

析构函数。

Public Methods

[h2]AddSubMesh

Method

SubMesh* AddSubMesh()

添加子网格。

Returns

Type

Description

SubMesh*

指向新添加子网格的指针。

[h2]GetSubMesh

Method

SubMesh* GetSubMesh(u32 index) const

获取指定索引的子网格。

Parameters

Name

Description

index

指定的子网格索引。

Returns

Type

Description

SubMesh*

返回子网格指针。

[h2]GetSubMeshCount

Method

u32 GetSubMeshCount() const

获取子网格总数。

Returns

Type

Description

u32

返回子网格总数。

[h2]RemoveSubMesh

Method

void RemoveSubMesh(u32 index)

删除指定子网格。

Parameters

Name

Description

index

指定删除的子网格索引。

[h2]HasSubMesh

Method

bool HasSubMesh(u32 index) const

判断是否存在指定索引的子网格。

Parameters

Name

Description

index

指定的子网格索引。

Returns

Type

Description

bool

  • true:存在。
  • false:不存在。

[h2]CreateVertexDeclaration

该接口已废弃,由UpdateVertexDeclaration接口替代。

Method

void CreateVertexDeclaration(VertexLayout layout)

根据参数layout中的枚举,生成对应的顶点声明。

Parameters

Name

Description

layout

VertexLayout枚举,指定顶点声明的方式。

[h2]CreateVertexBuffer

该接口已废弃,请使用FillVertexData接口替代。

Method

bool CreateVertexBuffer(const void* buffer, u64 count, u64 stride)

根据参数生成顶点数据缓存。

Parameters

Name

Description

buffer

存放顶点数据的缓存,一般为c8*或u8*类型。

count

buffer缓存中的顶点个数。

stride

一个顶点数据的步长。

Returns

Type

Description

bool

  • true:生成成功。
  • false:生成不成功。

[h2]CreateIndexBuffer

该接口已废弃,请使用FillIndexData接口替代。

Method

bool CreateIndexBuffer(const void* buffer, u64 count, u64 stride)

根据参数生成顶点数据的索引缓存。

Parameters

Name

Description

buffer

存放顶点数据索引的缓存,一般为c8*或u8*类型。

count

buffer缓存中的索引个数。

stride

索引数据类型的字节数。

Returns

Type

Description

bool

  • true:生成成功。
  • false:生成不成功。

[h2]GetTriangleCount

Method

u32 GetTriangleCount() const

获取所有子网格中三角形总数。

Returns

Type

Description

u32

返回子网格中三角形总数。

[h2]GetAABB

Method

const AABB& GetAABB()

获取当前网格的包围盒。

Returns

Type

Description

const AABB&

返回对当前网格的包围盒的引用。

[h2]Resume

该接口已废弃。

Method

bool Resume()

应用程序从后台切到前台时,完成网格资源的重建。

Returns

Type

Description

bool

  • true:资源重建成功。
  • false:资源重建失败。

[h2]Pause

该接口已废弃。

Method

void Pause()

应用程序从前台切到后台时,完成网格资源的销毁。

[h2]SetMaterialInstance

该接口已废弃。

Method

void SetMaterialInstance(u32 index, MaterialInstance* materialInstance) const

设置指定索引子网格中的材质实例指针。

Parameters

Name

Description

index

指定的子网格索引。

materialInstance

材质实例的指针。

[h2]GetMaterialInstance

该接口已废弃。

Method

const MaterialInstance* GetMaterialInstance(u32 index) const

获取指定索引子网格中的材质实例指针。

Parameters

Name

Description

index

指定的子网格索引。

Returns

Type

Description

MaterialInstance*

获取指定索引的子网格中的材质实例指针。

[h2]AddVertex

该接口已废弃,请使用FillIndexData接口替代。

Method

void AddVertex(const T* data, u32 count)

向顶点缓存添加类型为T的顶点数据。

Parameters

Name

Description

data

顶点数据缓存。

count

顶点的个数。

[h2]ReserveVertexCount

该接口已废弃。

Method

void ReserveVertexCount(u32 count)

为顶点缓存预申请count个字节的空间。

Parameters

Name

Description

count

需要预申请的字节大小。

[h2]GetVertexSize

该接口已废弃。

Method

u64 GetVertexSize() const

获取顶点缓存的字节大小。

Returns

Type

Description

u64

顶点缓存的大小。

[h2]AddIndex

该接口已废弃,请使用FillIndexData接口替代。

Method

void AddIndex(const T* data, u32 count)

向索引缓存添加数据类型为T的索引数据。

Parameters

Name

Description

data

索引数据缓存。

count

索引数据的个数。

[h2]ReserveIndexCount

该接口已废弃。

Method

void ReserveIndexCount(u32 count)

为索引缓存预申请count个字节的空间。

Parameters

Name

Description

count

需要预申请的字节大小。

[h2]GetIndexSize

该接口已废弃。

Method

u64 GetIndexSize() const

获取实际索引缓存的字节大小。

Returns

Type

Description

u64

索引缓存的大小。

[h2]Clear

该接口已废弃。

Method

void Clear()

清空顶点缓存和索引缓存。

[h2]FillVertexData

Method

template<typename T> bool FillVertexData(const T* data, u64 count, const String& name)

填充顶点数据。

Parameters

Name

Description

data

顶点数据缓存。

count

顶点数据的个数。

name

顶点数据的名字

Returns

Type

Description

bool

  • true:填充成功。
  • false:填充不成功。

[h2]SetVertexCount

Method

void SetVertexCount(u64 count)

设置顶点的总数。

Parameters

Name

Description

count

顶点的总数。

[h2]GetVertexCount

Method

u64 GetVertexCount() const

获取顶点的总数。

Returns

Type

Description

u64

返回顶点的总数。

[h2]FillIndexData

Method

template<typename T> bool FillIndexData(const T* data, u64 count)

填充索引数据。

Parameters

Name

Description

data

索引数据缓存。

count

索引数据的个数。

Returns

Type

Description

bool

  • true:填充成功。
  • false:填充不成功。

[h2]SetIndexCount

Method

void SetIndexCount(u64 count)

设置索引的总数。

Parameters

Name

Description

count

索引的总数。

[h2]GetIndexCount

Method

u64 GetIndexCount() const

获取索引的总数。

Returns

Type

Description

u64

返回索引的总数。

[h2]SetIndexStride

Method

void SetIndexStride(u32 stride)

设置索引的步长。

Parameters

Name

Description

stride

索引的步长。

[h2]GetIndexStride

Method

u32 GetIndexStride() const

获取索引的步长。

Returns

Type

Description

u32

返回索引的步长。

[h2]UpdateVertexDeclaration

Method

void UpdateVertexDeclaration(const std::vector<VertexAttribute>& vertexAttributes)

通过参数vertexAttributes更新顶点声明。

Parameters

Name

Description

vertexAttributes

顶点数据的属性列表。

[h2]Update

该接口已废弃。

Method

void Update()

更新顶点和索引的缓存。

如果没有顶点缓存并需要创建,则创建顶点缓存。如果已有顶点缓存,则更新顶点缓存。如果没有索引缓存且需要创建,则创建索引缓存。如果已有索引缓存,则更新索引缓存。

[h2]IsEmpty

该接口已废弃。

Method

bool IsEmpty() const

如果顶点缓存中的数据为空则返回true。否则返回false。

Returns

Type

Description

bool

如果顶点缓存中的数据为空则返回true。否则返回false。