[964] | 1 | /*
|
---|
| 2 | Copyright (C) 2005-2006 Feeling Software Inc.
|
---|
| 3 | MIT License: http://www.opensource.org/licenses/mit-license.php
|
---|
| 4 | */
|
---|
| 5 | /*
|
---|
| 6 | Based on the FS Import classes:
|
---|
| 7 | Copyright (C) 2005-2006 Feeling Software Inc
|
---|
| 8 | Copyright (C) 2005-2006 Autodesk Media Entertainment
|
---|
| 9 | MIT License: http://www.opensource.org/licenses/mit-license.php
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | @file FCDAnimation.h
|
---|
| 14 | This file contains the FCDAnimation class.
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 | #ifndef _FCD_ANIMATION_H_
|
---|
| 18 | #define _FCD_ANIMATION_H_
|
---|
| 19 |
|
---|
| 20 | #include "FUtils/FUXmlNodeIdPair.h"
|
---|
| 21 | #include "FCDocument/FCDEntity.h"
|
---|
| 22 |
|
---|
| 23 | class FCDocument;
|
---|
| 24 | class FCDAnimated;
|
---|
| 25 | class FCDAnimation;
|
---|
| 26 | class FCDAnimationChannel;
|
---|
| 27 | class FCDAnimationCurve;
|
---|
| 28 |
|
---|
| 29 | typedef vector<FCDAnimation*> FCDAnimationList; /**< A dynamically-sized array of animation entities. */
|
---|
| 30 | typedef vector<FCDAnimationChannel*> FCDAnimationChannelList; /**< A dynamically-sized array of animation channels. */
|
---|
| 31 | typedef vector<FCDAnimationCurve*> FCDAnimationCurveList; /**< A dynamically-sized array of animation curves. */
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | A COLLADA animation entity.
|
---|
| 35 | An animation entity contains a list of child animation entities,
|
---|
| 36 | in order to form a tree of animation entities.
|
---|
| 37 | It also hold a list of animation channels, which hold the information
|
---|
| 38 | to generate animation curves.
|
---|
| 39 |
|
---|
| 40 | In other words, the animation entity is a structural class
|
---|
| 41 | used to group animation channels hierarchically.
|
---|
| 42 |
|
---|
| 43 | @ingroup FCDocument
|
---|
| 44 | */
|
---|
| 45 | class FCOLLADA_EXPORT FCDAnimation : public FCDEntity
|
---|
| 46 | {
|
---|
| 47 | private:
|
---|
| 48 | DeclareObjectType;
|
---|
| 49 | FCDAnimationChannelList channels;
|
---|
| 50 | FUXmlNodeIdPairList childNodes;
|
---|
| 51 | FCDAnimationList children;
|
---|
| 52 |
|
---|
| 53 | public:
|
---|
| 54 | /** Constructor: do not use directly.
|
---|
| 55 | Instead, use the FCDLibrary::AddEntity function
|
---|
| 56 | or the AddChild function, depending on the
|
---|
| 57 | hierarchical level of the animation entity.
|
---|
| 58 | @param document The COLLADA document that owns the animation entity. */
|
---|
| 59 | FCDAnimation(FCDocument* document);
|
---|
| 60 |
|
---|
| 61 | /** Destructor: do not use directly.
|
---|
| 62 | Instead, use the FCDLibrary::ReleaseEntity function
|
---|
| 63 | or the ReleaseChild function, depending on the
|
---|
| 64 | hierarchical level of the animation entity.*/
|
---|
| 65 | virtual ~FCDAnimation();
|
---|
| 66 |
|
---|
| 67 | /** Retrieves the entity class type.
|
---|
| 68 | This function is a part of the FCDEntity interface.
|
---|
| 69 | @return The entity class type: ANIMATION. */
|
---|
| 70 | virtual Type GetType() const { return ANIMATION; }
|
---|
| 71 |
|
---|
| 72 | /** Retrieves the entity with the given COLLADA id.
|
---|
| 73 | This function will look through the local sub-tree of animations
|
---|
| 74 | for the given COLLADA id.
|
---|
| 75 | @param daeId A COLLADA id.
|
---|
| 76 | @return The animation entity that matches the COLLADA id. This pointer
|
---|
| 77 | will be NULL if there are no animation entities that matches the COLLADA id. */
|
---|
| 78 | virtual FCDEntity* FindDaeId(const string& daeId);
|
---|
| 79 |
|
---|
| 80 | /** Retrieves the number of animation entity sub-trees contained
|
---|
| 81 | by this animation entity tree.
|
---|
| 82 | @return The number of animation entity sub-trees. */
|
---|
| 83 | inline size_t GetChildCount() const { return children.size(); }
|
---|
| 84 |
|
---|
| 85 | /** Retrieves an animation entity sub-tree contained by this
|
---|
| 86 | animation entity tree.
|
---|
| 87 | @param index The index of the sub-tree.
|
---|
| 88 | @return The animation entity sub-tree at the given index. This pointer will
|
---|
| 89 | be NULL if the index is out-of-bounds. */
|
---|
| 90 | inline FCDAnimation* GetChild(size_t index) { FUAssert(index < GetChildCount(), return NULL); return children.at(index); }
|
---|
| 91 | inline const FCDAnimation* GetChild(size_t index) const { FUAssert(index < GetChildCount(), return NULL); return children.at(index); } /**< See above. */
|
---|
| 92 |
|
---|
| 93 | /** Creates a new animation entity sub-tree contained within this animation entity tree.
|
---|
| 94 | @return The new animation sub-tree. */
|
---|
| 95 | inline FCDAnimation* AddChild();
|
---|
| 96 |
|
---|
| 97 | /** Releases an animation entity sub-tree contained by this animation entity tree.
|
---|
| 98 | @param animation The animation entity the release. */
|
---|
| 99 | inline void ReleaseChild(FCDAnimation* animation);
|
---|
| 100 |
|
---|
| 101 | /** Retrieves the animation channels that target the given COLLADA target pointer.
|
---|
| 102 | @param pointer A COLLADA target pointer.
|
---|
| 103 | @param targetChannels A list of animation channels to fill in.
|
---|
| 104 | This list is not cleared. */
|
---|
| 105 | void FindAnimationChannels(const string& pointer, FCDAnimationChannelList& targetChannels);
|
---|
| 106 |
|
---|
| 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 |
|
---|
| 111 | /** Retrieves an animation channel contained by this animation entity.
|
---|
| 112 | @param index The index of the channel.
|
---|
| 113 | @return The channel at the given index. This pointer will be NULL
|
---|
| 114 | if the index is out-of-bounds. */
|
---|
| 115 | FCDAnimationChannel* GetChannel(size_t index) { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); }
|
---|
| 116 | const FCDAnimationChannel* GetChannel(size_t index) const { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); } /**< See above. */
|
---|
| 117 |
|
---|
| 118 | /** Adds a new animation channel to this animation entity.
|
---|
| 119 | @return The new animation channel. */
|
---|
| 120 | FCDAnimationChannel* AddChannel();
|
---|
| 121 |
|
---|
| 122 | /** Releases an animation channel contained within this animation entity.
|
---|
| 123 | @param channel The animation channel to release. */
|
---|
| 124 | void ReleaseChannel(FCDAnimationChannel* channel);
|
---|
| 125 |
|
---|
| 126 | /** Retrieves all the curves created in the subtree of this animation element.
|
---|
| 127 | @param curves A list of animation curves to fill in.
|
---|
| 128 | This list is not cleared. */
|
---|
| 129 | void GetCurves(FCDAnimationCurveList& curves);
|
---|
| 130 |
|
---|
| 131 | /** [INTERNAL] Links the animation sub-tree with the other entities within the document.
|
---|
| 132 | This function is used at the end of the import of a document to verify that all the
|
---|
| 133 | necessary drivers were found.
|
---|
| 134 | @return The status of the linkage. */
|
---|
| 135 | FUStatus Link();
|
---|
| 136 |
|
---|
| 137 | /** [INTERNAL] Reads in the animation entity from a given COLLADA XML tree node.
|
---|
| 138 | @param animationNode The COLLADA XML tree node.
|
---|
| 139 | @return The status of the import. If the status is not successful,
|
---|
| 140 | it may be dangerous to extract information from the animation. */
|
---|
| 141 | virtual FUStatus LoadFromXML(xmlNode* animationNode);
|
---|
| 142 |
|
---|
| 143 | /** [INTERNAL] Writes out the \<animation\> element to the given COLLADA XML tree node.
|
---|
| 144 | @param parentNode The COLLADA XML parent node in which to insert the animation tree.
|
---|
| 145 | @return The created element XML tree node. */
|
---|
| 146 | virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
|
---|
| 147 |
|
---|
| 148 | /** [INTERNAL] Retrieves the child source or sampler.
|
---|
| 149 | This function should only be used by the FCDAnimationChannel class
|
---|
| 150 | during the import of a COLLADA document.
|
---|
| 151 | @param id The COLLADA id of a sampler or a source.
|
---|
| 152 | @return The XML node tree for the sampler or the source. This pointer
|
---|
| 153 | will be NULL if there are no child nodes for the given id. */
|
---|
| 154 | xmlNode* FindChildById(const string& id);
|
---|
| 155 |
|
---|
| 156 | /** [INTERNAL] Links a possible driver with the animation curves contained
|
---|
| 157 | within the subtree of this animation element.
|
---|
| 158 | This function is used during the import of a COLLADA document.
|
---|
| 159 | @param animated The driver animated value.
|
---|
| 160 | @return Whether any linkage was done. */
|
---|
| 161 | bool LinkDriver(FCDAnimated* animated);
|
---|
| 162 | };
|
---|
| 163 |
|
---|
| 164 | #endif // _FCD_ANIMATION_H_
|
---|