Antkeeper  0.0.1
spot-light.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_SCENE_SPOT_LIGHT_HPP
21 #define ANTKEEPER_SCENE_SPOT_LIGHT_HPP
22 
23 #include <engine/scene/light.hpp>
24 #include <engine/math/numbers.hpp>
25 #include <engine/math/vector.hpp>
26 
27 namespace scene {
28 
32 class spot_light: public light
33 {
34 public:
36  [[nodiscard]] inline light_type get_light_type() const noexcept override
37  {
38  return light_type::spot;
39  }
40 
46  inline void set_luminous_flux(const math::fvec3& luminous_flux) noexcept
47  {
48  m_luminous_flux = luminous_flux;
49  }
50 
52  [[nodiscard]] inline const math::fvec3& get_luminous_flux() const noexcept
53  {
54  return m_luminous_flux;
55  }
56 
62  void set_cutoff(const math::fvec2& cutoff);
63 
65  [[nodiscard]] inline const math::fvec3& get_direction() const noexcept
66  {
67  return m_direction;
68  }
69 
71  [[nodiscard]] inline const math::fvec2& get_cutoff() const noexcept
72  {
73  return m_cutoff;
74  }
75 
77  [[nodiscard]] inline const math::fvec2& get_cosine_cutoff() const noexcept
78  {
79  return m_cosine_cutoff;
80  }
81 
82 private:
83  void transformed() override;
84 
85  math::fvec3 m_luminous_flux{0.0f, 0.0f, 0.0f};
86  math::fvec3 m_direction{0.0f, 0.0f, -1.0f};
87  math::fvec2 m_cutoff{math::pi<float>, math::pi<float>};
88  math::fvec2 m_cosine_cutoff{-1.0f, -1.0f};
89 };
90 
91 } // namespace scene
92 
93 #endif // ANTKEEPER_SCENE_SPOT_LIGHT_HPP
94 
Abstract base class for light objects.
Definition: scene/light.hpp:32
Directional cone light source.
Definition: spot-light.hpp:33
const math::fvec2 & get_cutoff() const noexcept
Returns the spot light cutoff angles.
Definition: spot-light.hpp:71
const math::fvec2 & get_cosine_cutoff() const noexcept
Returns the cosine of the spot light cutoff angles.
Definition: spot-light.hpp:77
const math::fvec3 & get_luminous_flux() const noexcept
Returns the luminous flux of the spot light, in lm.
Definition: spot-light.hpp:52
void set_cutoff(const math::fvec2 &cutoff)
Sets the spot light cutoff angles.
Definition: spot-light.cpp:25
void set_luminous_flux(const math::fvec3 &luminous_flux) noexcept
Sets the luminous flux of the spot light.
Definition: spot-light.hpp:46
light_type get_light_type() const noexcept override
Returns light_type::spot.
Definition: spot-light.hpp:36
const math::fvec3 & get_direction() const noexcept
Returns the direction vector.
Definition: spot-light.hpp:65
3D scene.
Definition: context.hpp:28
light_type
Light types.
Definition: light-type.hpp:29
@ spot
Spot light.
n-dimensional vector.
Definition: vector.hpp:44