Class Info |
|---|
class SceneObject 场景对象类,主要提供当前场景中组件管理,模型旋转、缩放,场景可见性配置,父场景配置,子场景配置等功能。 |
Constructor Name |
|---|
SceneObject(const SceneManager* sceneManager,SceneObject* parent) 构造函数,若父类场景为空,则调用AddSceneObject函数添加自身作为场景对象,并作为父场景;否则调用SetParent设置父场景,参数为父场景对象指针。 |
Qualifier and Type |
Method Name and Description |
|---|---|
void |
设置当前场景对象的名称。 |
const String& |
GetName() const 获取当前场景对象的名称。 |
void |
设置当前场景对象的排序ID。 |
GetSortId() const 获取当前场景对象的排序ID。 |
|
virtual void |
每帧预更新逻辑,可用于有物理更新逻辑的场景。 |
virtual void |
每帧更新逻辑,主要更新世界矩阵。 |
virtual void |
PostUpdate(f32 deltaTime) 每帧后更新逻辑,可用于具有追随更新逻辑的场景,如相机追随某个对象,要滞后于对象的更新。 |
bool |
RemoveComponent(IComponent* component) 删除指定组件。 |
template <typename T> T* |
模板,向组件列表中添加T类型组件并完成组件的启动。 |
template <typename T> T* |
GetComponent() const 模板,获取组件列表中找到的第一个T类型组件。 |
template <typename T> vector<T*> |
模板,获取所有T类型组件。 |
const SceneObject* |
GetParent() const 获取当前场景的父场景对象常量指针。 |
void |
SetParent(SceneObject* newParent) 移除原有父场景对象,并设置新的父场景对象。 |
bool |
HasParent() const 判断是否存在父场景。 |
bool |
IsParentOf(const SceneObject* object) const 判断当前场景是否为指定场景的父场景。 |
const list<SceneObject*>& |
GetChildren() const 获取子场景对象列表。 |
GetChildrenCount() const 获取子场景对象总数。 |
|
void |
AddChild(SceneObject* child) 添加子场景对象。 |
bool |
RemoveChild(SceneObject* child) 删除指定子场景对象。 |
bool |
IsChildOf(const SceneObject* object) const 判断当前场景对象是否为指定场景对象的子场景。 |
GetID() const 获取当前场景对象ID。 |
|
void |
SetNodeIndex(u32 nodeIndex) 设置当前场景对象的节点索引。 |
GetNodeIndex() const 获取当前场景对象的节点索引。 |
|
void |
SetVisible(bool visible) 设置当前场景对象是否可见。 |
bool |
IsVisible() const 判断当前场景对象是否可见。 |
void |
SetPosition(const Vector3& position) 设置当前场景对象在世界坐标系下的位置。 |
const Vector3& |
GetPosition() const 获取当前场景对象在世界坐标系下的位置。 |
void |
SetScale(const Vector3& scale) 设置当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。 |
const Vector3& |
GetScale() const 获取当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。 |
void |
SetRotation(const Vector3& rotation) 设置当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。 |
const Vector3& |
GetRotation() const 获取当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。 |
const Transform* |
GetTransform() const 获取当前场景对象绑定的坐标转换类接口。 |
const Transform* |
GetParentTransform() const 获取父场景对象绑定的坐标转换类接口。 |
void |
SetLocalPosition(const Vector3& position) 设置局部坐标系下,当前场景对象相对于父场景对象的位置。 |
| 获取网格渲染对象。 |
|
GetLayerType() const 获取场景对象的类型。 |
|
void |
SetLayerType(LayerType layerType) 设置场景对象的类型。 |
const SceneManager* |
GetSceneManager() const 获取SceneManager指针。 |
template <typename T> std::vector<T*> |
递归获取已包含的所有类型T的组件变量。 |
Constructor |
|---|
SceneObject(const SceneManager* sceneManager,SceneObject* parent) 构造函数,若父类场景为空,则调用AddSceneObject函数添加自身作为场景对象,并作为父场景;否则调用SetParent设置父场景。 |
Parameters
Name |
Description |
|---|---|
sceneManager |
SceneManager指针。 |
parent |
父场景对象指针。 |
Method |
|---|
void SetName(const String& name) 设置当前场景对象的名称。 |
Parameters
Name |
Description |
|---|---|
name |
所需设置场景对象的名称。 |
Method |
|---|
const String& GetName() const 获取当前场景对象的名称。 |
Returns
Type |
Description |
|---|---|
const String& |
当前场景对象的名称。 |
Method |
|---|
void SetSortId(u32 id) 设置当前场景对象的排序ID。 |
Parameters
Name |
Description |
|---|---|
id |
所需设置场景对象的排序ID。 |
Method |
|---|
virtual void PreUpdate(f32 deltaTime) 每帧预更新逻辑,可用于有物理更新逻辑的场景。 |
Parameters
Name |
Description |
|---|---|
deltaTime |
帧间隔时间,单位为秒。 |
Method |
|---|
virtual void Update(f32 deltaTime) 每帧更新逻辑,主要更新世界矩阵。 |
Parameters
Name |
Description |
|---|---|
deltaTime |
帧间隔时间,单位为秒。 |
Method |
|---|
virtual void PostUpdate(f32 deltaTime) 每帧后更新逻辑,可用于具有追随更新逻辑的场景,如相机追随某个对象,要滞后于对象的更新。 |
Parameters
Name |
Description |
|---|---|
deltaTime |
帧间隔时间,单位为秒。 |
Method |
|---|
bool RemoveComponent(IComponent* component) 删除指定组件。 |
Parameters
Name |
Description |
|---|---|
component |
IComponent类型待删除的组件指针。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
template <typename T> T* AddComponent() 模板,向组件列表中添加T类型组件并完成组件的启动。 |
Returns
Type |
Description |
|---|---|
template <typename T> T* |
指向T类型组件的指针。 |
Method |
|---|
template <typename T> T* GetComponent() const 模板,获取组件列表中找到的第一个T类型组件。 |
Returns
Type |
Description |
|---|---|
template <typename T> T* |
指向组件列表中第一个T类型组件的指针。 |
Method |
|---|
template <typename T> vector<T*> GetComponents() 模板,获取所有T类型组件。 |
Returns
Type |
Description |
|---|---|
template <typename T> vector<T*> |
T类型组件列表。 |
Method |
|---|
const SceneObject* GetParent() const 获取当前场景的父场景对象常量指针。 |
Returns
Type |
Description |
|---|---|
const SceneObject* |
当前场景的父场景对象常量指针。 |
Method |
|---|
void SetParent(SceneObject* newParent) 移除原有父场景对象,并设置新的父场景对象。 |
Parameters
Name |
Description |
|---|---|
newParent |
SceneObject类型父场景指针。 |
Method |
|---|
bool HasParent() const 判断是否存在父场景。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
bool IsParentOf(const SceneObject* object) const 判断当前场景是否为指定场景的父场景。 |
Parameters
Name |
Description |
|---|---|
object |
SceneObject类型指向指定场景对象的指针。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
const list<SceneObject*>& GetChildren() const 获取子场景对象列表。 |
Returns
Type |
Description |
|---|---|
const list<SceneObject*>& |
返回子场景对象列表。 |
Method |
|---|
u32 GetChildrenCount() const 获取子场景对象总数。 |
Returns
Type |
Description |
|---|---|
返回子场景对象总数。 |
Method |
|---|
void AddChild(SceneObject* child) 添加子场景对象。 |
Parameters
Name |
Description |
|---|---|
child |
SceneObject类型指向待添加子场景对象的指针。 |
Method |
|---|
bool RemoveChild(SceneObject* child) 删除指定子场景对象。 |
Parameters
Name |
Description |
|---|---|
child |
SceneObject类型待删除的子场景对象指针。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
bool IsChildOf(const SceneObject* object) const 判断当前场景对象是否为指定场景对象的子场景。 |
Parameters
Name |
Description |
|---|---|
object |
指向指定场景对象的指针。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
void SetNodeIndex(u32 nodeIndex) 设置当前场景对象的节点索引。 |
Parameters
Name |
Description |
|---|---|
nodeIndex |
所需设置场景对象的节点索引。 |
Method |
|---|
u32 GetNodeIndex() const 获取当前场景对象的节点索引。 |
Returns
Type |
Description |
|---|---|
当前场景对象的节点索引。 |
Method |
|---|
void SetVisible(bool visible) 设置当前场景对象是否可见。 |
Parameters
Name |
Description |
|---|---|
visible |
表示是否可见的布尔类型标志变量。
|
Method |
|---|
bool IsVisible() const 判断当前场景对象是否可见。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
void SetPosition(const Vector3& position) 设置当前场景对象在世界坐标系下的位置。 |
Parameters
Name |
Description |
|---|---|
position |
Vector3类型位置的引用。 |
Method |
|---|
void SetScale(const Vector3& scale) 设置当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。 |
Parameters
Name |
Description |
|---|---|
scale |
Vector3类型缩放向量。 |
Method |
|---|
const Vector3& GetScale() const 获取当前场景对象在局部坐标系下的缩放向量(相对于父场景对象)。 |
Returns
Type |
Description |
|---|---|
const Vector3& |
场景对象在局部坐标下的缩放向量。 |
Method |
|---|
void SetRotation(const Vector3& rotation) 设置当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。 |
Parameters
Name |
Description |
|---|---|
rotation |
Vector3类型旋转向量,各个分量为弧度。 |
Method |
|---|
const Vector3& GetRotation() const 获取当前场景对象在局部坐标系下的旋转向量(相对于父场景对象)。 |
Returns
Type |
Description |
|---|---|
const Vector3& |
场景对象在局部坐标下的旋转向量,各分量的值为弧度。 |
Method |
|---|
const Transform* GetTransform() const 获取当前场景对象绑定的坐标转换类接口。 |
Returns
Type |
Description |
|---|---|
const Transform* |
指向当前场景对象绑定的坐标转换类接口的指针。 |
Method |
|---|
const Transform* GetParentTransform() const 获取父场景对象绑定的坐标转换类接口。 |
Returns
Type |
Description |
|---|---|
const Transform* |
|
Method |
|---|
void Scale(const Vector3& scale) 局部坐标系下的缩放变换。 |
Parameters
Name |
Description |
|---|---|
scale |
缩放系数。 |
Method |
|---|
void SetLocalPosition(const Vector3& position) 设置局部坐标系下,当前场景对象相对于父场景对象的位置。 |
Parameters
Name |
Description |
|---|---|
position |
Vector3类型局部坐标系下待设置的位置。 |
Method |
|---|
MeshRenderer* GetMeshRenderer() 获取网格渲染对象。 |
Returns
Type |
Description |
|---|---|
网格渲染对象。 |
Method |
|---|
const SceneManager* GetSceneManager() const 获取SceneManager指针。 |
Returns
Type |
Description |
|---|---|
返回SceneManager指针。 |