💿🐜 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.

107 lines
2.3 KiB

  1. /*
  2. * Copyright (C) 2021 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_LIGHT_HPP
  20. #define ANTKEEPER_SCENE_LIGHT_HPP
  21. #include "scene/object.hpp"
  22. #include "geometry/sphere.hpp"
  23. #include "utility/fundamental-types.hpp"
  24. namespace scene {
  25. enum class light_type
  26. {
  27. ambient,
  28. directional,
  29. point,
  30. spot
  31. };
  32. class light: public object<light>
  33. {
  34. public:
  35. light();
  36. virtual light_type get_light_type() const = 0;
  37. void set_color(const float3& color);
  38. void set_intensity(float intensity);
  39. virtual const bounding_volume<float>& get_bounds() const;
  40. const float3& get_color() const;
  41. float get_intensity() const;
  42. const float3& get_scaled_color() const;
  43. const tween<float3>& get_color_tween() const;
  44. const tween<float>& get_intensity_tween() const;
  45. const tween<float3>& get_scaled_color_tween() const;
  46. /// @copydoc object_base::update_tweens();
  47. virtual void update_tweens();
  48. private:
  49. virtual void transformed();
  50. tween<float3> color;
  51. tween<float> intensity;
  52. tween<float3> scaled_color;
  53. sphere<float> bounds;
  54. };
  55. inline const bounding_volume<float>& light::get_bounds() const
  56. {
  57. return bounds;
  58. }
  59. inline const float3& light::get_color() const
  60. {
  61. return color[1];
  62. }
  63. inline float light::get_intensity() const
  64. {
  65. return intensity[1];
  66. }
  67. inline const float3& light::get_scaled_color() const
  68. {
  69. return scaled_color[1];
  70. }
  71. inline const tween<float3>& light::get_color_tween() const
  72. {
  73. return color;
  74. }
  75. inline const tween<float>& light::get_intensity_tween() const
  76. {
  77. return intensity;
  78. }
  79. inline const tween<float3>& light::get_scaled_color_tween() const
  80. {
  81. return scaled_color;
  82. }
  83. } // namespace scene
  84. #endif // ANTKEEPER_SCENE_LIGHT_HPP