PolyTween.h 2.6 KB

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