💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.9 KiB

  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. #ifndef ANTKEEPER_SCENE_POINT_LIGHT_HPP
  20. #define ANTKEEPER_SCENE_POINT_LIGHT_HPP
  21. #include <engine/scene/light.hpp>
  22. #include <engine/math/vector.hpp>
  23. namespace scene {
  24. /**
  25. * Light source that radiates outward from a point.
  26. */
  27. class point_light: public light
  28. {
  29. public:
  30. /// Returns light_type::point.
  31. [[nodiscard]] inline light_type get_light_type() const noexcept override
  32. {
  33. return light_type::point;
  34. }
  35. /**
  36. * Sets the luminous flux of the light.
  37. *
  38. * @param luminous_flux Luminous flux.
  39. */
  40. inline void set_luminous_flux(float luminous_flux) noexcept
  41. {
  42. m_luminous_flux = luminous_flux;
  43. luminous_flux_updated();
  44. }
  45. /// Returns the luminous flux of the light.
  46. [[nodiscard]] inline constexpr float get_luminous_flux() const noexcept
  47. {
  48. return m_luminous_flux;
  49. }
  50. /// Returns the color-modulated luminous flux of the light.
  51. [[nodiscard]] inline constexpr const math::fvec3& get_colored_luminous_flux() const noexcept
  52. {
  53. return m_colored_luminous_flux;
  54. }
  55. private:
  56. void color_updated() override;
  57. void luminous_flux_updated() noexcept;
  58. float m_luminous_flux{};
  59. math::fvec3 m_colored_luminous_flux{};
  60. };
  61. } // namespace scene
  62. #endif // ANTKEEPER_SCENE_POINT_LIGHT_HPP