/Core/Dependencies/OgreCollada/FCollada/FCollada/FCDocument/FCDAnimation.h

https://bitbucket.org/barakianc/nvidia-physx-and-apex-in-gge · C Header · 156 lines · 43 code · 26 blank · 87 comment · 0 complexity · fa4fb5804c5f8d57710775fa5959fc85 MD5 · raw file

  1. /*
  2. Copyright (C) 2005-2007 Feeling Software Inc.
  3. Portions of the code are:
  4. Copyright (C) 2005-2007 Sony Computer Entertainment America
  5. MIT License: http://www.opensource.org/licenses/mit-license.php
  6. */
  7. /*
  8. Based on the FS Import classes:
  9. Copyright (C) 2005-2006 Feeling Software Inc
  10. Copyright (C) 2005-2006 Autodesk Media Entertainment
  11. MIT License: http://www.opensource.org/licenses/mit-license.php
  12. */
  13. /**
  14. @file FCDAnimation.h
  15. This file contains the FCDAnimation class.
  16. */
  17. #ifndef _FCD_ANIMATION_H_
  18. #define _FCD_ANIMATION_H_
  19. #ifndef _FCD_ENTITY_H_
  20. #include "FCDocument/FCDEntity.h"
  21. #endif // _FCD_ENTITY_H_
  22. class FCDocument;
  23. class FCDAnimated;
  24. class FCDAnimation;
  25. class FCDAnimationChannel;
  26. class FCDAnimationCurve;
  27. typedef fm::pvector<FCDAnimationChannel> FCDAnimationChannelList; /**< A dynamically-sized array of animation channels. */
  28. typedef fm::pvector<FCDAnimationCurve> FCDAnimationCurveList; /**< A dynamically-sized array of animation curves. */
  29. /**
  30. A COLLADA animation entity.
  31. An animation entity contains a list of child animation entities,
  32. in order to form a tree of animation entities.
  33. It also hold a list of animation channels, which hold the information
  34. to generate animation curves.
  35. In other words, the animation entity is a structural class
  36. used to group animation channels hierarchically.
  37. @ingroup FCDocument
  38. */
  39. class FCOLLADA_EXPORT FCDAnimation : public FCDEntity
  40. {
  41. private:
  42. DeclareObjectType(FCDEntity);
  43. // Animation hierarchy
  44. FCDAnimation* parent;
  45. DeclareParameterContainer(FCDAnimation, children, FC("Children"));
  46. // Animation sources and channels
  47. DeclareParameterContainer(FCDAnimationChannel, channels, FC("Channels"));
  48. public:
  49. /** Constructor. Do not use directly.
  50. Instead, use the FCDLibrary::AddEntity function
  51. or the AddChild function, depending on the
  52. hierarchical level of the animation entity.
  53. @param document The FCollada document that owns the animation entity.
  54. @param parent The parent animation entity. This pointer will be NULL for root animation entities. */
  55. FCDAnimation(FCDocument* document, FCDAnimation* parent = NULL);
  56. /** Destructor .*/
  57. virtual ~FCDAnimation();
  58. /** Retrieves the entity class type.
  59. This function is a part of the FCDEntity interface.
  60. @return The entity class type: ANIMATION. */
  61. virtual Type GetType() const { return ANIMATION; }
  62. /** Retrieves the parent of the animation structure.
  63. @return The animation parent. This pointer will be NULL
  64. to indicate a root-level animation structure that is
  65. contained within the animation library. */
  66. inline FCDAnimation* GetParent() { return parent; }
  67. inline const FCDAnimation* GetParent() const { return parent; } /**< See above. */
  68. /** Copies the animation tree into a clone.
  69. The clone may reside in another document.
  70. @param clone The empty clone. If this pointer is NULL, a new animation tree
  71. will be created and you will need to release the returned pointer manually.
  72. @param cloneChildren Whether to recursively clone this entity's children.
  73. @return The clone. */
  74. virtual FCDEntity* Clone(FCDEntity* clone = NULL, bool cloneChildren = false) const;
  75. /** Retrieves the entity with the given COLLADA id.
  76. This function will look through the local sub-tree of animations
  77. for the given COLLADA id.
  78. @param daeId A COLLADA id.
  79. @return The animation entity that matches the COLLADA id. This pointer
  80. will be NULL if there are no animation entities that matches the COLLADA id. */
  81. virtual FCDEntity* FindDaeId(const fm::string& daeId) { return const_cast<FCDEntity*>(const_cast<const FCDAnimation*>(this)->FindDaeId(daeId)); }
  82. virtual const FCDEntity* FindDaeId(const fm::string& daeId) const; /**< See above. */
  83. /** Retrieves the number of animation entity sub-trees contained
  84. by this animation entity tree.
  85. @return The number of animation entity sub-trees. */
  86. inline size_t GetChildrenCount() const { return children.size(); }
  87. /** Retrieves an animation entity sub-tree contained by this
  88. animation entity tree.
  89. @param index The index of the sub-tree.
  90. @return The animation entity sub-tree at the given index. This pointer will
  91. be NULL if the index is out-of-bounds. */
  92. inline FCDAnimation* GetChild(size_t index) { FUAssert(index < children.size(), return NULL); return children.at(index); }
  93. inline const FCDAnimation* GetChild(size_t index) const { FUAssert(index < children.size(), return NULL); return children.at(index); } /**< See above. */
  94. /** Creates a new animation entity sub-tree contained within this animation entity tree.
  95. @return The new animation sub-tree. */
  96. FCDAnimation* AddChild();
  97. /** Retrieves the asset information structures that affect
  98. this entity in its hierarchy.
  99. @param assets A list of asset information structures to fill in. */
  100. inline void GetHierarchicalAssets(FCDAssetList& assets) { GetHierarchicalAssets(*(FCDAssetConstList*) &assets); }
  101. virtual void GetHierarchicalAssets(FCDAssetConstList& assets) const; /**< See above. */
  102. /** Retrieves the animation channels that target the given COLLADA target pointer.
  103. @param pointer A COLLADA target pointer.
  104. @param targetChannels A list of animation channels to fill in.
  105. This list is not cleared. */
  106. void FindAnimationChannels(const fm::string& pointer, FCDAnimationChannelList& targetChannels);
  107. /** Retrieves the number of animation channels at this level within the animation tree.
  108. @return The number of animation channels. */
  109. size_t GetChannelCount() const { return channels.size(); }
  110. /** Retrieves an animation channel contained by this animation entity.
  111. @param index The index of the channel.
  112. @return The channel at the given index. This pointer will be NULL
  113. if the index is out-of-bounds. */
  114. FCDAnimationChannel* GetChannel(size_t index) { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); }
  115. const FCDAnimationChannel* GetChannel(size_t index) const { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); } /**< See above. */
  116. /** [INTERNAL] Retrieves the channels' list
  117. @return The list of channels */
  118. DEPRECATED(3.05A, GetChannelCount and GetChannel(index)) void GetChannels() const {}
  119. /** Adds a new animation channel to this animation entity.
  120. @return The new animation channel. */
  121. FCDAnimationChannel* AddChannel();
  122. /** Retrieves all the curves created in the subtree of this animation element.
  123. @param curves A list of animation curves to fill in.
  124. This list is not cleared. */
  125. void GetCurves(FCDAnimationCurveList& curves);
  126. };
  127. #endif // _FCD_ANIMATION_H_