AnimationChannel.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef ANIMATIONCHANNEL_H_
  2. #define ANIMATIONCHANNEL_H_
  3. #include "Object.h"
  4. namespace gameplay
  5. {
  6. class AnimationChannel : public Object
  7. {
  8. public:
  9. enum InterpolationTypes
  10. {
  11. LINEAR = 1,
  12. BEZIER = 2,
  13. CARDINAL = 3,
  14. HERMITE = 4,
  15. BSPLINE = 5,
  16. STEP = 6
  17. };
  18. /**
  19. * Constructor.
  20. */
  21. AnimationChannel(void);
  22. /**
  23. * Destructor.
  24. */
  25. virtual ~AnimationChannel(void);
  26. virtual unsigned int getTypeId(void) const;
  27. virtual const char* getElementName(void) const;
  28. virtual void writeBinary(FILE* file);
  29. virtual void writeText(FILE* file);
  30. const std::string& getTargetId() const;
  31. /**
  32. * Sets the interpolation type of the entire animation channel.
  33. *
  34. * @param interpolation The interpolation type from InterpolationTypes enum.
  35. */
  36. void setInterpolation(unsigned int interpolation);
  37. void setTargetId(const std::string& str);
  38. void setTargetAttribute(unsigned int attrib);
  39. void setKeyTimes(const std::vector<float>& values);
  40. void setKeyValues(const std::vector<float>& values);
  41. void setTangentsIn(const std::vector<float>& values);
  42. void setTangentsOut(const std::vector<float>& values);
  43. void setInterpolations(const std::vector<unsigned int>& values);
  44. unsigned int getTargetAttribute() const;
  45. const std::vector<float>& getKeyValues() const;
  46. const std::vector<float>& getKeyTimes() const;
  47. const std::vector<float>& getTangentsIn() const;
  48. const std::vector<float>& getTangentsOut() const;
  49. const std::vector<unsigned int>& getInterpolationTypes() const;
  50. void removeDuplicates();
  51. void convertToQuaternion();
  52. void convertToTransform();
  53. /**
  54. * Returns the interpolation type value for the given string or zero if not valid.
  55. * Example: "LINEAR" returns AnimationChannel::LINEAR
  56. *
  57. * @param str Interpolation such as "LINEAR" or "BSPLINE".
  58. *
  59. * @return A value from InterpolationTypes enum or zero if not valid.
  60. */
  61. static unsigned int getInterpolationType(const char* str);
  62. private:
  63. void deleteRange(size_t begin, size_t end);
  64. private:
  65. std::string _targetId;
  66. unsigned int _targetAttrib;
  67. std::vector<float> _keytimes;
  68. std::vector<float> _keyValues;
  69. std::vector<float> _tangentsIn;
  70. std::vector<float> _tangentsOut;
  71. std::vector<unsigned int> _interpolations;
  72. };
  73. }
  74. #endif