FCDocument/FCDAnimationMultiCurve.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 /*
00006     Based on the FS Import classes:
00007     Copyright (C) 2005-2006 Feeling Software Inc
00008     Copyright (C) 2005-2006 Autodesk Media Entertainment
00009     MIT License: http://www.opensource.org/licenses/mit-license.php
00010 */
00011 
00017 #ifndef _FCD_ANIMATION_MULTI_CURVE_H_
00018 #define _FCD_ANIMATION_MULTI_CURVE_H_
00019 
00020 class FCDocument;
00021 
00022 #include "FCDocument/FCDObject.h"
00023 
00024 typedef float (*FCDConversionFunction)(float v); 
00025 typedef float (*FCDCollapsingFunction)(float* values, uint32 count); 
00039 class FCOLLADA_EXPORT FCDAnimationMultiCurve : public FCDObject
00040 {
00041 private:
00042     DeclareObjectType;
00043 
00044     // The number of merged curves
00045     uint32 dimension;
00046 
00047     // Target information
00048     int32 targetElement;
00049     string* targetQualifiers;
00050 
00051     // Input information
00052     FloatList keys,* keyValues;
00053     FloatList* inTangents,* outTangents;
00054 
00055     // The interpolation values follow the FUDaeInterpolation enum (FUDaeEnum.h)
00056     UInt32List interpolations;
00057 
00058 public:
00064     FCDAnimationMultiCurve(FCDocument* document, uint32 dimension);
00065 
00067     virtual ~FCDAnimationMultiCurve();
00068 
00078     static FCDAnimationMultiCurve* MergeCurves(const vector<FCDAnimationCurve*>& toMerge, const FloatList& defaultValues);
00079     static FCDAnimationMultiCurve* MergeCurves(const vector<const FCDAnimationCurve*>& toMerge, const FloatList& defaultValues); 
00083     inline uint32 GetDimension() const { return dimension; }
00084 
00087     inline FloatList& GetKeys() { return keys; }
00088     inline const FloatList& GetKeys() const { return keys; } 
00093     inline FloatList* GetKeyValues() { return keyValues; }
00094     inline const FloatList* GetKeyValues() const { return keyValues; } 
00100     inline FloatList* GetInTangents() { return inTangents; }
00101     inline const FloatList* GetInTangents() const { return inTangents; } 
00107     inline FloatList* GetOutTangents() { return outTangents; }
00108     inline const FloatList* GetOutTangents() const { return outTangents; } 
00115     inline UInt32List& GetInterpolations() { return interpolations; }
00116     inline const UInt32List& GetInterpolations() const { return interpolations; } 
00121     void Evaluate(float input, float* output) const;
00122 
00128     FCDAnimationCurve* Collapse(FCDCollapsingFunction collapse=NULL) const;
00129 
00134     void WriteSourceToXML(xmlNode* parentNode, const string& baseId);
00135 
00142     xmlNode* WriteSamplerToXML(xmlNode* parentNode, const string& baseId);
00143 
00151     xmlNode* WriteChannelToXML(xmlNode* parentNode, const string& baseId, const string& pointer);
00152 
00157     inline int32 GetTargetElement() const { return targetElement; }
00158 
00162     inline void SetTargetElement(int32 e) { targetElement = e; }
00163 };
00164 
00171 inline float TakeFirst(float* values, uint32 count) { return (count > 0) ? *values : 0.0f; }
00172 
00179 inline float Average(float* values, uint32 count) { float v = 0.0f; for (uint32 i = 0; i < count; ++i) v += values[i]; v /= float(count); return v; }
00180 
00181 #endif // _FCD_ANIMATION_MULTI_CURVE_H_

Generated on Fri May 12 16:44:38 2006 for FCollada by  doxygen 1.4.6-NO