LightEvent.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Scene/Events/Event.h>
  7. #include <AnKi/Math.h>
  8. namespace anki {
  9. /// @addtogroup scene
  10. /// @{
  11. /// An event for light animation
  12. class LightEvent : public Event
  13. {
  14. public:
  15. /// Create
  16. LightEvent(EventManager* manager)
  17. : Event(manager)
  18. {
  19. }
  20. ANKI_USE_RESULT Error init(Second startTime, Second duration, SceneNode* light);
  21. /// Implements Event::update
  22. ANKI_USE_RESULT Error update(Second prevUpdateTime, Second crntTime) override;
  23. void setRadiusMultiplier(F32 v)
  24. {
  25. m_radiusMultiplier = v;
  26. }
  27. void setIntensityMultiplier(const Vec4& v)
  28. {
  29. m_intensityMultiplier = v;
  30. }
  31. /// Set the frequency of changes.
  32. /// @param freq The higher it is the faster things happen.
  33. /// @param deviation Add a randomization to the frequency.
  34. void setFrequency(F32 freq, F32 deviation)
  35. {
  36. ANKI_ASSERT(freq > 0.0);
  37. ANKI_ASSERT(freq > deviation);
  38. m_freq = freq;
  39. m_freqDeviation = deviation;
  40. }
  41. private:
  42. F32 m_freq = 1.0;
  43. F32 m_freqDeviation = 0.0;
  44. F32 m_radiusMultiplier = 0.0;
  45. Vec4 m_intensityMultiplier = Vec4(0.0);
  46. F32 m_originalRadius;
  47. Vec4 m_originalDiffColor;
  48. };
  49. /// @}
  50. } // end namespace anki