AnimationController.pkg 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. $#include "Graphics/AnimationController.h"
  2. struct AnimationControl
  3. {
  4. AnimationControl();
  5. ~AnimationControl();
  6. String name_ @ name;
  7. StringHash hash_ @ hash;
  8. float speed_ @ speed;
  9. float targetWeight_ @ targetWeight;
  10. float fadeTime_ @ fadeTime ;
  11. float autoFadeTime_ @ autoFadeTime;
  12. bool removeOnCompletion_ @ removeOnCompletion;
  13. };
  14. class AnimationController : public Component
  15. {
  16. bool Play(const String name, unsigned char layer, bool looped, float fadeInTime = 0.0f);
  17. bool PlayExclusive(const String name, unsigned char layer, bool looped, float fadeTime = 0.0f);
  18. bool Stop(const String name, float fadeOutTime = 0.0f);
  19. void StopLayer(unsigned char layer, float fadeOutTime = 0.0f);
  20. void StopAll(float fadeTime = 0.0f);
  21. bool Fade(const String name, float targetWeight, float fadeTime);
  22. bool FadeOthers(const String name, float targetWeight, float fadeTime);
  23. bool SetLayer(const String name, unsigned char layer);
  24. bool SetStartBone(const String name, const String startBoneName);
  25. bool SetTime(const String name, float time);
  26. bool SetWeight(const String name, float weight);
  27. bool SetLooped(const String name, bool enable);
  28. bool SetBlendMode(const String name, AnimationBlendMode mode);
  29. bool SetSpeed(const String name, float speed);
  30. bool SetAutoFade(const String name, float fadeOutTime);
  31. bool SetRemoveOnCompletion(const String name, bool removeOnCompletion);
  32. bool IsPlaying(const String name) const;
  33. bool IsPlaying(unsigned char layer) const;
  34. bool IsFadingIn(const String name) const;
  35. bool IsFadingOut(const String name) const;
  36. bool IsAtEnd(const String name) const;
  37. unsigned char GetLayer(const String name) const;
  38. Bone* GetStartBone(const String name) const;
  39. const String GetStartBoneName(const String name) const;
  40. float GetTime(const String name) const;
  41. float GetWeight(const String name) const;
  42. bool IsLooped(const String name) const;
  43. AnimationBlendMode GetBlendMode(const String name) const;
  44. float GetLength(const String name) const;
  45. float GetSpeed(const String name) const;
  46. float GetFadeTarget(const String name) const;
  47. float GetFadeTime(const String name) const;
  48. float GetAutoFade(const String name) const;
  49. bool GetRemoveOnCompletion(const String name) const;
  50. AnimationState* GetAnimationState(const String name) const;
  51. AnimationState* GetAnimationState(StringHash nameHash) const;
  52. tolua_outside const AnimationControl* AnimationControllerGetAnimation @ GetAnimation(unsigned index) const;
  53. tolua_outside unsigned AnimationControllerGetNumAnimations @ GetNumAnimations() const;
  54. };
  55. ${
  56. static const AnimationControl* AnimationControllerGetAnimation(const AnimationController* controller, unsigned index)
  57. {
  58. if (!controller)
  59. return (const AnimationControl*)0;
  60. const Vector<AnimationControl>& animations = controller->GetAnimations();
  61. return (index < animations.Size()) ? &animations[index] : (const AnimationControl*)0;
  62. }
  63. static unsigned AnimationControllerGetNumAnimations(const AnimationController* controller)
  64. {
  65. if (!controller)
  66. return 0;
  67. return controller->GetAnimations().Size();
  68. }
  69. $}