MQEngine
载入中...
搜索中...
未找到
Component.h
浏览该文件的文档.
1//
2// Created by Administrator on 2025/8/25.
3//
4
5#ifndef COMPONENT_H
6#define COMPONENT_H
7#include "NameTag.h"
9#include <boost/describe.hpp>
10namespace MQEngine {
12 {
13 std::string modelUuid; // 模型UUID,用于定位模型文件
14 std::string meshName; // 网格体名称,用于从模型中选择特定网格
15 FCT::StaticMesh<uint32_t>* mesh; // 实际存储的mesh,默认为nullptr表示未加载
16
17 StaticMeshInstance() : mesh(nullptr) {}
18
19 StaticMeshInstance(const std::string& uuid, const std::string& name)
20 : modelUuid(uuid), meshName(name), mesh(nullptr)
21 {
22 }
24
25 template<class Archive>
26 void serialize(Archive & ar, const unsigned int version)
27 {
28 ar & modelUuid;
29 ar & meshName;
30 }
31 };
32 BOOST_DESCRIBE_STRUCT(StaticMeshInstance, (), (modelUuid, meshName))
33
34 struct ENGINE_API ScriptComponent
35 {
36 std::string functionName;
37
38 ScriptComponent() = default;
39
40 ScriptComponent(const std::string& funcName)
41 : functionName(funcName)
42 {
43 }
44
45 friend class boost::serialization::access;
46
47 template<class Archive>
48 void serialize(Archive & ar, const unsigned int version)
49 {
50 ar & functionName;
51 }
52 };
53 BOOST_DESCRIBE_STRUCT(ScriptComponent, (), (functionName))
54
55 struct ENGINE_API DirectionalLightComponent
56 {
57 FCT::Vec3 direction = FCT::Vec3(0.0f, -1.0f, 0.0f); // 光照方向
58 FCT::Vec3 color = FCT::Vec3(1.0f, 1.0f, 1.0f); // 光照颜色
59 float intensity = 1.0f; // 光照强度
60 bool enabled = true; // 是否启用
61
62 DirectionalLightComponent() = default;
63
64 DirectionalLightComponent(const FCT::Vec3& dir, const FCT::Vec3& col, float intens, bool enable = true)
65 : direction(dir), color(col), intensity(intens), enabled(enable)
66 {
67 }
68
69 friend class boost::serialization::access;
70
71 template<class Archive>
72 void serialize(Archive & ar, const unsigned int version)
73 {
74 ar & direction;
75 ar & color;
76 ar & intensity;
77 ar & enabled;
78 }
79 };
80 BOOST_DESCRIBE_STRUCT(DirectionalLightComponent, (), (direction, color, intensity, enabled))
81
82 struct ENGINE_API DiffuseTextureComponent
83 {
84 std::string modelUuid;
85 std::string texturePath;
86 FCT::Image* texture = nullptr;
87 DiffuseTextureComponent() = default;
88
89 DiffuseTextureComponent(const std::string& uuid, const std::string& path)
90 : modelUuid(uuid), texturePath(path)
91 {
92 }
93
94 friend class boost::serialization::access;
95 template<class Archive>
96 void serialize(Archive & ar, const unsigned int version)
97 {
98 ar & modelUuid;
99 ar & texturePath;
100 }
101 };
102 BOOST_DESCRIBE_STRUCT(DiffuseTextureComponent, (), (modelUuid, texturePath))
103}
104
105#endif //COMPONENT_H
A header file containing third party libraries and macros for platform
#define ENGINE_API
定义 EnginePCH.h:14
定义 application.h:5
BOOST_DESCRIBE_STRUCT(PositionComponent,(),(position)) struct ENGINE_API RotationComponent
定义 Camera.h:23
定义 Component.h:12
StaticMeshInstance()
定义 Component.h:17
FCT::StaticMesh< uint32_t > * mesh
定义 Component.h:15
StaticMeshInstance(const std::string &uuid, const std::string &name)
定义 Component.h:19
std::string modelUuid
定义 Component.h:13
void serialize(Archive &ar, const unsigned int version)
定义 Component.h:26
friend class boost::serialization::access
定义 Component.h:23
std::string meshName
定义 Component.h:14