From d7f7a7d09534ef0549aa6dd5a95b0f560c5a5879 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 6 Sep 2024 01:04:28 +0800 Subject: [PATCH] [WIP] preparing SceneManager --- inc/hgl/graph/SceneInfo.h | 38 ----------------------------- inc/hgl/graph/SceneManager.h | 46 +++++++++++++++++++++++++++++++++++ inc/hgl/graph/SceneNode.h | 18 ++++++++++++++ src/SceneGraph/CMakeLists.txt | 2 +- 4 files changed, 65 insertions(+), 39 deletions(-) delete mode 100644 inc/hgl/graph/SceneInfo.h create mode 100644 inc/hgl/graph/SceneManager.h diff --git a/inc/hgl/graph/SceneInfo.h b/inc/hgl/graph/SceneInfo.h deleted file mode 100644 index bc644125..00000000 --- a/inc/hgl/graph/SceneInfo.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef HGL_GRAPH_SCENE_INFO_INCLUDE -#define HGL_GRAPH_SCENE_INFO_INCLUDE - -#include -#include -namespace hgl -{ - namespace graph - { - /** - * MVP矩阵 - */ - struct MVPMatrix - { - Matrix4f model; ///< model: Local to World - //Matrix4f normal; /// + +namespace hgl +{ + namespace graph + { + template class ObjectAllocator + { + + template class IDNameObjectMap + { + ObjectList obj_list; + + Map obj_map_by_id; + Map obj_map_by_name; + + public: + + virtual ~IDNameObjectMap()=default; + };//class NodeManager; + + /** + * 场景管理器
+ * 管理一个场景中的所有资源与场景节点 + */ + class SceneManager + { + SceneNode *root_node; + + + + public: + + SceneNode *GetSceneRoot() {return root_node;} + const SceneNode *GetSceneRoot()const{return root_node;} + + const uint GetNodeCount()const { return node_list.GetCount(); } + + public: + + + + };//class SceneManager + }//namespace graph +}//namespace hgl diff --git a/inc/hgl/graph/SceneNode.h b/inc/hgl/graph/SceneNode.h index cc023101..d71b6ffa 100644 --- a/inc/hgl/graph/SceneNode.h +++ b/inc/hgl/graph/SceneNode.h @@ -2,12 +2,16 @@ #define HGL_GRAPH_SCENE_NODE_INCLUDE #include +#include #include #include namespace hgl { namespace graph { + using SceneNodeID =uint64; + using SceneNodeName =AnsiIDName; + /** * 场景节点数据类
* 从场景坐标变换(SceneOrient)类继承, @@ -15,6 +19,9 @@ namespace hgl */ class SceneNode:public SceneOrient ///场景节点类 { + SceneNodeID NodeID; ///<节点ID + SceneNodeName NodeName; ///<节点名称 + protected: AABB BoundingBox; ///<绑定盒 @@ -29,12 +36,21 @@ namespace hgl public: + const SceneNodeID & GetNodeID ()const { return NodeID; } ///<取得节点ID + const SceneNodeName & GetNodeName ()const { return NodeName; } ///<取得节点名称 + + private: + SceneNode()=default; SceneNode(SceneNode *); SceneNode( Renderable *ri ) {render_obj=ri;} SceneNode(const Matrix4f &mat ):SceneOrient(mat) {} SceneNode(const Matrix4f &mat, Renderable *ri ):SceneOrient(mat) {render_obj=ri;} + friend SceneNode *CreateSceneNode(const SceneNodeName &); + + public: + virtual ~SceneNode()=default; void Clear() override @@ -140,6 +156,8 @@ namespace hgl virtual const AABB & GetLocalBoundingBox ()const{return LocalBoundingBox;} ///<取得本地坐标绑定盒 // virtual const AABB & GetWorldBoundingBox ()const{return WorldBoundingBox;} ///<取得世界坐标绑定盒 };//class SceneNode + + SceneNode *CreateSceneNode(const SceneNodeName &); }//namespace graph }//namespace hgl #endif//HGL_GRAPH_SCENE_NODE_INCLUDE diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index 0882cd67..90b51d51 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -40,7 +40,7 @@ SET(LIGHT_FILES ${SG_INCLUDE_PATH}/Light.h) source_group("Light" FILES ${LIGHT_FILES}) -SET(SCENE_GRAPH_HEADER ${SG_INCLUDE_PATH}/SceneInfo.h +SET(SCENE_GRAPH_HEADER ${SG_INCLUDE_PATH}/SceneManager.h ${SG_INCLUDE_PATH}/SceneNode.h ${SG_INCLUDE_PATH}/RenderNode.h ${SG_INCLUDE_PATH}/SceneMatrix.h