ULRE/inc/hgl/graph/SceneNode.h

105 lines
4.6 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
2023-07-28 20:17:46 +08:00
#include<hgl/type/ObjectList.h>
2024-09-06 01:04:28 +08:00
#include<hgl/type/IDName.h>
2019-05-21 21:28:33 +08:00
#include<hgl/graph/SceneOrient.h>
2021-09-24 01:53:44 +08:00
#include<hgl/graph/AABB.h>
2019-05-21 21:28:33 +08:00
namespace hgl
{
namespace graph
{
2024-09-06 01:04:28 +08:00
using SceneNodeID =uint64;
2024-10-06 02:30:59 +08:00
using SceneNodeName =UTF16IDName;
2024-09-06 01:04:28 +08:00
2019-05-21 21:28:33 +08:00
/**
* <br>
2021-04-30 18:56:20 +08:00
* (SceneOrient)
* (/)
2019-05-21 21:28:33 +08:00
*/
class SceneNode:public SceneOrient ///场景节点类
{
2024-09-06 01:04:28 +08:00
SceneNodeID NodeID; ///<节点ID
SceneNodeName NodeName; ///<节点名称
2019-05-21 21:28:33 +08:00
protected:
AABB BoundingBox; ///<绑定盒
AABB LocalBoundingBox; ///<本地坐标绑定盒
//AABB WorldBoundingBox; ///<世界坐标绑定盒
2019-05-21 21:28:33 +08:00
Renderable *render_obj=nullptr; ///<可渲染实例
2019-05-21 21:28:33 +08:00
2024-10-06 02:30:59 +08:00
protected:
2019-05-21 21:28:33 +08:00
ObjectList<SceneNode> SubNode; ///<子节点
2019-05-21 21:28:33 +08:00
public:
2024-09-06 01:04:28 +08:00
const SceneNodeID & GetNodeID ()const { return NodeID; } ///<取得节点ID
const SceneNodeName & GetNodeName ()const { return NodeName; } ///<取得节点名称
2024-10-06 02:30:59 +08:00
const ObjectList<SceneNode> &GetSubNode()const { return SubNode; } ///<取得子节点列表
public:
2024-09-06 01:04:28 +08:00
2021-05-31 19:10:17 +08:00
SceneNode()=default;
2024-10-06 02:30:59 +08:00
SceneNode(const SceneNode &)=delete;
SceneNode(const SceneNode *)=delete;
SceneNode(const SceneOrient &so ):SceneOrient(so) {}
SceneNode( Renderable *ri ) {render_obj=ri;}
SceneNode(const Matrix4f &mat ):SceneOrient(mat) {}
SceneNode(const Matrix4f &mat, Renderable *ri ):SceneOrient(mat) {render_obj=ri;}
2019-05-21 21:28:33 +08:00
2024-09-06 01:04:28 +08:00
public:
virtual ~SceneNode()=default;
void Clear() override
{
SceneOrient::Clear();
BoundingBox.SetZero();
LocalBoundingBox.SetZero();
SubNode.Clear();
2021-06-10 18:56:23 +08:00
render_obj=nullptr;
}
2024-07-28 23:34:04 +08:00
const bool IsEmpty()const
{
if(render_obj)return(false);
if(SubNode.GetCount())return(false);
return(true);
}
Renderable *GetRenderable(){return render_obj;}
void SetRenderable(Renderable *);
2024-10-06 02:30:59 +08:00
SceneNode *Add(SceneNode *sn)
{
if(!sn)
return(nullptr);
SubNode.Add(sn);
return sn;
}
2019-05-21 21:28:33 +08:00
public: //坐标相关方法
virtual void SetBoundingBox (const AABB &bb){BoundingBox=bb;} ///<设置绑定盒
2024-10-06 02:30:59 +08:00
virtual void RefreshMatrix () override; ///<刷新世界变换
2019-05-21 21:28:33 +08:00
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
};//class SceneNode
2024-09-06 01:04:28 +08:00
2024-10-06 14:51:38 +08:00
SceneNode *Duplication(SceneNode *); ///<复制一个场景节点
2019-05-21 21:28:33 +08:00
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_SCENE_NODE_INCLUDE