BsAnimationUtility.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "BsAnimationCurve.h"
  6. namespace bs
  7. {
  8. /** @addtogroup Animation
  9. * @{
  10. */
  11. /** Helper class for dealing with animations, animation clips and curves. */
  12. class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Animation) AnimationUtility
  13. {
  14. public:
  15. /**
  16. * Wraps or clamps the provided time value between the provided range.
  17. *
  18. * @param[in,out] time Time value to wrap/clamp.
  19. * @param[in] start Start of the range.
  20. * @param[in] end End of the range.
  21. * @param[in] loop If true the value will be wrapped, otherwise clamped to range.
  22. */
  23. static void wrapTime(float& time, float start, float end, bool loop);
  24. /** Converts a curve in euler angles (in degrees) into a curve using quaternions. */
  25. BS_SCRIPT_EXPORT(n:EulerToQuaternionCurve)
  26. static SPtr<TAnimationCurve<Quaternion>> eulerToQuaternionCurve(const SPtr<TAnimationCurve<Vector3>>& eulerCurve);
  27. /** Converts a curve in quaternions into a curve using euler angles (in degrees). */
  28. BS_SCRIPT_EXPORT(n:QuaternionToEulerCurve)
  29. static SPtr<TAnimationCurve<Vector3>> quaternionToEulerCurve(const SPtr<TAnimationCurve<Quaternion>>& quatCurve);
  30. /** Splits a Vector3 curve into three individual curves, one for each component. */
  31. BS_SCRIPT_EXPORT(n:SplitCurve)
  32. static Vector<SPtr<TAnimationCurve<float>>> splitCurve(const SPtr<TAnimationCurve<Vector3>>& compoundCurve);
  33. /** Combines three single component curves into a Vector3 curve. */
  34. BS_SCRIPT_EXPORT(n:CombineCurve)
  35. static SPtr<TAnimationCurve<Vector3>> combineCurve(const Vector<SPtr<TAnimationCurve<float>>>& curveComponents);
  36. /** Scales all curve values and tangents by the specified scale factor. */
  37. template<class T>
  38. static TAnimationCurve<T> scaleCurve(const TAnimationCurve<T>& curve, float factor);
  39. /** Adds a time offset to all keyframes in the provided curve. */
  40. template<class T>
  41. static TAnimationCurve<T> offsetCurve(const TAnimationCurve<T>& curve, float offset);
  42. };
  43. /** @} */
  44. }