source: NonGTP/FCollada/FCDocument/FCDAnimationChannel.h @ 964

Revision 964, 5.4 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[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 FCDAnimationChannel.h
14        This file contains the FCDAnimationChannel class.
15*/
16
17#ifndef _FCD_ANIMATION_CHANNEL_H_
18#define _FCD_ANIMATION_CHANNEL_H_
19
20#include "FCDocument/FCDObject.h"
21
22class FCDocument;
23class FCDAnimated;
24class FCDAnimation;
25class FCDAnimationCurve;
26
27/** A dynamically-sized array of animation curves. */
28typedef vector<FCDAnimationCurve*> FCDAnimationCurveList;
29
30/**
31        A COLLADA animation channel.
32        Each animation channel holds the animation curves for one animatable element,
33        such as a single floating-point value, a 3D vector or a matrix.
34
35        @see FCDAnimated
36        @ingroup FCDocument
37*/
38class FCOLLADA_EXPORT FCDAnimationChannel : public FCDObject
39{
40private:
41        DeclareObjectType;
42        FCDAnimation* parent;
43
44        // Channel target
45        string targetPointer;
46        string targetQualifier;
47
48        // Maya-specific: the driver for this/these curves
49        string driverPointer;
50        int32 driverQualifier;
51
52        FCDAnimationCurveList curves;
53
54public:
55        /** Constructor: do not use directly.
56                Instead, call the FCDAnimation::AddChannel function.
57                @param document The COLLADA document that owns the animation channel.
58                @param parent The animation sub-tree that contains the animation channel. */
59        FCDAnimationChannel(FCDocument* document, FCDAnimation* parent);
60
61        /** Destructor: do not use directly.
62                Instead, call the FCDAnimation::ReleaseChannel function. */
63        virtual ~FCDAnimationChannel();
64       
65        /** Retrieves the animation sub-tree that contains the animation channel.
66                @return The parent animation sub-tree. */
67        FCDAnimation* GetParent() { return parent; }
68        const FCDAnimation* GetParent() const { return parent; } /**< See above. */
69
70        /** Retrieves the list of animation curves contained within the channel.
71                @return The list of animation curves. */
72        const FCDAnimationCurveList& GetCurves() const { return curves; }
73
74        /** Retrieves the number of animation curves contained within the channel.
75                @return The number of animation curves. */
76        size_t GetCurveCount() const { return curves.size(); }
77
78        /** Retrieves an animation curve contained within the channel.
79                @param index The index of the animation curve.
80                @return The animation curve at the given index. This pointer will be NULL
81                        if the index is out-of-bounds. */
82        FCDAnimationCurve* GetCurve(size_t index) { FUAssert(index < GetCurveCount(), return NULL); return curves.at(index); }
83        const FCDAnimationCurve* GetCurve(size_t index) const { FUAssert(index < GetCurveCount(), return NULL); return curves.at(index); } /**< See above. */
84
85        /** Adds a new animation curve to this animation channel.
86                @return The new animation curve. */
87        FCDAnimationCurve* AddCurve();
88
89        /** Releases an animation curve contained within this channel.
90                @todo This function is not yet implemented, as it requires
91                a lot more memory management than FCollada currently does.
92                @param curve The animation curve to release. */
93        void ReleaseCurve(FCDAnimationCurve* curve);
94
95        /** [INTERNAL] Retrieves the target pointer prefix for this animation channel.
96                This function is used during the import of a COLLADA document to match the
97                target pointer prefixes with the animated elements.
98                @return The target pointer prefix. */
99        const string& GetTargetPointer() const { return targetPointer; }
100
101        /** [INTERNAL] Retrieves the target qualifier for this animation channel.
102                This function is used during the import of a COLLADA document.
103                Where there is a target qualifier, there should be only one curve contained by the channel.
104                @return The target qualifier. This value may be the empty string if the channel
105                targets all the values targeted by the target pointer prefix. */
106        const string& GetTargetQualifier() const { return targetQualifier; }
107
108        /** [INTERNAL] Enforces the tarrget pointer prefix for the animation channel.
109                This function is used during the export of a COLLADA document.
110                @param p The new target pointer prefix. */
111        void SetTargetPointer(const string& p) { targetPointer = p; }
112
113        /** [INTERNAL] Considers the given animated element as the driver for this animation channel.
114                @param animated An animated element.
115                @return Whether the animated element is in fact the driver for the animation channel. */
116        bool LinkDriver(FCDAnimated* animated);
117
118        /** [INTERNAL] Verifies that if a driver is used by this channel, then it was found during
119                the import of the animated elements.
120                @return The status of the verification. */
121        FUStatus CheckDriver();
122
123        /** [INTERNAL] Reads in the animation channel from a given COLLADA XML tree node.
124                @param channelNode The COLLADA XML tree node.
125                @return The status of the import. If the status is not successful,
126                        it may be dangerous to extract information from the animation channel. */
127        FUStatus LoadFromXML(xmlNode* channelNode);
128
129        /** [INTERNAL] Writes out the animation channel to the given COLLADA XML tree node.
130                @param parentNode The COLLADA XML parent node in which to insert the animation channel.
131                @return The created element XML tree node. */
132        void WriteToXML(xmlNode* parentNode) const;
133};
134
135#endif // _FCD_ANIMATION_CHANNEL_H_
Note: See TracBrowser for help on using the repository browser.