BsAnimationCurve.h 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Animation
  8. * @{
  9. */
  10. template <class T>
  11. struct TKeyframe
  12. {
  13. T value;
  14. T inTangent;
  15. T outTangent;
  16. float time;
  17. };
  18. template <class T>
  19. class BS_CORE_EXPORT TAnimationCurve
  20. {
  21. public:
  22. typedef TKeyframe<T> KeyFrame;
  23. TAnimationCurve(const Vector<KeyFrame>& keyframes);
  24. T evaluate(const AnimationInstanceData& animInstance, bool loop = true);
  25. private:
  26. void findKeys(const AnimationInstanceData& animInstance, UINT32& leftKey, UINT32& rightKey);
  27. void findKeys(float time, UINT32& leftKey, UINT32& rightKey);
  28. static const UINT32 CACHE_LOOKAHEAD;
  29. Vector<KeyFrame> mKeyframes;
  30. float mStart;
  31. float mEnd;
  32. float mLength;
  33. };
  34. /** @} */
  35. }