AnimationTarget.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef ANIMATIONTARGET_H_
  2. #define ANIMATIONTARGET_H_
  3. #include "Curve.h"
  4. #include "AnimationController.h"
  5. namespace gameplay
  6. {
  7. class Animation;
  8. class AnimationValue;
  9. /**
  10. * Defines an interface allowing animation to target
  11. * an object for changing its animation properties.
  12. */
  13. class AnimationTarget
  14. {
  15. friend class Animation;
  16. friend class AnimationClip;
  17. friend class AnimationController;
  18. public:
  19. /**
  20. * Abstract method to return the property component count of the given property ID on the AnimationTarget.
  21. *
  22. * @param propertyId The ID of the property on the AnimationTarget to obtain the component count for.
  23. *
  24. * @return The property component count of the given property.
  25. */
  26. virtual unsigned int getAnimationPropertyComponentCount(int propertyId) const = 0;
  27. /**
  28. * Abstract method for getting the animation property value for the given property ID on the AnimationTarget.
  29. *
  30. * @param propertyId The ID of the property on the AnimationTarget to get the animation property value for.
  31. * @param value The container to get the animation property value in.
  32. */
  33. virtual void getAnimationPropertyValue(int propertyId, AnimationValue* value) = 0;
  34. /**
  35. * Abstract method for setting the animation property value for the given property ID on the AnimationTarget.
  36. *
  37. * @param propertyId The ID of the property on the AnimationTarget to set the animation property value on.
  38. * @param value The container to set the animation property value in.
  39. */
  40. virtual void setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight = 1.0f) = 0;
  41. protected:
  42. enum TargetType
  43. {
  44. SCALAR,
  45. TRANSFORM
  46. };
  47. /**
  48. * Constructor.
  49. */
  50. AnimationTarget();
  51. /**
  52. * Destructor.
  53. */
  54. virtual ~AnimationTarget();
  55. void addChannel(Animation::Channel* animation);
  56. TargetType _targetType; // The type of target this is.
  57. char _animationPropertyBitFlag; // Bit flag used to indicate which properties on the AnimationTarget are currently animating.
  58. private:
  59. /**
  60. * Constructor.
  61. */
  62. AnimationTarget(const AnimationTarget& copy);
  63. /**
  64. * Gets the TargetType's property ID value for the specified property ID string.
  65. *
  66. * @param type The TargetType of the AnimationTarget.
  67. * @param propertyIdStr The property ID string.
  68. * @return The property ID value for teh property ID string; -1 if the propertyIdStr does not exist
  69. * for the TargetType.
  70. */
  71. static int getPropertyId(TargetType type, const char* propertyIdStr);
  72. std::vector<Animation::Channel*>* _animationChannels; // Collection of all animation channels that target the AnimationTarget
  73. };
  74. }
  75. #endif