2 Commits

Author SHA1 Message Date
d577642533 RenderFramework关联default_scene事件传递 2025-07-27 16:47:12 +08:00
510168e912 CreateComponentInfo代码排版 2025-07-27 16:46:35 +08:00
3 changed files with 60 additions and 44 deletions

View File

@@ -2,49 +2,45 @@
#include<hgl/math/Matrix.h>
namespace hgl
namespace hgl::graph
{
namespace graph
class SceneNode;
struct CreateComponentInfo
{
class SceneNode;
graph::SceneNode *owner_node; ///<所属节点
graph::Matrix4f mat; ///<变换矩阵
struct CreateComponentInfo
public:
CreateComponentInfo()
{
graph::SceneNode *owner_node; ///<所属节点
graph::Matrix4f mat; ///<变换矩阵
owner_node=nullptr;
mat=graph::Identity4f;
}
public:
CreateComponentInfo(const CreateComponentInfo &cci)
{
owner_node=cci.owner_node;
mat=cci.mat;
}
CreateComponentInfo()
{
owner_node=nullptr;
mat=graph::Identity4f;
}
CreateComponentInfo(graph::SceneNode *pn,const graph::Matrix4f &m)
{
owner_node=pn;
mat=m;
}
CreateComponentInfo(const CreateComponentInfo &cci)
{
owner_node=cci.owner_node;
mat=cci.mat;
}
CreateComponentInfo(graph::SceneNode *pn)
{
owner_node=pn;
mat=graph::Identity4f;
}
CreateComponentInfo(graph::SceneNode *pn,const graph::Matrix4f &m)
{
owner_node=pn;
mat=m;
}
CreateComponentInfo(graph::SceneNode *pn)
{
owner_node=pn;
mat=graph::Identity4f;
}
CreateComponentInfo(const graph::Matrix4f &m)
{
owner_node=nullptr;
mat=m;
}
};//struct CreateComponentInfo
}//namespace graph
}//namespace hgl
CreateComponentInfo(const graph::Matrix4f &m)
{
owner_node=nullptr;
mat=m;
}
};//struct CreateComponentInfo
}//namespace hgl::graph

View File

@@ -63,6 +63,8 @@ protected: //RenderContext,未来合并成一个RenderContext结构
CameraControl * default_camera_control =nullptr;
Renderer * default_renderer =nullptr;
void OnChangeDefaultScene(Scene *);
void CreateDefaultRenderer();
protected: //EventDispatcher

View File

@@ -134,7 +134,7 @@ bool RenderFramework::Init(uint w,uint h)
render_resource=new RenderResource(device);
default_scene=new Scene;
OnChangeDefaultScene(new Scene);
default_camera=new Camera();
@@ -143,6 +143,24 @@ bool RenderFramework::Init(uint w,uint h)
return(true);
}
void RenderFramework::OnChangeDefaultScene(Scene *s)
{
if(default_scene==s)
return;
if(default_scene)
{
this->RemoveChildDispatcher(&(default_scene->GetEventDispatcher()));
}
if(s)
{
this->AddChildDispatcher(&(s->GetEventDispatcher()));
}
default_scene=s;
}
void RenderFramework::CreateDefaultRenderer()
{
SAFE_CLEAR(default_renderer)
@@ -246,11 +264,11 @@ graph::Primitive *RenderFramework::CreatePrimitive( const AnsiString &name,
return prim;
}
graph::Mesh *RenderFramework::CreateMesh( const AnsiString &name,
const uint32_t vertices_count,
graph::MaterialInstance *mi,
graph::Pipeline *pipeline,
const std::initializer_list<graph::VertexAttribDataPtr> &vad_list)
graph::Mesh *RenderFramework::CreateMesh( const AnsiString &name,
const uint32_t vertices_count,
graph::MaterialInstance *mi,
graph::Pipeline *pipeline,
const std::initializer_list<graph::VertexAttribDataPtr> &vad_list)
{
auto *prim=this->CreatePrimitive(name,vertices_count,mi->GetVIL(),vad_list);