FCDocument/FCDAnimated.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2007 Feeling Software Inc.
00003     Portions of the code are:
00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
00005     
00006     MIT License: http://www.opensource.org/licenses/mit-license.php
00007 */
00008 /*
00009     Based on the FS Import classes:
00010     Copyright (C) 2005-2006 Feeling Software Inc
00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
00012     MIT License: http://www.opensource.org/licenses/mit-license.php
00013 */
00014 
00020 #ifndef _FCD_ANIMATED_H_
00021 #define _FCD_ANIMATED_H_
00022 
00023 #ifndef __FCD_OBJECT_H_
00024 #include "FCDocument/FCDObject.h"
00025 #endif // __FCD_OBJECT_H_
00026 
00027 class FCDocument;
00028 class FCDAnimated;
00029 class FCDAnimationCurve;
00030 class FCDAnimationChannel;
00031 class FCDAnimationMultiCurve;
00032 
00033 typedef fm::pvector<float> FloatPtrList; 
00034 typedef fm::pvector<FCDAnimationCurve> FCDAnimationCurveList; 
00035 typedef FUTrackedList<FCDAnimationCurve> FCDAnimationCurveTrackList; 
00036 typedef fm::vector<FCDAnimationCurveTrackList> FCDAnimationCurveListList; 
00037 typedef fm::pvector<FCDAnimationChannel> FCDAnimationChannelList; 
00038 typedef fm::pvector<FCDAnimated> FCDAnimatedList; 
00055 class FCOLLADA_EXPORT FCDAnimated : public FCDObject, FUTracker
00056 {
00057 private:
00058     DeclareObjectType(FCDObject);
00059 
00060 protected:
00062     FloatPtrList values;
00063 
00066     StringList qualifiers; 
00067 
00071     FCDAnimationCurveListList curves;
00072 
00074     FCDObject* target;
00075 
00080     int32 arrayElement;
00081 
00082 public:
00083     DeclareFlag(RelativeAnimation, 0); 
00084     DeclareFlagCount(1); 
00086 public:
00093     FCDAnimated(FCDObject* object, size_t valueCount, const char** qualifiers, float** values);
00094 
00101     FCDAnimated(FCDocument* document, size_t valueCount, const char** qualifiers, float** values);
00102 
00104     virtual ~FCDAnimated();
00105 
00108     inline size_t GetValueCount() const { return values.size(); }
00109 
00113     inline size_t GetCurveCount(size_t index) const { FUAssert(index < GetValueCount(), return 0); return curves[index].size(); }
00114 
00121     inline FCDAnimationCurve* GetCurve(size_t index, size_t curveIndex = 0) { FUAssert(index < GetValueCount(), return NULL); return curveIndex < curves.at(index).size() ? curves.at(index).at(curveIndex) : NULL; }
00122     inline const FCDAnimationCurve* GetCurve(size_t index, size_t curveIndex = 0) const { FUAssert(index < GetValueCount(), return NULL); return curveIndex < curves.at(index).size() ? curves.at(index).at(curveIndex) : NULL; } 
00127     inline FCDAnimationCurveListList& GetCurves() { return curves; }
00128     inline const FCDAnimationCurveListList& GetCurves() const { return curves; } 
00136     bool AddCurve(size_t index, FCDAnimationCurve* curve);
00137     bool AddCurve(size_t index, FCDAnimationCurveList& curve); 
00143     bool RemoveCurve(size_t index);
00144 
00149     inline float* GetValue(size_t index) { FUAssert(index < GetValueCount(), return NULL); return values.at(index); }
00150     inline const float* GetValue(size_t index) const { FUAssert(index < GetValueCount(), return NULL); return values.at(index); } 
00156     inline void SetValue(size_t index, float* value) { FUAssert(index < GetValueCount(), return); values.at(index) = value; }
00157 
00162     const fm::string& GetQualifier(size_t index) const;
00163 
00167     StringList& GetQualifiers(){ return qualifiers; }
00168 
00173     float* FindValue(const fm::string& qualifier);
00174     const float* FindValue(const fm::string& qualifier) const; 
00181     inline FCDAnimationCurve* FindCurve(const char* qualifier) { size_t index = FindQualifier(qualifier); return index < GetValueCount() ? GetCurve(index) : NULL; }
00182     inline FCDAnimationCurve* FindCurve(const fm::string& qualifier) { return FindCurve(qualifier.c_str()); } 
00183     inline const FCDAnimationCurve* FindCurve(const char* qualifier) const { size_t index = FindQualifier(qualifier); return index < GetValueCount() ? GetCurve(index) : NULL; } 
00184     inline const FCDAnimationCurve* FindCurve(const fm::string& qualifier) const { return FindCurve(qualifier.c_str()); } 
00191     inline FCDAnimationCurve* FindCurve(const float* value) { size_t index = FindValue(value); return index < GetValueCount() ? GetCurve(index) : NULL; }
00192     inline const FCDAnimationCurve* FindCurve(const float* value) const { size_t index = FindValue(value); return index < GetValueCount() ? GetCurve(index) : NULL; } 
00198     size_t FindQualifier(const char* qualifier) const;
00199     inline size_t FindQualifier(const fm::string& qualifier) const { return FindQualifier(qualifier.c_str()); } 
00205     size_t FindValue(const float* value) const;
00206 
00209     void SetTargetObject(FCDObject* _target);
00210 
00213     FCDObject* GetTargetObject() { return target; } 
00214 
00220     inline int32 GetArrayElement() const { return arrayElement; }
00221 
00227     inline void SetArrayElement(int32 index) { arrayElement = index; SetDirtyFlag(); }
00228 
00232     bool HasCurve() const;
00233 
00238     FCDAnimationMultiCurve* CreateMultiCurve() const;
00239 
00247     static FCDAnimationMultiCurve* CreateMultiCurve(const FCDAnimatedList& toMerge);
00248 
00253     void Evaluate(float time);
00254 
00258     FCDAnimated* Clone(FCDocument* document) const;
00259 
00263     FCDAnimated* Clone(FCDAnimated* clone) const;
00264 
00267     virtual void OnObjectReleased(FUTrackable* object);
00268 };
00269 
00274 class FCOLLADA_EXPORT FCDAnimatedCustom : public FCDAnimated
00275 {
00276 private:
00277     DeclareObjectType(FCDAnimated);
00278     float dummy;
00279 
00280     bool Link(xmlNode* node);
00281 
00282 public:
00286     FCDAnimatedCustom(FCDObject* object);
00287 
00292     void Copy(const FCDAnimated* copy);
00293 
00296     float& GetDummy() { return dummy; }
00297     const float& GetDummy() const { return dummy; } 
00304     void Resize(size_t count, const char** qualifiers = NULL, bool prependDot = true);
00305     
00309     void Resize(const StringList& qualifiers = NULL, bool prependDot = true);
00310 };
00311 
00313 namespace FCDAnimatedStandardQualifiers
00314 {
00317     FCOLLADA_EXPORT extern const char* EMPTY[1]; 
00318     FCOLLADA_EXPORT extern const char* XYZW[4]; 
00319     FCOLLADA_EXPORT extern const char* RGBA[4]; 
00321     FCOLLADA_EXPORT extern const char* ROTATE_AXIS[4]; 
00322     FCOLLADA_EXPORT extern const char* SKEW[7]; 
00323     FCOLLADA_EXPORT extern const char* MATRIX[16]; 
00324     FCOLLADA_EXPORT extern const char* LOOKAT[9]; 
00325 };
00326 
00327 #endif // _FCD_ANIMATED_H_
00328 

Generated on Thu Feb 14 16:58:33 2008 for FCollada by  doxygen 1.4.6-NO