目录

AABB

Class Info

class AABB

描述网格包围盒的类,包围盒为一个立方体。包括包围盒对象间的赋值、比较,获取包围盒最小、最大坐标、中心点坐标、角坐标等。

Public Constructor Summary

Constructor Name

AABB()

构造函数,初始化包围盒坐标最小值、坐标最大值、指向八个角坐标的指针。

AABB(const AABB& other)

拷贝构造函数。

Public Destructor Summary

Destructor Name

~AABB()

析构函数,释放内存。

Public Method Summary

Qualifier and Type

Method Name and Description

AABB&

operator=(const AABB& other)

重载赋值运算符,使用AABB类对象给当前对象赋值。

bool

operator==(const AABB& other) const

重载==运算符,比较当前对象与指定AABB类对象是否相等,相等返回true,不相等返回false。

bool

operator!=(const AABB& other) const

重载!=运算符,比较当前对象与指定AABB类对象是否不相等,不相等返回true,相等返回false。

Vector3

GetMinDistanceVertex(const Vector3& normal) const

获取AABB包围盒最远离指定方向上的顶点。

Vector3

GetMaxDistanceVertex(const Vector3& normal) const

获取AABB包围盒最靠近指定方向上的顶点。

const Vector3&

GetMinimum() const

获取包围盒的坐标最小值。

const Vector3&

GetMaximum() const

获取包围盒的坐标最大值。

void

SetMinimum(const Vector3& vec)

设置包围盒的坐标最小值。

void

SetMaximum(const Vector3& vec)

设置包围盒的坐标最大值。

const Vector3*

GetCorners() const

获取包围盒八个角的坐标。

Vector3

GetCenter() const

获取包围盒中心点的坐标。

Vector3

GetSize() const

获取包围盒三个维度上的大小。

Vector3

GetHalfSize() const

获取包围盒三个维度上一半的大小。

void

AddInternalPoint(const Vector3& p)

增加包围盒中的点,并根据该点的坐标更新包围盒的坐标最小值和最大值。

void

AddInternalBox(const AABB& b)

增加一个包围盒,根据该包围盒的坐标最小值、最大值,更新当前包围盒的坐标最小值、最大值。

String

ToString() const

包围盒类型转字符串类型,形如“(包围盒最小值,包围盒最大值)”。

bool

Contains(const AABB& other) const

是否包含在包围盒中。

Public Constructors

[h2]AABB

Constructor

AABB()

构造函数,初始化包围盒坐标最小值、坐标最大值、指向八个角坐标的指针。

[h2]AABB(const AABB& other)

Constructor

AABB(const AABB& other)

拷贝构造函数。

Parameters

Name

Description

other

已存的AABB类对象引用。

Public Destructors

[h2]~AABB

Destructor

~AABB()

析构函数,释放内存。

Public Methods

[h2]operator=

Method

AABB& operator=(const AABB& other)

重载赋值运算符,使用AABB类对象给当前对象赋值。

Parameters

Name

Description

other

用于赋值的AABB类对象。

Returns

Type

Description

AABB&

返回赋值后对当前对象的引用。

[h2]operator==

Method

bool operator==(const AABB& other) const

重载==运算符,比较当前对象与指定AABB类对象是否相等,相等返回true,不相等返回false。

Parameters

Name

Description

other

与当前对象进行比较的AABB类对象的引用。

Returns

Type

Description

bool

  • true:相等。
  • false:不相等。

[h2]operator!=

Method

bool operator!=(const AABB& other) const

重载!=运算符,比较当前对象与指定AABB类对象是否不相等,不相等返回true,相等返回false。

Parameters

Name

Description

other

与当前对象进行比较的AABB类对象的引用。

Returns

Type

Description

bool

  • true:不相等。
  • false:相等。

[h2]GetMinDistanceVertex

Method

Vector3 GetMinDistanceVertex(const Vector3& normal) const

获取AABB包围盒最远离指定方向上的顶点。

Parameters

Name

Description

normal

三维的方向向量。

Returns

Type

Description

Vector3

获取AABB包围盒最远离指定方向上的顶点。

[h2]GetMaxDistanceVertex

Method

Vector3 GetMaxDistanceVertex(const Vector3& normal) const

获取AABB包围盒最靠近指定方向上的顶点。

Parameters

Name

Description

normal

三维的方向向量。

Returns

Type

Description

Vector3

获取AABB包围盒最靠近指定方向上的顶点。

[h2]GetMinimum

Method

const Vector3& GetMinimum() const

获取包围盒的坐标最小值。

Returns

Type

Description

const Vector3&

返回包围盒的坐标最小值。

[h2]GetMaximum

Method

const Vector3& GetMaximum() const

获取包围盒的坐标最大值。

Returns

Type

Description

const Vector3&

返回包围盒的坐标最大值。

[h2]SetMinimum

Method

void SetMinimum(const Vector3& vec)

设置包围盒的坐标最小值。

Parameters

Name

Description

vec

三维向量表示的XYZ坐标。

[h2]SetMaximum

Method

void SetMaximum(const Vector3& vec)

设置包围盒的坐标最大值。

Parameters

Name

Description

vec

三维向量表示的XYZ坐标。

[h2]GetCorners

Method

const Vector3* GetCorners() const

获取包围盒八个角坐标。

Returns

Type

Description

const Vector3*

返回指向包围盒八个角坐标的指针。

[h2]GetCenter

Method

Vector3 GetCenter() const

获取包围盒中心点的坐标。

Returns

Type

Description

Vector3

返回包围盒中心点的坐标。

[h2]GetSize

Method

Vector3 GetSize() const

获取包围盒三个维度上的大小。

Returns

Type

Description

Vector3

返回包围盒三个维度上的大小,返回值形如“(宽度,高度,深度)”。

[h2]GetHalfSize

Method

Vector3 GetHalfSize() const

获取包围盒三个维度上一半的大小。

Returns

Type

Description

Vector3

返回包围盒三个维度上一半的大小,返回值形如“(宽度,高度,深度)”。

[h2]AddInternalPoint

Method

void AddInternalPoint(const Vector3& p)

增加包围盒中的点,并根据该点的坐标更新包围盒的坐标最小值和最大值。

Parameters

Name

Description

p

待添加点的三维坐标。

[h2]AddInternalBox

Method

void AddInternalBox(const AABB& b)

增加一个包围盒,根据该包围盒的坐标最小值、最大值,更新当前包围盒的坐标最小值、最大值。

Parameters

Name

Description

b

待添加的包围盒。

[h2]ToString

Method

String ToString() const

包围盒类型转字符串类型,形如“(包围盒最小值,包围盒最大值)”。

Returns

Type

Description

String

返回AABB类型转换成的字符串,返回值形如“(包围盒最小值,包围盒最大值)”。

[h2]Contains

Method

bool Contains(const AABB& other) const

是否包含在包围盒中。

Parameters

Name

Description

other

待判断的物体。

Returns

Type

Description

bool

  • true:在包围盒中。
  • false:不在包围盒中。