Animation.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "Base.h"
  2. #include "Animation.h"
  3. namespace gameplay
  4. {
  5. Animation::Animation(void)
  6. {
  7. }
  8. Animation::~Animation(void)
  9. {
  10. }
  11. unsigned int Animation::getTypeId(void) const
  12. {
  13. return ANIMATION_ID;
  14. }
  15. const char* Animation::getElementName(void) const
  16. {
  17. return "Animation";
  18. }
  19. void Animation::writeBinary(FILE* file)
  20. {
  21. Object::writeBinary(file);
  22. // Animation writes its ID because it is not listed in the ref table.
  23. write(getId(), file);
  24. write(_channels.size(), file);
  25. for (std::vector<AnimationChannel*>::iterator i = _channels.begin(); i != _channels.end(); ++i)
  26. {
  27. (*i)->writeBinary(file);
  28. }
  29. }
  30. void Animation::writeText(FILE* file)
  31. {
  32. fprintElementStart(file);
  33. if (_channels.size() > 0 )
  34. {
  35. for (std::vector<AnimationChannel*>::iterator i = _channels.begin(); i != _channels.end(); ++i)
  36. {
  37. (*i)->writeText(file);
  38. }
  39. }
  40. fprintElementEnd(file);
  41. }
  42. void Animation::add(AnimationChannel* animationChannel)
  43. {
  44. _channels.push_back(animationChannel);
  45. }
  46. unsigned int Animation::getAnimationChannelCount() const
  47. {
  48. return _channels.size();
  49. }
  50. AnimationChannel* Animation::getAnimationChannel(unsigned int index) const
  51. {
  52. return _channels[index];
  53. }
  54. }