Skylicht Engine
Loading...
Searching...
No Matches
CIndirectLighting.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 "CIndirectLightingData.h"
29
30namespace Skylicht
31{
32 class CEntity;
33
46 class SKYLICHT_API CIndirectLighting : public CComponentSystem
47 {
48 public:
49 enum EIndirectType
50 {
51 LightmapArray = 0,
52 VertexColor,
53 SH9,
54 AmbientColor
55 };
56
57 protected:
58 EIndirectType m_type;
59
60 bool m_autoSH;
61
62 std::vector<CIndirectLightingData*> m_data;
63
64 core::vector3df m_sh[9];
65 float m_intensity;
66 float m_customIntensity;
67
68 std::vector<std::string> m_indirectLMPaths;
69 ITexture* m_indirectLM;
70 bool m_internalIndirectLM;
71
72 SColor m_ambientColor;
73
74 u32 m_lightLayers;
75
76 public:
77 CIndirectLighting();
78
79 virtual ~CIndirectLighting();
80
81 virtual void initComponent();
82
83 virtual void startComponent();
84
85 virtual void updateComponent();
86
87 virtual CObjectSerializable* createSerializable();
88
89 virtual void loadSerializable(CObjectSerializable* object);
90
91 protected:
92
93 void addLightingData(CEntity* entity);
94
95 public:
96
97 void setLightLayers(u32 layers);
98
99 void setAutoSH(bool b);
100
101 void setIndirectLightingType(EIndirectType type, bool loadLightmap = true);
102
103 void setIndirectLightmap(ITexture* texture);
104
105 ITexture* getIndirectLightmap()
106 {
107 return m_indirectLM;
108 }
109
110 void setSH(core::vector3df* sh);
111
112 void setAmbientColor(const SColor& color);
113
114 void setCustomIntensity(float intensity);
115
116 EIndirectType getIndirectLightingType()
117 {
118 return m_type;
119 }
120
121 std::vector<CIndirectLightingData*>& getData()
122 {
123 return m_data;
124 }
125
126 bool isLightmapEmpty();
127
128 bool isLightmapChanged(const std::vector<std::string>& paths);
129
130 void removeAllData();
131
132 DECLARE_GETTYPENAME(CIndirectLighting)
133 };
134}
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