LightEvent.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. {
  10. /// @addtogroup scene
  11. /// @{
  12. /// An event for light animation
  13. class LightEvent : public Event
  14. {
  15. public:
  16. /// Create
  17. LightEvent(EventManager* manager)
  18. : Event(manager)
  19. {
  20. }
  21. ANKI_USE_RESULT Error init(Second startTime, Second duration, SceneNode* light);
  22. /// Implements Event::update
  23. ANKI_USE_RESULT Error update(Second prevUpdateTime, Second crntTime) override;
  24. void setRadiusMultiplier(F32 v)
  25. {
  26. m_radiusMultiplier = v;
  27. }
  28. void setIntensityMultiplier(const Vec4& v)
  29. {
  30. m_intensityMultiplier = v;
  31. }
  32. /// Set the frequency of changes.
  33. /// @param freq The higher it is the faster things happen.
  34. /// @param deviation Add a randomization to the frequency.
  35. void setFrequency(F32 freq, F32 deviation)
  36. {
  37. ANKI_ASSERT(freq > 0.0);
  38. ANKI_ASSERT(freq > deviation);
  39. m_freq = freq;
  40. m_freqDeviation = deviation;
  41. }
  42. private:
  43. F32 m_freq = 1.0;
  44. F32 m_freqDeviation = 0.0;
  45. F32 m_radiusMultiplier = 0.0;
  46. Vec4 m_intensityMultiplier = Vec4(0.0);
  47. F32 m_originalRadius;
  48. Vec4 m_originalDiffColor;
  49. };
  50. /// @}
  51. } // end namespace anki