ObjectAnimation.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // Copyright (c) 2008-2014 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "AttributeAnimationDefs.h"
  24. #include "Resource.h"
  25. namespace Urho3D
  26. {
  27. class AttributeAnimation;
  28. class AttributeAnimationInfo;
  29. /// Object animation class, an object animation include one or more attribute animations and theirs wrap mode and speed for an Animatable object.
  30. class URHO3D_API ObjectAnimation : public Resource
  31. {
  32. OBJECT(ObjectAnimation );
  33. public:
  34. /// Construct.
  35. ObjectAnimation(Context* context);
  36. /// Destruct.
  37. virtual ~ObjectAnimation();
  38. /// Register object factory.
  39. static void RegisterObject(Context* context);
  40. /// Load resource. Return true if successful.
  41. virtual bool Load(Deserializer& source);
  42. /// Save resource. Return true if successful.
  43. virtual bool Save(Serializer& dest) const;
  44. /// Load from XML data. Return true if successful.
  45. bool LoadXML(const XMLElement& source);
  46. /// Save as XML data. Return true if successful.
  47. bool SaveXML(XMLElement& dest) const;
  48. /// Add attribute animation.
  49. void AddAttributeAnimation(const String& name, AttributeAnimation* attributeAnimation, WrapMode wrapMode = WM_LOOP, float speed = 1.0f);
  50. /// Remove attribute animation.
  51. void RemoveAttributeAnimation(const String& name);
  52. /// Remove attribute animation.
  53. void RemoveAttributeAnimation(AttributeAnimation* attributeAnimation);
  54. /// Return attribute animation by name.
  55. AttributeAnimation* GetAttributeAnimation(const String& name) const;
  56. /// Return attribute animation wrap mode by name.
  57. WrapMode GetAttributeAnimationWrapMode(const String& name) const;
  58. /// Return attribute animation speed by name.
  59. float GetAttributeAnimationSpeed(const String& name) const;
  60. /// Return all attribute animations infos.
  61. const HashMap<String, SharedPtr<AttributeAnimationInfo> >& GetAttributeAnimationInfos() const { return attributeAnimationInfos_; }
  62. private:
  63. /// Return attribute animation info by name.
  64. AttributeAnimationInfo* GetAttributeAnimationInfo(const String& name) const;
  65. /// Name to attribute animation info mapping.
  66. HashMap<String, SharedPtr<AttributeAnimationInfo> > attributeAnimationInfos_;
  67. };
  68. }