3 Copyright (C) 2021 Liso <anlismon@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "irrlichttypes_bloated.h"
24 #include "util/basic_macros.h"
25 #include "constants.h"
36 core::matrix4 ProjOrthMat;
37 core::matrix4 ViewMat;
43 class DirectionalLight
46 DirectionalLight(const u32 shadowMapResolution,
48 video::SColorf lightColor = video::SColor(0xffffffff),
49 f32 farValue = 100.0f);
50 ~DirectionalLight() = default;
52 //DISABLE_CLASS_COPY(DirectionalLight)
54 void update_frustum(const Camera *cam, Client *client, bool force = false);
56 // when set direction is updated to negative normalized(direction)
57 void setDirection(v3f dir);
58 v3f getDirection() const{
61 v3f getPosition() const;
62 v3f getPlayerPos() const;
63 v3f getFuturePlayerPos() const;
65 /// Gets the light's matrices.
66 const core::matrix4 &getViewMatrix() const;
67 const core::matrix4 &getProjectionMatrix() const;
68 const core::matrix4 &getFutureViewMatrix() const;
69 const core::matrix4 &getFutureProjectionMatrix() const;
70 core::matrix4 getViewProjMatrix();
72 /// Gets the light's far value.
73 f32 getMaxFarValue() const
79 /// Gets the light's color.
80 const video::SColorf &getLightColor() const
85 /// Sets the light's color.
86 void setLightColor(const video::SColorf &lightColor)
88 diffuseColor = lightColor;
91 /// Gets the shadow map resolution for this light.
92 u32 getMapResolution() const
97 bool should_update_map_shadow{true};
102 void createSplitMatrices(const Camera *cam);
104 video::SColorf diffuseColor;
111 shadowFrustum shadow_frustum;
112 shadowFrustum future_frustum;