Animation.pkg 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. $#include "Graphics/Animation.h"
  2. static const unsigned char CHANNEL_POSITION;
  3. static const unsigned char CHANNEL_ROTATION;
  4. static const unsigned char CHANNEL_SCALE;
  5. struct AnimationKeyFrame
  6. {
  7. float time_ @ time;
  8. Vector3 position_ @ position;
  9. Quaternion rotation_ @ rotation;
  10. Vector3 scale_ @ scale;
  11. };
  12. struct AnimationTrack
  13. {
  14. void SetKeyFrame(unsigned index, const AnimationKeyFrame& keyFrame);
  15. void AddKeyFrame(const AnimationKeyFrame& keyFrame);
  16. void InsertKeyFrame(unsigned index, const AnimationKeyFrame& keyFrame);
  17. void RemoveKeyFrame(unsigned index);
  18. void RemoveAllKeyFrames();
  19. AnimationKeyFrame* GetKeyFrame(unsigned index);
  20. unsigned GetNumKeyFrames() const { return keyFrames_.Size(); }
  21. const String name_ @ name;
  22. const StringHash nameHash_ @ nameHash;
  23. unsigned char channelMask_ @ channelMask;
  24. Vector<AnimationKeyFrame> keyFrames_ @ keyFrames;
  25. tolua_readonly tolua_property__get_set unsigned numKeyFrames;
  26. };
  27. struct AnimationTriggerPoint
  28. {
  29. AnimationTriggerPoint();
  30. float time_ @ time;
  31. Variant data_ @ data;
  32. };
  33. class Animation : public Resource
  34. {
  35. void SetAnimationName(const String name);
  36. void SetLength(float length);
  37. AnimationTrack* CreateTrack(const String name);
  38. bool RemoveTrack(const String name);
  39. void RemoveAllTracks();
  40. void SetTrigger(unsigned index, const AnimationTriggerPoint& trigger);
  41. void AddTrigger(const AnimationTriggerPoint& trigger);
  42. void AddTrigger(float time, bool timeIsNormalized, const Variant& data);
  43. void RemoveTrigger(unsigned index);
  44. void RemoveAllTriggers();
  45. const String GetAnimationName() const;
  46. float GetLength() const;
  47. unsigned GetNumTracks() const;
  48. AnimationTrack* GetTrack(const String name);
  49. AnimationTrack* GetTrack(StringHash nameHash);
  50. unsigned GetNumTriggers() const;
  51. AnimationTriggerPoint* GetTrigger(unsigned index);
  52. tolua_property__get_set String animationName;
  53. tolua_property__get_set float length;
  54. tolua_readonly tolua_property__get_set unsigned numTracks;
  55. tolua_readonly tolua_property__get_set unsigned numTriggers;
  56. };