SceneColorEvent.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "anki/event/SceneColorEvent.h"
  2. #include "anki/scene/Scene.h"
  3. #include "anki/core/Globals.h"
  4. #include "anki/core/Logger.h"
  5. namespace anki {
  6. //==============================================================================
  7. // Constructor =
  8. //==============================================================================
  9. SceneColorEvent::SceneColorEvent(float startTime, float duration,
  10. const Vec3& finalColor_)
  11. : Event(SCENE_COLOR, startTime, duration), finalColor(finalColor_)
  12. {
  13. originalColor = SceneSingleton::get().getAmbientColor();
  14. }
  15. //==============================================================================
  16. // Constructor copy =
  17. //==============================================================================
  18. SceneColorEvent::SceneColorEvent(const SceneColorEvent& b)
  19. : Event(SCENE_COLOR, 0.0, 0.0)
  20. {
  21. *this = b;
  22. }
  23. //==============================================================================
  24. // operator= =
  25. //==============================================================================
  26. SceneColorEvent& SceneColorEvent::operator=(const SceneColorEvent& b)
  27. {
  28. Event::operator=(b);
  29. originalColor = b.originalColor;
  30. finalColor = b.finalColor;
  31. return *this;
  32. }
  33. //==============================================================================
  34. // updateSp =
  35. //==============================================================================
  36. void SceneColorEvent::updateSp(float /*prevUpdateTime*/, float crntTime)
  37. {
  38. float d = crntTime - getStartTime(); // delta
  39. float dp = d / float(getDuration()); // delta as persentage
  40. SceneSingleton::get().setAmbientColor(
  41. interpolate(originalColor, finalColor, dp));
  42. }
  43. } // end namespace