Compare commits

..

2 Commits

12 changed files with 91 additions and 76 deletions

View File

@ -26,18 +26,15 @@ namespace hgl
graph::RenderPass *render_pass=nullptr;
bool destroy_flag=false;
bool render_dirty=true;
protected:
//以下数据均取自RenderFramework
graph::RenderResource *db=nullptr; //暂时的,未来会被更好的机制替代
/**
* WorkObject中SceneWorld以及一个Renderer即可
* WorldWorkObject上
*/
graph::SceneWorld * world =nullptr; //世界
graph::Scene * scene=nullptr; //场景
graph::Renderer * renderer=nullptr; //渲染器
public:
@ -54,6 +51,9 @@ namespace hgl
const bool IsDestroy ()const{return destroy_flag;}
void MarkDestory(){destroy_flag=true;}
const bool IsRenderDirty ()const{return render_dirty;}
void MarkRenderDirty(){render_dirty=true;}
public:
WorkObject(graph::RenderFramework *,graph::IRenderTarget *rt=nullptr);

View File

@ -11,14 +11,14 @@
*
* AMD FidelityFX中Component存放于Entity下SceneNode
* Entity还是SceneNodeComponent的管理
* AMD FidelityFX中的SceneSceneWorld
* AMD FidelityFX中的SceneScene
*
* ComponentData是每个Component的数据Component或是其它模块提供数据
* ComponentManager是Component的管理器Component的创建
*
* AMD FidelityFX一样ComponentManager与SceneWorld基本无关
* AMD FidelityFX一样ComponentManager与Scene基本无关
* World之中
* SceneWorld密切相关的Component它对应的Manager才会出现在SceneWorldCameraManager/LightManager
* Scene密切相关的Component它对应的Manager才会出现在Scene中CameraManager/LightManager
* StaticMeshComponent之类的纯资源型就会是独立存在的
*
* Component是组件的基类

View File

@ -17,6 +17,9 @@ class RenderTargetManager;
class RenderModule;
class Scene;
class Renderer;
class CameraComponentManager{/*现阶段测试使用*/};
class LightComponentManager{/*现阶段测试使用*/};
@ -47,6 +50,11 @@ protected:
CameraComponentManager *camera_component_manager=nullptr;
LightComponentManager *light_component_manager =nullptr;
protected:
Scene * default_scene =nullptr;
Renderer * default_renderer=nullptr;
public:
Window * GetWindow ()const{return win;}
@ -68,6 +76,11 @@ public:
SwapchainModule * GetSwapchainModule (){return sc_module;}
SwapchainRenderTarget * GetSwapchainRenderTarget(){return sc_module?sc_module->GetRenderTarget():nullptr;}
public:
Scene * GetDefaultScene (){return default_scene;}
Renderer * GetDefaultRenderer (){return default_renderer;}
public:
RenderFramework(const OSString &);

View File

@ -6,7 +6,7 @@
namespace hgl::graph
{
class SceneNode;
class SceneWorld;
class Scene;
class Camera;
class IRenderTarget;
class RenderList;

View File

@ -5,7 +5,7 @@
namespace hgl::graph
{
class SceneWorld;
class Scene;
using RenderTaskNameMap=Map<RenderTaskName,RenderTask *>;
@ -15,7 +15,7 @@ namespace hgl::graph
class Renderer
{
IRenderTarget *render_target;
SceneWorld *world;
Scene *world;
Camera *camera;
@ -30,7 +30,7 @@ namespace hgl::graph
public:
SceneWorld *GetSceneWorld () const { return world; } ///<获取场景世界
Scene *GetScene () const { return world; } ///<获取场景世界
Camera * GetCurCamera () const { return camera; } ///<获取当前相机
public:
@ -38,7 +38,7 @@ namespace hgl::graph
Renderer(IRenderTarget *);
virtual ~Renderer();
void SetCurWorld(SceneWorld *);
void SetCurWorld(Scene *);
void SetCurCamera(Camera *);
bool RenderFrame(RenderCmdBuffer *);

50
inc/hgl/graph/Scene.h Normal file
View File

@ -0,0 +1,50 @@
#pragma once
#include<hgl/graph/SceneNode.h>
#include<hgl/type/Pool.h>
namespace hgl::graph
{
/**
* <Br>
*
*/
class Scene
{
U8String SceneName; ///<场景名称
ObjectList<SceneNode> SceneNodePool; ///<场景节点池
SceneNode *root_node; ///<场景根节点
public:
const U8String & GetSceneName()const{return SceneName;} ///<获取场景名称
SceneNode * GetRootNode (){return root_node;} ///<获取场景根节点
public:
Scene()
{
root_node=new SceneNode;
}
virtual ~Scene()
{
SAFE_CLEAR(root_node);
}
};//class Scene
bool RegistryScene(Scene *sw); ///<注册场景
bool UnregistryScene(const U8String &world_name); ///<注销场景
inline bool UnregistryScene(Scene *sw) ///<注销场景
{
if(!sw)return(false);
return UnregistryScene(sw->GetSceneName());
}
Scene *GetScene(const U8String &world_name); ///<获取指定名称的场景
}//namespace hgl::graph

View File

@ -1,50 +0,0 @@
#pragma once
#include<hgl/graph/SceneNode.h>
#include<hgl/type/Pool.h>
namespace hgl::graph
{
/**
* <Br>
*
*/
class SceneWorld
{
U8String WorldName; ///<世界名称
ObjectList<SceneNode> SceneNodePool; ///<场景节点池
SceneNode *root_node; ///<世界根节点
public:
const U8String & GetWorldName()const{return WorldName;} ///<获取世界名称
SceneNode * GetRootNode (){return root_node;} ///<获取世界根节点
public:
SceneWorld()
{
root_node=new SceneNode;
}
virtual ~SceneWorld()
{
SAFE_CLEAR(root_node);
}
};//class SceneWorld
bool RegistrySceneWorld(SceneWorld *sw); ///<注册场景世界
bool UnregistrySceneWorld(const U8String &world_name); ///<注销场景世界
inline bool UnregistrySceneWorld(SceneWorld *sw) ///<注销场景世界
{
if(!sw)return(false);
return UnregistrySceneWorld(sw->GetWorldName());
}
SceneWorld *GetSceneWorld(const U8String &world_name); ///<获取指定名称的场景世界
}//namespace hgl::graph

View File

@ -71,7 +71,7 @@ SET(GRAPH_FRAMEWORK_FILES ${SG_INCLUDE_PATH}/RenderFramework.h
source_group("Framework" FILES ${GRAPH_FRAMEWORK_FILES})
SET(SG_SCENE_SOURCE ${SG_INCLUDE_PATH}/SceneWorld.h
SET(SG_SCENE_SOURCE ${SG_INCLUDE_PATH}/Scene.h
${SG_INCLUDE_PATH}/SceneNodeAttributes.h
${SG_INCLUDE_PATH}/SceneNode.h
${SG_INCLUDE_PATH}/SceneMatrix.h
@ -79,7 +79,7 @@ SET(SG_SCENE_SOURCE ${SG_INCLUDE_PATH}/SceneWorld.h
Scene/SceneNode.cpp
Scene/SceneOrient.cpp
Scene/SceneMatrix.cpp
Scene/SceneWorld.cpp
Scene/Scene.cpp
)
SET(SG_RENDER_SOURCE ${SG_INCLUDE_PATH}/RenderNode.h

View File

@ -1,5 +1,5 @@
#include<hgl/graph/Renderer.h>
#include<hgl/graph/SceneWorld.h>
#include<hgl/graph/Scene.h>
#include<hgl/graph/VKCommandBuffer.h>
namespace hgl::graph
@ -17,7 +17,7 @@ namespace hgl::graph
delete world;
}
void Renderer::SetCurWorld(SceneWorld *sw)
void Renderer::SetCurWorld(Scene *sw)
{
if(world==sw)
return;

View File

@ -1,18 +1,18 @@
#include<hgl/graph/SceneWorld.h>
#include<hgl/graph/Scene.h>
#include<hgl/type/Map.h>
namespace hgl::graph
{
namespace
{
Map<U8String,SceneWorld *> scene_world_map;///<场景世界列表
Map<U8String,Scene *> scene_world_map;///<场景列表
}//namespace
bool RegistrySceneWorld(SceneWorld *sw)
bool RegistryScene(Scene *sw)
{
if(!sw)return(false);
const U8String &world_name=sw->GetWorldName();
const U8String &world_name=sw->GetSceneName();
if(scene_world_map.Find(world_name))
return false;///<已经注册过了
@ -21,7 +21,7 @@ namespace hgl::graph
return true;
}
SceneWorld *GetSceneWorld(const U8String &world_name)
Scene *GetScene(const U8String &world_name)
{
if(world_name.IsEmpty())
return(nullptr);
@ -29,7 +29,7 @@ namespace hgl::graph
return GetObjectFromMap(scene_world_map,world_name);
}
bool UnregistrySceneWorld(const U8String &world_name)
bool UnregistryScene(const U8String &world_name)
{
if(world_name.IsEmpty())
return(false);

View File

@ -75,7 +75,7 @@ namespace hgl
if(cur_work_object->IsTickable())
Tick(cur_work_object);
if(win->IsVisible()&&cur_work_object->IsRenderable())
if(win->IsVisible())//&&cur_work_object->IsRenderable())
{
Render(cur_work_object);
dev->WaitIdle();

View File

@ -43,6 +43,8 @@ namespace hgl
render_pass=rt->GetRenderPass();
db=rf->GetRenderResource();
scene=rf->GetDefaultScene();
renderer=rf->GetDefaultRenderer();
}
void WorkObject::Render(double delta_time)