PolyTween.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * PolyTween.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 7/7/08.
  6. * Copyright 2008 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package BasicTypes
  10. #pragma once
  11. #include "PolyString.h"
  12. #include "PolyGlobals.h"
  13. #include "PolyEventDispatcher.h"
  14. #include "PolyCoreServices.h"
  15. #include "PolyBezierCurve.h"
  16. #include "PolyQuaternionCurve.h"
  17. namespace Polycode {
  18. class Timer;
  19. class _PolyExport Tween : public EventDispatcher {
  20. public:
  21. Tween(float *target, int easeType, float startVal, float endVal, float time, bool repeat=false);
  22. ~Tween();
  23. void handleEvent(Event *event);
  24. float interpolateTween();
  25. virtual void updateCustomTween() {}
  26. void doOnComplete();
  27. void Pause(bool pauseVal);
  28. void Reset();
  29. static const int EASE_NONE = 0;
  30. static const int EASE_IN_QUAD = 1;
  31. static const int EASE_OUT_QUAD = 2;
  32. static const int EASE_INOUT_QUAD = 3;
  33. static const int EASE_IN_CUBIC= 4;
  34. static const int EASE_OUT_CUBIC= 5;
  35. static const int EASE_INOUT_CUBIC= 6;
  36. static const int EASE_IN_QUART= 7;
  37. static const int EASE_OUT_QUART= 8;
  38. static const int EASE_INOUT_QUART= 9;
  39. static const int EASE_IN_QUINT= 10;
  40. static const int EASE_OUT_QUINT= 11;
  41. static const int EASE_INOUT_QUINT= 12;
  42. static const int EASE_IN_SINE= 13;
  43. static const int EASE_OUT_SINE= 14;
  44. static const int EASE_INOUT_SINE= 15;
  45. static const int EASE_IN_EXPO= 16;
  46. static const int EASE_OUT_EXPO= 17;
  47. static const int EASE_INOUT_EXPO= 18;
  48. static const int EASE_IN_CIRC= 19;
  49. static const int EASE_OUT_CIRC= 20;
  50. static const int EASE_INOUT_CIRC= 21;
  51. static const int EASE_IN_BOUNCE= 22;
  52. static const int EASE_OUT_BOUNCE = 23;
  53. static const int EASE_INOUT_BOUNCE = 24;
  54. bool isComplete();
  55. bool repeat;
  56. void setSpeed(float speed);
  57. protected:
  58. int easeType;
  59. bool complete;
  60. float endVal;
  61. float cVal;
  62. float startVal;
  63. float actEndTime;
  64. float endTime;
  65. float *targetVal;
  66. float localTargetVal;
  67. float tweenTime;
  68. Timer *tweenTimer;
  69. };
  70. class _PolyExport BezierPathTween : public Tween {
  71. public:
  72. BezierPathTween(Vector3 *target, BezierCurve *curve, int easeType, float time, bool repeat=false);
  73. ~BezierPathTween();
  74. void updateCustomTween();
  75. protected:
  76. float pathValue;
  77. Tween *pathTween;
  78. BezierCurve *curve;
  79. Vector3 *target;
  80. };
  81. class _PolyExport QuaternionTween : public Tween {
  82. public:
  83. QuaternionTween(Quaternion *target, BezierCurve *wCurve, BezierCurve *xCurve, BezierCurve *yCurve,
  84. BezierCurve *zCurve, int easeType, float time, bool repeat=false);
  85. ~QuaternionTween();
  86. void updateCustomTween();
  87. private:
  88. float pathValue;
  89. Tween *pathTween;
  90. QuaternionCurve *quatCurve;
  91. Quaternion *target;
  92. };
  93. }