ULRE/inc/hgl/graph/SceneNode.h

94 lines
4.4 KiB
C
Raw Normal View History

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>
#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; ///<绑定盒
AABB LocalBoundingBox; ///<本地坐标绑定盒
AABB WorldBoundingBox; ///<世界坐标绑定盒
2019-05-21 21:28:33 +08:00
Vector4f Center; ///<中心点
Vector4f LocalCenter; ///<本地坐标中心点
Vector4f WorldCenter; ///<世界坐标中心点
RenderableInstance *render_obj=nullptr; ///<可渲染实例
2019-05-21 21:28:33 +08:00
public:
ObjectList<SceneNode> SubNode; ///<子节点
2019-05-21 21:28:33 +08:00
public:
2021-05-31 19:10:17 +08:00
SceneNode()=default;
2021-06-10 18:56:23 +08:00
SceneNode( RenderableInstance *ri ) {render_obj=ri;}
SceneNode(const Matrix4f &mat ):SceneOrient(mat) {}
SceneNode(const Matrix4f &mat, RenderableInstance *ri ):SceneOrient(mat) {render_obj=ri;}
2019-05-21 21:28:33 +08:00
virtual ~SceneNode()=default;
2021-06-10 18:56:23 +08:00
void Clear()
{
2021-06-10 18:56:23 +08:00
SubNode.ClearData();
render_obj=nullptr;
}
RenderableInstance *GetRI(){return render_obj;}
void SetRI(RenderableInstance *);
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;
}
SceneNode *CreateSubNode(const Matrix4f &mat,RenderableInstance *ri)
{
SceneNode *sn=new SceneNode(mat,ri);
SubNode.Add(sn);
return sn;
}
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;} ///<取得绑定盒
virtual const AABB & GetLocalBoundingBox ()const{return LocalBoundingBox;} ///<取得本地坐标绑定盒
virtual const AABB & GetWorldBoundingBox ()const{return WorldBoundingBox;} ///<取得世界坐标绑定盒
2019-05-21 21:28:33 +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