目录

Transform

Class Info

class Transform : public IComponent

坐标转换类,主要提供不同坐标系下向量平移、旋转和缩放功能,以及不同坐标间的转换矩阵。

Public Constructor Summary

Constructor Name

Transform(SceneObject* sceneObject= nullptr)

构造函数。

Public Destructor Summary

Destructor Name

virtual ~Transform()

析构函数。

Public Method Summary

Qualifier and Type

Method Name and Description

void

Translate(const Vector3& translate)

局部坐标系下的平移变换。

void

Rotate(f32 angle, const Vector3& axis)

局部坐标系下的旋转变换,绕旋转轴axis旋转angle弧度。

void

Scale(const Vector3& scale)

局部坐标系下的缩放变换。

void

SetLocalPosition(const Vector3& position)

设置局部坐标系下,当前场景对象相对于父场景对象的位置。

void

SetLocalRotation(const Vector3& rotation)

设置当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。

void

SetLocalScale(const Vector3& scale)

设置当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。

void

SetWorldPosition(const Vector3& position)

设置当前场景对象在世界坐标系下的绝对位置。

void

SetWorldRotation(const Vector3& rotation)

设置当前场景对象在世界坐标系下的旋转向量。

void

SetWorldScale(const Vector3& scale)

设置当前场景对象在世界坐标系下的缩放向量。

const

Vector3&

GetLocalPosition() const

获取局部坐标系下当前场景对象相对于父场景对象的位置。

const

Vector3&

GetLocalRotation() const

获取当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。

const

Vector3&

GetLocalScale() const

获取当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。

const

Vector3&

GetWorldPosition() const

获取当前场景对象在世界坐标系下的绝对位置。

const

Vector3&

GetWorldRotation() const

获取当前场景对象在世界坐标系下的旋转向量。

const

Vector3&

GetWorldScale() const

获取当前场景对象在世界坐标系下的缩放向量。

const

Matrix4&

GetLocalToWorldMatrix() const

获取局部坐标转换为世界坐标的转换矩阵。

bool

IsTransChanged() const

判断是否发生了平移变换。

void

ClearTransFlags()

清空坐标变换标志位。

Public Constructors

[h2]Transform

Constructor

Transform(SceneObject* sceneObject= nullptr)

构造函数。

Parameters

Name

Description

sceneObject

指定初始化的场景对象。

Public Destructors

[h2]~Transform

Destructor

virtual ~Transform()

析构函数。

Public Methods

[h2]Translate

Method

void Translate(const Vector3& translate)

局部坐标系下的平移变换。

Parameters

Name

Description

translate

平移向量。

[h2]Rotate

Method

void Rotate(f32 angle, const Vector3& axis)

局部坐标系下的旋转变换,绕旋转轴axis旋转angle弧度。

Parameters

Name

Description

angle

旋转弧度。

axis

旋转轴。

[h2]Scale

Method

void Scale(const Vector3& scale)

局部坐标系下的缩放变换。

Parameters

Name

Description

scale

缩放系数。

[h2]SetLocalPosition

Method

void SetLocalPosition(const Vector3& position)

设置局部坐标系下,当前场景对象相对于父场景对象的位置。

Parameters

Name

Description

position

Vector3类型局部坐标系下待设置的位置。

[h2]SetLocalRotation

Method

void SetLocalRotation(const Vector3& rotation)

设置当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。

Parameters

Name

Description

rotation

Vector3类型局部坐标系下的待设置旋转向量。各分量的值为弧度。

[h2]SetLocalScale

Method

void SetLocalScale(const Vector3& scale)

设置当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。

Parameters

Name

Description

scale

Vector3类型局部坐标系下的待设置缩放向量。各分量的值为弧度。

[h2]SetWorldPosition

Method

void SetWorldPosition(const Vector3& position)

设置当前场景对象在世界坐标系下的绝对位置。

Parameters

Name

Description

position

Vector3类型给定世界坐标系下的位置。

[h2]SetWorldRotation

Method

void SetWorldRotation(const Vector3& rotation)

设置当前场景对象在世界坐标系下的旋转向量。

Parameters

Name

Description

rotation

Vector3类型给定世界坐标系下的旋转向量。各分量的值为弧度。

[h2]SetWorldScale

Method

void SetWorldScale(const Vector3& scale)

设置当前场景对象在世界坐标系下的缩放向量。

Parameters

Name

Description

scale

Vector3类型给定世界坐标系下的缩放向量。

[h2]GetLocalPosition

Method

const Vector3& GetLocalPosition() const

获取局部坐标系下当前场景对象相对于父场景对象的位置。

Returns

Type

Description

const Vector3&

返回局部坐标系下当前场景对象相对于父场景对象的位置。

[h2]GetLocalRotation

Method

const Vector3& GetLocalRotation() const

获取当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。返回值各分量的值为弧度。

Returns

Type

Description

const Vector3&

返回当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。各分量的值为弧度。

[h2]GetLocalScale

Method

const Vector3& GetLocalScale() const

获取当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。

Returns

Type

Description

const Vector3&

返回当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。

[h2]GetWorldPosition

Method

const Vector3& GetWorldPosition() const

获取当前场景对象在世界坐标系下的绝对位置。

Returns

Type

Description

const Vector3&

返回当前场景对象在世界坐标系下的绝对位置。

[h2]GetWorldRotation

Method

const Vector3& GetWorldRotation() const

获取当前场景对象在世界坐标系下的旋转向量。返回值各分量的值为弧度。

Returns

Type

Description

const Vector3&

返回当前场景对象在世界坐标系下的旋转向量。各分量的值为弧度。

[h2]GetWorldScale

Method

const Vector3& GetWorldScale() const

获取当前场景对象在世界坐标系下的缩放向量。

Returns

Type

Description

const Vector3&

返回当前场景对象在世界坐标系下的缩放向量。

[h2]GetLocalToWorldMatrix

Method

const Matrix4& GetLocalToWorldMatrix() const

获取局部坐标转换为世界坐标的转换矩阵。

Returns

Type

Description

const Matrix4&

局部坐标转换为世界坐标的转换矩阵。

[h2]IsTransChanged

Method

bool IsTransChanged() const

判断是否进行了平移变换。

Returns

Type

Description

bool

  • true:进行平移变换。
  • false:未进行平移变换。

[h2]ClearTransFlags

Method

void ClearTransFlags()

清空坐标变换标志位。