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

109 lines
2.4 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 "geom/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. typedef geom::sphere<float> sphere_type;
  36. light();
  37. virtual light_type get_light_type() const = 0;
  38. void set_color(const float3& color);
  39. void set_intensity(float intensity);
  40. virtual const bounding_volume_type& get_bounds() const;
  41. const float3& get_color() const;
  42. float get_intensity() const;
  43. const float3& get_scaled_color() const;
  44. const tween<float3>& get_color_tween() const;
  45. const tween<float>& get_intensity_tween() const;
  46. const tween<float3>& get_scaled_color_tween() const;
  47. /// @copydoc object_base::update_tweens();
  48. virtual void update_tweens();
  49. private:
  50. virtual void transformed();
  51. tween<float3> color;
  52. tween<float> intensity;
  53. tween<float3> scaled_color;
  54. sphere_type bounds;
  55. };
  56. inline const typename object_base::bounding_volume_type& light::get_bounds() const
  57. {
  58. return bounds;
  59. }
  60. inline const float3& light::get_color() const
  61. {
  62. return color[1];
  63. }
  64. inline float light::get_intensity() const
  65. {
  66. return intensity[1];
  67. }
  68. inline const float3& light::get_scaled_color() const
  69. {
  70. return scaled_color[1];
  71. }
  72. inline const tween<float3>& light::get_color_tween() const
  73. {
  74. return color;
  75. }
  76. inline const tween<float>& light::get_intensity_tween() const
  77. {
  78. return intensity;
  79. }
  80. inline const tween<float3>& light::get_scaled_color_tween() const
  81. {
  82. return scaled_color;
  83. }
  84. } // namespace scene
  85. #endif // ANTKEEPER_SCENE_LIGHT_HPP