Skylicht Engine
Loading...
Searching...
No Matches
CLightmap.h
1/*
2!@
3MIT License
4
5Copyright (c) 2020 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "Components/CComponentSystem.h"
28#include "CLightmapData.h"
29
30namespace Skylicht
31{
32 class CEntity;
33
34 class SKYLICHT_API CLightmap : public CComponentSystem
35 {
36 public:
37
38 protected:
39 std::vector<std::string> m_lightmapPaths;
40 std::vector<std::string> m_lightDataExternal;
41
42 ITexture* m_lightmap;
43
44 std::string m_lightmapShader;
45 bool m_autoLoadLightmap;
46 int m_lightmapBeginIndex;
47 bool m_applyChilds;
48
49 bool m_textureOwner;
50
51 std::vector<CLightmapData*> m_data;
52
53 public:
54 CLightmap();
55
56 virtual ~CLightmap();
57
58 virtual void initComponent();
59
60 virtual void startComponent();
61
62 virtual void updateComponent();
63
64 virtual CObjectSerializable* createSerializable();
65
66 virtual void loadSerializable(CObjectSerializable* object);
67
68 protected:
69
70 void addLightingData(CEntity* entity);
71
72 public:
73
74 void updateLightmap(bool loadLightmap = true);
75
76 void setLightmap(ITexture* texture, int beginIndex);
77
78 void changeLightmapShader();
79
80 void changeLightmapShader(const char* shader);
81
82 void changeDefaultShader();
83
84 inline const std::string& getLightmapShader()
85 {
86 return m_lightmapShader;
87 }
88
89 ITexture* getLightmap()
90 {
91 return m_lightmap;
92 }
93
94 std::vector<CLightmapData*>& getData()
95 {
96 return m_data;
97 }
98
99 const std::vector<std::string>& getLightDataExternal()
100 {
101 return m_lightDataExternal;
102 }
103
104 bool isLightmapEmpty();
105
106 bool isLightmapChanged(const std::vector<std::string>& paths);
107
108 DECLARE_GETTYPENAME(CLightmap)
109 };
110}
This is the object class that describes an entity.
Definition CEntity.h:58
Definition CObjectSerializable.h:36
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29