增加新的StaticMeshComponent,并添加关于各Component关系的注释
This commit is contained in:
parent
87989a8e42
commit
964c17cf94
@ -4,6 +4,30 @@
|
|||||||
#include<hgl/type/SortedSet.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<hgl/type/List.h>
|
#include<hgl/type/List.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component/Data/Manager 体系设计简要说明
|
||||||
|
*
|
||||||
|
* 本体系参考AMD FidelityFX,但并不完全一致。
|
||||||
|
*
|
||||||
|
* AMD FidelityFX中,Component存放于Entity下,而我方中与其类似的定义为SceneNode。
|
||||||
|
* 不管是Entity还是SceneNode,它们都提供空间变换,以及子节点、Component的管理。
|
||||||
|
*
|
||||||
|
* ComponentData是每个Component的数据,用于向Component或是其它模块提供数据。
|
||||||
|
* ComponentManager是Component的管理器,用于管理Component的创建、销毁、更新等。
|
||||||
|
*
|
||||||
|
* Component是组件的基类,所有组件都从这里派生。
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* RenderComponent是可渲染组件的基类,所有可渲染组件都从这里派生。它继承于Component。
|
||||||
|
*
|
||||||
|
* PrimitiveComponent是图元组件的基类,所有图元组件都从这里派生。它继承于RenderComponent。
|
||||||
|
* 它再度派生出的任何Component都必须是一个有3D空间的几何图元。
|
||||||
|
* 引擎中的空间、物理、等都由PrimitiveComponent提供数据进行计算。
|
||||||
|
*
|
||||||
|
* StaticMeshComponent是静态网格组件,它是一个具体的PrimitiveComponent实现。
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#define COMPONENT_NAMESPACE hgl::graph
|
#define COMPONENT_NAMESPACE hgl::graph
|
||||||
#define COMPONENT_NAMESPACE_BEGIN namespace COMPONENT_NAMESPACE {
|
#define COMPONENT_NAMESPACE_BEGIN namespace COMPONENT_NAMESPACE {
|
||||||
#define COMPONENT_NAMESPACE_END }
|
#define COMPONENT_NAMESPACE_END }
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/component/RenderComponent.h>
|
#include<hgl/component/RenderComponent.h>
|
||||||
#include<hgl/graph/VKRenderable.h>
|
|
||||||
|
|
||||||
COMPONENT_NAMESPACE_BEGIN
|
COMPONENT_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图元组件<br>
|
||||||
|
* 组件中的元素必须是一个可以明确描述的几何体,可以被明确标记尺寸、参与空间、物理计算等。
|
||||||
|
*/
|
||||||
class PrimitiveComponent:public RenderComponent
|
class PrimitiveComponent:public RenderComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PrimitiveComponent()=default;
|
PrimitiveComponent()=default;
|
||||||
virtual ~PrimitiveComponent()=default;
|
virtual ~PrimitiveComponent()=default;
|
||||||
|
|
||||||
Renderable *GetRenderable();
|
|
||||||
};//class PrimitiveComponent
|
};//class PrimitiveComponent
|
||||||
|
|
||||||
COMPONENT_NAMESPACE_END
|
COMPONENT_NAMESPACE_END
|
||||||
|
51
inc/hgl/component/StaticMeshComponent.h
Normal file
51
inc/hgl/component/StaticMeshComponent.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/component/PrimitiveComponent.h>
|
||||||
|
#include<hgl/graph/VKRenderable.h>
|
||||||
|
|
||||||
|
COMPONENT_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
struct StaticMeshComponentData:public ComponentData
|
||||||
|
{
|
||||||
|
Renderable *renderable;
|
||||||
|
};//struct StaticMeshComponentData
|
||||||
|
|
||||||
|
class StaticMeshComponent:public PrimitiveComponent;
|
||||||
|
|
||||||
|
class StaticMeshComponentManager:public ComponentManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
StaticMeshComponentManager()=default;
|
||||||
|
|
||||||
|
StaticMeshComponent *CreateStaticMeshComponent(SceneNode *psn,StaticMeshComponentData *data);
|
||||||
|
|
||||||
|
virtual Component *CreateComponent(SceneNode *psn,ComponentData *data) override
|
||||||
|
{
|
||||||
|
return CreateStaticMeshComponent(psn,reinterpret_cast<StaticMeshComponentData *>(data));
|
||||||
|
}
|
||||||
|
};//class StaticMeshComponentManager
|
||||||
|
|
||||||
|
class StaticMeshComponent:public PrimitiveComponent
|
||||||
|
{
|
||||||
|
StaticMeshComponentData *sm_data;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
StaticMeshComponent(SceneNode *psn,ComponentData *cd,ComponentManager *cm)
|
||||||
|
:PrimitiveComponent(psn,cd,cm)
|
||||||
|
{
|
||||||
|
sm_data=reinterpret_cast<StaticMeshComponentData *>(cd);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~StaticMeshComponent()
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(sm_Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
StaticMeshComponentData &GetData() {return *sm_data;}
|
||||||
|
const StaticMeshComponentData &GetData()const {return *sm_data;}
|
||||||
|
|
||||||
|
};//class StaticMeshComponent
|
||||||
|
|
||||||
|
COMPONENT_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user