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

130 lines
3.2 KiB

  1. /*
  2. * Copyright (C) 2020 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_SPOTLIGHT_HPP
  20. #define ANTKEEPER_SPOTLIGHT_HPP
  21. #include "scene/light.hpp"
  22. #include "utility/fundamental-types.hpp"
  23. class spotlight: public light
  24. {
  25. public:
  26. spotlight();
  27. /// Returns light_type::spot
  28. virtual light_type get_light_type() const;
  29. /**
  30. * Sets the attenuation factors of the light.
  31. *
  32. * @param attenuation Vector containing the constant, linear, and quadratic attenuation factors, as x, y, and z, respectively.
  33. */
  34. void set_attenuation(const float3& attenuation);
  35. /**
  36. * Sets the spotlight cutoff angles.
  37. *
  38. * @param cutoff Vector containing the inner and outer cutoff angles, as x and y, respectively.
  39. */
  40. void set_cutoff(const float2& cutoff);
  41. /// Returns the direction vector.
  42. const float3& get_direction() const;
  43. /// Returns the attenuation factors of the light.
  44. const float3& get_attenuation() const;
  45. /// Returns the spotlight cutoff angles.
  46. const float2& get_cutoff() const;
  47. /// Returns the cosine of the spotlight cutoff angles.
  48. const float2& get_cosine_cutoff() const;
  49. /// Returns the direction tween.
  50. const tween<float3>& get_direction_tween() const;
  51. /// Returns the attenuation tween.
  52. const tween<float3>& get_attenuation_tween() const;
  53. /// Returns the cutoff tween.
  54. const tween<float2>& get_cutoff_tween() const;
  55. /// Returns the cosine cutoff tween.
  56. const tween<float2>& get_cosine_cutoff_tween() const;
  57. /// @copydoc scene_object_base::update_tweens();
  58. virtual void update_tweens();
  59. private:
  60. virtual void transformed();
  61. tween<float3> direction;
  62. tween<float3> attenuation;
  63. tween<float2> cutoff;
  64. tween<float2> cosine_cutoff;
  65. };
  66. inline light_type spotlight::get_light_type() const
  67. {
  68. return light_type::spot;
  69. }
  70. inline const float3& spotlight::get_direction() const
  71. {
  72. return direction[1];
  73. }
  74. inline const float3& spotlight::get_attenuation() const
  75. {
  76. return attenuation[1];
  77. }
  78. inline const float2& spotlight::get_cutoff() const
  79. {
  80. return cutoff[1];
  81. }
  82. inline const float2& spotlight::get_cosine_cutoff() const
  83. {
  84. return cosine_cutoff[1];
  85. }
  86. inline const tween<float3>& spotlight::get_direction_tween() const
  87. {
  88. return direction;
  89. }
  90. inline const tween<float3>& spotlight::get_attenuation_tween() const
  91. {
  92. return attenuation;
  93. }
  94. inline const tween<float2>& spotlight::get_cutoff_tween() const
  95. {
  96. return cutoff;
  97. }
  98. inline const tween<float2>& spotlight::get_cosine_cutoff_tween() const
  99. {
  100. return cosine_cutoff;
  101. }
  102. #endif // ANTKEEPER_SPOTLIGHT_HPP