2019-05-21 21:28:33 +08:00
|
|
|
|
#ifndef HGL_GRAPH_SCENE_NODE_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_SCENE_NODE_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include<hgl/type/List.h>
|
|
|
|
|
#include<hgl/graph/SceneOrient.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2019-05-21 21:28:33 +08:00
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 场景节点数据类<br>
|
2021-04-30 18:56:20 +08:00
|
|
|
|
* 从场景坐标变换(SceneOrient)类继承,
|
|
|
|
|
* 每个场景节点中可能包括一个可渲染数据实例,或是完全不包含(用于坐标变换的父节点,或是灯光/摄像机之类)。
|
2019-05-21 21:28:33 +08:00
|
|
|
|
*/
|
|
|
|
|
class SceneNode:public SceneOrient ///场景节点类
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
AABB BoundingBox; ///<绑定盒
|
2019-05-25 14:52:24 +08:00
|
|
|
|
AABB LocalBoundingBox; ///<本地坐标绑定盒
|
|
|
|
|
AABB WorldBoundingBox; ///<世界坐标绑定盒
|
2019-05-21 21:28:33 +08:00
|
|
|
|
|
2020-11-17 14:35:39 +08:00
|
|
|
|
Vector4f Center; ///<中心点
|
|
|
|
|
Vector4f LocalCenter; ///<本地坐标中心点
|
|
|
|
|
Vector4f WorldCenter; ///<世界坐标中心点
|
2019-05-21 21:28:33 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
ObjectList<SceneNode> SubNode; ///<子节点
|
|
|
|
|
|
2021-02-07 18:38:52 +08:00
|
|
|
|
RenderableInstance *renderable_instances; ///<可渲染实例
|
2019-05-27 16:54:08 +08:00
|
|
|
|
|
2019-05-21 21:28:33 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2021-02-07 18:38:52 +08:00
|
|
|
|
SceneNode()
|
|
|
|
|
{
|
|
|
|
|
renderable_instances=nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SceneNode(const Matrix4f &mat,RenderableInstance *ri=nullptr)
|
2019-05-28 22:03:55 +08:00
|
|
|
|
{
|
|
|
|
|
SetLocalMatrix(mat);
|
2021-02-07 18:38:52 +08:00
|
|
|
|
renderable_instances=ri;
|
2019-05-28 22:03:55 +08:00
|
|
|
|
}
|
2019-06-12 16:13:35 +08:00
|
|
|
|
|
2019-05-21 21:28:33 +08:00
|
|
|
|
virtual ~SceneNode()
|
|
|
|
|
{
|
|
|
|
|
ClearSubNode();
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 22:03:55 +08:00
|
|
|
|
SceneNode *CreateSubNode()
|
|
|
|
|
{
|
|
|
|
|
SceneNode *sn=new SceneNode();
|
|
|
|
|
|
|
|
|
|
SubNode.Add(sn);
|
|
|
|
|
return sn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SceneNode *CreateSubNode(const Matrix4f &mat)
|
|
|
|
|
{
|
|
|
|
|
SceneNode *sn=new SceneNode(mat);
|
|
|
|
|
|
|
|
|
|
SubNode.Add(sn);
|
|
|
|
|
return sn;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-07 18:38:52 +08:00
|
|
|
|
void AddSubNode(SceneNode *n){if(n)SubNode.Add(n);} ///<增加一个子节点
|
2019-05-27 16:54:08 +08:00
|
|
|
|
void ClearSubNode(){SubNode.ClearData();} ///<清除子节点
|
2019-05-21 21:28:33 +08:00
|
|
|
|
|
2021-02-07 18:38:52 +08:00
|
|
|
|
void Set(RenderableInstance *ri){renderable_instances=ri;} ///<增加渲染实例
|
2019-05-28 22:03:55 +08:00
|
|
|
|
|
2021-02-07 18:38:52 +08:00
|
|
|
|
void Set(const Matrix4f &mat,RenderableInstance *ri)
|
2019-05-28 22:03:55 +08:00
|
|
|
|
{
|
2021-02-07 18:38:52 +08:00
|
|
|
|
SetLocalMatrix(mat);
|
2019-05-28 22:03:55 +08:00
|
|
|
|
|
2021-02-07 18:38:52 +08:00
|
|
|
|
renderable_instances=ri;
|
2019-05-28 22:03:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-21 21:28:33 +08:00
|
|
|
|
public: //坐标相关方法
|
|
|
|
|
|
|
|
|
|
virtual void SetBoundingBox (const AABB &bb){BoundingBox=bb;} ///<设置绑定盒
|
|
|
|
|
|
|
|
|
|
virtual void RefreshMatrix (const Matrix4f *mat=nullptr); ///<刷新世界变换矩阵
|
|
|
|
|
virtual void RefreshBoundingBox (); ///<刷新绑定盒
|
|
|
|
|
|
|
|
|
|
virtual const AABB & GetBoundingBox ()const{return BoundingBox;} ///<取得绑定盒
|
2019-05-25 14:52:24 +08:00
|
|
|
|
virtual const AABB & GetLocalBoundingBox ()const{return LocalBoundingBox;} ///<取得本地坐标绑定盒
|
|
|
|
|
virtual const AABB & GetWorldBoundingBox ()const{return WorldBoundingBox;} ///<取得世界坐标绑定盒
|
2019-05-21 21:28:33 +08:00
|
|
|
|
|
2020-11-17 14:35:39 +08:00
|
|
|
|
virtual const Vector4f & GetCenter ()const{return Center;} ///<取得中心点
|
|
|
|
|
virtual const Vector4f & GetLocalCenter ()const{return LocalCenter;} ///<取得本地坐标中心点
|
|
|
|
|
virtual const Vector4f & GetWorldCenter ()const{return WorldCenter;} ///<取得世界坐标中心点
|
2019-05-21 21:28:33 +08:00
|
|
|
|
};//class SceneNode
|
|
|
|
|
}//namespace graph
|
|
|
|
|
}//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_SCENE_NODE_INCLUDE
|