AnimationTarget.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. class NodeCloneContext;
  10. /**
  11. * Defines an interface allowing animation to target
  12. * an object for changing its animation properties.
  13. */
  14. class AnimationTarget
  15. {
  16. friend class Animation;
  17. friend class AnimationClip;
  18. friend class AnimationController;
  19. public:
  20. /**
  21. * Abstract method to return the property component count of the given property ID on the AnimationTarget.
  22. *
  23. * @param propertyId The ID of the property on the AnimationTarget to obtain the component count for.
  24. *
  25. * @return The property component count of the given property.
  26. */
  27. virtual unsigned int getAnimationPropertyComponentCount(int propertyId) const = 0;
  28. /**
  29. * Abstract method for getting the animation property value for the given property ID on the AnimationTarget.
  30. *
  31. * @param propertyId The ID of the property on the AnimationTarget to get the animation property value for.
  32. * @param value The container to get the animation property value in.
  33. */
  34. virtual void getAnimationPropertyValue(int propertyId, AnimationValue* value) = 0;
  35. /**
  36. * Abstract method for setting the animation property value for the given property ID on the AnimationTarget.
  37. *
  38. * @param propertyId The ID of the property on the AnimationTarget to set the animation property value on.
  39. * @param value The container to set the animation property value in.
  40. * @param blendWeight The blend weight.
  41. */
  42. virtual void setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight = 1.0f) = 0;
  43. protected:
  44. enum TargetType
  45. {
  46. SCALAR,
  47. TRANSFORM
  48. };
  49. /**
  50. * Constructor.
  51. */
  52. AnimationTarget();
  53. /**
  54. * Destructor.
  55. */
  56. virtual ~AnimationTarget();
  57. /**
  58. * Adds the given animation channel to this animation target.
  59. *
  60. * @param channel The animation channel to add.
  61. */
  62. void addChannel(Animation::Channel* channel);
  63. /**
  64. * Deletes the given animation channel from this animation target.
  65. *
  66. * @param channel The animation channel to delete.
  67. */
  68. void deleteChannel(Animation::Channel* channel);
  69. /**
  70. * Copies data from this animation target into the given target for the purpose of cloning.
  71. *
  72. * @param target The target to copy into.
  73. * @param context The clone context.
  74. */
  75. void cloneInto(AnimationTarget* target, NodeCloneContext &context) const;
  76. TargetType _targetType; // The type of target this is.
  77. unsigned char _animationPropertyBitFlag; // Bit flag used to indicate which properties on the AnimationTarget are currently animating.
  78. private:
  79. /**
  80. * Constructor.
  81. */
  82. AnimationTarget(const AnimationTarget& copy);
  83. /**
  84. * Gets the TargetType's property ID value for the specified property ID string.
  85. *
  86. * @param type The TargetType of the AnimationTarget.
  87. * @param propertyIdStr The property ID string.
  88. * @return The property ID value for teh property ID string; -1 if the propertyIdStr does not exist
  89. * for the TargetType.
  90. */
  91. static int getPropertyId(TargetType type, const char* propertyIdStr);
  92. std::vector<Animation::Channel*>* _animationChannels; // Collection of all animation channels that target the AnimationTarget
  93. };
  94. }
  95. #endif