2025-03-25 23:15:38 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include<hgl/component/PrimitiveComponent.h>
|
2025-05-18 02:15:33 +08:00
|
|
|
#include<hgl/graph/Mesh.h>
|
2025-03-25 23:15:38 +08:00
|
|
|
|
|
|
|
COMPONENT_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
struct StaticMeshComponentData:public ComponentData
|
|
|
|
{
|
2025-05-18 02:03:16 +08:00
|
|
|
Mesh *renderable;
|
2025-03-25 23:15:38 +08:00
|
|
|
};//struct StaticMeshComponentData
|
|
|
|
|
2025-04-01 01:11:32 +08:00
|
|
|
class StaticMeshComponent;
|
2025-03-25 23:15:38 +08:00
|
|
|
|
|
|
|
class StaticMeshComponentManager:public ComponentManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2025-04-03 01:35:39 +08:00
|
|
|
static StaticMeshComponentManager *GetDefaultManager()
|
|
|
|
{
|
|
|
|
return GetComponentManager<StaticMeshComponentManager>(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr const size_t StaticHashCode (){return hgl::GetTypeHash<StaticMeshComponentManager>();}
|
|
|
|
static constexpr const size_t StaticComponentHashCode (){return hgl::GetTypeHash<StaticMeshComponent>();}
|
|
|
|
|
|
|
|
const size_t GetComponentHashCode ()const override{return StaticMeshComponentManager::StaticComponentHashCode();}
|
|
|
|
const size_t GetHashCode ()const override{return StaticMeshComponentManager::StaticHashCode();}
|
|
|
|
|
|
|
|
public:
|
2025-03-25 23:15:38 +08:00
|
|
|
|
2025-04-03 01:35:39 +08:00
|
|
|
StaticMeshComponentManager()=default;
|
2025-04-01 01:11:32 +08:00
|
|
|
|
2025-03-25 23:15:38 +08:00
|
|
|
StaticMeshComponent *CreateStaticMeshComponent(SceneNode *psn,StaticMeshComponentData *data);
|
|
|
|
|
2025-04-01 01:11:32 +08:00
|
|
|
virtual Component *CreateComponent(SceneNode *psn,ComponentData *data) override;
|
2025-03-25 23:15:38 +08:00
|
|
|
};//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);
|
|
|
|
}
|
|
|
|
|
2025-04-03 01:35:39 +08:00
|
|
|
virtual ~StaticMeshComponent()=default;
|
|
|
|
|
|
|
|
static constexpr const size_t StaticHashCode()
|
|
|
|
{
|
|
|
|
return hgl::GetTypeHash<StaticMeshComponent>();
|
|
|
|
}
|
|
|
|
|
|
|
|
const size_t GetHashCode()const override
|
2025-03-25 23:15:38 +08:00
|
|
|
{
|
2025-04-03 01:35:39 +08:00
|
|
|
return StaticMeshComponent::StaticHashCode();
|
2025-03-25 23:15:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
StaticMeshComponentData &GetData() {return *sm_data;}
|
|
|
|
const StaticMeshComponentData &GetData()const {return *sm_data;}
|
|
|
|
|
|
|
|
};//class StaticMeshComponent
|
|
|
|
|
|
|
|
COMPONENT_NAMESPACE_END
|