Line data Source code
1 : /* Copyright (C) 2026 Wildfire Games. 2 : * This file is part of 0 A.D. 3 : * 4 : * 0 A.D. is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 2 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * 0 A.D. is distributed in the hope that it will be useful, 10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : * GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License 15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 : */ 17 : 18 : /* 19 : * CLightEnv, a class describing the current lights 20 : */ 21 : 22 : #ifndef INCLUDED_LIGHTENV 23 : #define INCLUDED_LIGHTENV 24 : 25 : #include "graphics/Color.h" 26 : #include "maths/Vector3D.h" 27 : 28 : namespace Renderer::Backend { class IDeviceCommandContext; } 29 : namespace Renderer::Backend { class IShaderProgram; } 30 : 31 : /** 32 : * Class CLightEnv: description of a lighting environment - contains all the 33 : * necessary parameters for representation of the lighting within a scenario 34 : */ 35 : class CLightEnv 36 : { 37 : public: 38 : RGBColor m_SunColor; 39 : RGBColor m_AmbientColor; 40 : RGBColor m_FogColor; 41 : 42 : float m_FogFactor; 43 : float m_FogMax; 44 : 45 : float m_Brightness, m_Contrast, m_Saturation, m_Bloom; 46 : 47 : CLightEnv(); 48 : 49 0 : float GetElevation() const { return m_Elevation; } 50 0 : float GetRotation() const { return m_Rotation; } 51 0 : const CVector3D& GetSunDir() const { return m_SunDir; } 52 : 53 : void SetElevation(float f); 54 : void SetRotation(float f); 55 : 56 : // Comparison operators 57 : bool operator==(const CLightEnv& o) const 58 : { 59 : return m_Elevation == o.m_Elevation && 60 : m_Rotation == o.m_Rotation && 61 : m_SunColor == o.m_SunColor && 62 : m_AmbientColor == o.m_AmbientColor && 63 : m_FogColor == o.m_FogColor && 64 : m_FogFactor == o.m_FogFactor && 65 : m_FogMax == o.m_FogMax && 66 : m_Brightness == o.m_Brightness && 67 : m_Contrast == o.m_Contrast && 68 : m_Saturation == o.m_Saturation && 69 : m_Bloom == o.m_Bloom; 70 : } 71 : 72 : bool operator!=(const CLightEnv& o) const 73 : { 74 : return !(*this == o); 75 : } 76 : 77 : void Bind( 78 : Renderer::Backend::IDeviceCommandContext* deviceCommandContext, 79 : Renderer::Backend::IShaderProgram* shaderProgram) const; 80 : 81 : private: 82 : friend class CMapWriter; 83 : friend class CMapReader; 84 : friend class CXMLReader; 85 : 86 : /** 87 : * Height of sun above the horizon, in radians. 88 : * For example, an elevation of PI/2 means the sun is straight up. 89 : */ 90 : float m_Elevation; 91 : 92 : /** 93 : * Direction of sun on the compass, in radians. 94 : * For example, a rotation of zero means the sun is in the direction (0,0,-1) 95 : * and a rotation of PI/2 means the sun is in the direction (1,0,0) (not taking 96 : * elevation into account). 97 : */ 98 : float m_Rotation; 99 : 100 : /** 101 : * Vector corresponding to m_Elevation and m_Rotation. 102 : * Updated by CalculateSunDirection. 103 : */ 104 : CVector3D m_SunDir; 105 : 106 : void CalculateSunDirection(); 107 : }; 108 : 109 : #endif // INCLUDED_LIGHTENV