1 | /**************************************************************************************** |
2 | |
3 | Copyright (C) 2015 Autodesk, Inc. |
4 | All rights reserved. |
5 | |
6 | Use of this software is subject to the terms of the Autodesk license agreement |
7 | provided at the time of installation or download, or which otherwise accompanies |
8 | this software in either electronic or hard copy form. |
9 | |
10 | ****************************************************************************************/ |
11 | |
12 | //! \file fbxanimutilities.h |
13 | #ifndef _FBXSDK_SCENE_ANIMATION_UTILITIES_H_ |
14 | #define _FBXSDK_SCENE_ANIMATION_UTILITIES_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/core/base/fbxarray.h> |
19 | #include <fbxsdk/core/base/fbxstring.h> |
20 | #include <fbxsdk/core/base/fbxtime.h> |
21 | #include <fbxsdk/scene/animation/fbxanimcurve.h> |
22 | |
23 | #include <fbxsdk/fbxsdk_nsbegin.h> |
24 | |
25 | class FbxMultiMap; |
26 | class FbxObject; |
27 | class FbxProperty; |
28 | class FbxScene; |
29 | class FbxIO; |
30 | class FbxAnimStack; |
31 | class FbxAnimLayer; |
32 | class FbxAnimCurveNode; |
33 | class FbxAnimCurve; |
34 | |
35 | class FBXSDK_DLL FbxAnimUtilities |
36 | { |
37 | public: |
38 | /** Inspects all the properties of the given object for animation curves. |
39 | * \param pObj Pointer to the object to query. |
40 | * \return \c true if at least one property is animated and \c false otherwise. |
41 | * \remarks A property is animated if it contains at least one FbxAnimCurve with keys. |
42 | */ |
43 | static bool IsAnimated(FbxObject* pObj); |
44 | |
45 | /** Inspects the specified property of the given object for animation curves. |
46 | * \param pObj Pointer to the object to query. |
47 | * \param pPropertyName Name of the inspected property. |
48 | * \param pChannelName Name of the specific channel of the inspected property. |
49 | * \return \c true if the specified channel is animated and \c false otherwise. |
50 | * \remarks A property is animated if it contains at least one FbxAnimCurve with keys. |
51 | */ |
52 | static bool IsChannelAnimated(FbxObject* pObj, const char* pPropertyName, const char* pChannelName = NULL); |
53 | |
54 | class FBXSDK_DLL FbxAnimSplitDef |
55 | { |
56 | public: |
57 | FbxString mName; |
58 | FbxTime mStart; |
59 | FbxTime mEnd; |
60 | |
61 | FbxAnimSplitDef() |
62 | { |
63 | mName = "unnamed" ; |
64 | mStart = 0; |
65 | mEnd = 0; |
66 | } |
67 | |
68 | FbxAnimSplitDef(const FbxString& pName, FbxTime& pStart, FbxTime& pEnd) |
69 | { |
70 | mName = pName; |
71 | mStart = pStart; |
72 | mEnd = pEnd; |
73 | } |
74 | |
75 | FbxAnimSplitDef& operator =(const FbxAnimSplitDef& pRhs) |
76 | { |
77 | mName = pRhs.mName; |
78 | mStart = pRhs.mStart; |
79 | mEnd = pRhs.mEnd; |
80 | return *this; |
81 | } |
82 | } ; |
83 | |
84 | class FBXSDK_DLL CurveNodeIntfce |
85 | { |
86 | public: |
87 | // pData is a pointer to the private KFCurveNode |
88 | CurveNodeIntfce(void* pData); |
89 | ~CurveNodeIntfce(); |
90 | |
91 | FbxHandle GetHandle(); |
92 | |
93 | char* GetTimeWarpName() const; |
94 | CurveNodeIntfce GetTimeWarp(); |
95 | |
96 | CurveNodeIntfce GetLayer(int pId); |
97 | |
98 | int GetCount(); |
99 | void* GetHandle(unsigned int pId); |
100 | void* GetCurveHandle(int pId = -1); |
101 | void SetCurveHandle(void* pCurveHandle, int pId = -1); |
102 | CurveNodeIntfce FindRecursive(const char* pName); |
103 | |
104 | bool IsValid() { return mImp != NULL; } |
105 | CurveNodeIntfce& operator=(CurveNodeIntfce& lRhs) |
106 | { |
107 | mImp = lRhs.mImp; |
108 | return *this; |
109 | } |
110 | |
111 | bool operator==(CurveNodeIntfce& lRhs) |
112 | { |
113 | return (mImp == lRhs.mImp); |
114 | } |
115 | |
116 | private: |
117 | friend class FbxAnimUtilities; |
118 | void* mImp; |
119 | }; |
120 | |
121 | class FBXSDK_DLL CurveIntfce |
122 | { |
123 | public: |
124 | // pData is a pointer to the private KFCurve |
125 | CurveIntfce(void* pData); |
126 | CurveIntfce(FbxAnimCurve* pAnimCurve); |
127 | ~CurveIntfce(); |
128 | |
129 | float GetValue(); |
130 | void SetValue(float pVal); |
131 | int KeyGetCount(); |
132 | |
133 | void* GetCurveHandle(); |
134 | void SetCurveHandle(void* pData); |
135 | |
136 | int (); |
137 | int (); |
138 | int (); |
139 | int (); |
140 | |
141 | |
142 | bool IsValid() { return mImp != NULL; } |
143 | CurveIntfce& operator=(CurveIntfce& lRhs) |
144 | { |
145 | mImp = lRhs.mImp; |
146 | mIsAnimCurveImp = lRhs.mIsAnimCurveImp; |
147 | return *this; |
148 | } |
149 | |
150 | bool operator==(CurveIntfce& lRhs) |
151 | { |
152 | return (mImp == lRhs.mImp); |
153 | } |
154 | |
155 | private: |
156 | friend class FbxAnimUtilities; |
157 | |
158 | void* mImp; |
159 | bool mIsAnimCurveImp; |
160 | }; |
161 | |
162 | static int SplitAnimationIntoMultipleStacks(FbxScene* pScene, const FbxArray<FbxAnimSplitDef*>& pAnimSplitDefinitions, const FbxAnimStack* pSrcAnimStack, FbxArray<FbxAnimStack*>& pDstStacks); |
163 | static void ShareAnimCurves(FbxProperty& pDstProperty, FbxProperty& pSrcProperty, FbxScene* pScene); |
164 | |
165 | // Encapsulate use of private animation data |
166 | static void SetTimeWarpSet(FbxMultiMap* pTWset); |
167 | |
168 | static CurveNodeIntfce CreateCurveNode(const char* pName); |
169 | static CurveNodeIntfce CreateCurveNode(FbxIO* pFileObject); |
170 | static CurveNodeIntfce CreateCurveNode(FbxIO* pFileObject, CurveNodeIntfce& pParent, bool pOnlyDefaults = false); |
171 | static CurveNodeIntfce CreateTimeWarpNode(FbxAnimCurve* pAnimCurve, const char* pFalloffName); |
172 | |
173 | static CurveNodeIntfce GrabCurveNode(FbxAnimCurveNode* pCN); |
174 | static void RestrieveCurveNode(CurveNodeIntfce& pData, FbxIO* mFileObject); |
175 | static void StoreCurveNode(CurveNodeIntfce& pData, FbxIO* mFileObject); |
176 | static void ReleaseCurveNode(FbxAnimCurveNode* pCurveNode); |
177 | static void DestroyCurveNode(CurveNodeIntfce& pData); |
178 | static void DestroyCurve(CurveIntfce& pData); |
179 | |
180 | static void ConnectTimeWarp(FbxAnimCurveNode* pCurveNode, CurveNodeIntfce& pData, FbxMultiMap& pTimeWarpsKFCurveNodes); |
181 | static void MergeLayerAndTimeWarp(FbxObject* pObj, FbxAnimLayer* pAnimLayer); |
182 | |
183 | static void CopyFrom(FbxAnimCurve* pAC, CurveIntfce& pFC); |
184 | static bool CompareCurves(FbxAnimCurve* pAC1, FbxAnimCurve* pAC2); |
185 | |
186 | static void Resample(FbxAnimCurve &pSourceCurve, FbxAnimCurve &pTargetCurve, FbxTime &pStart, FbxTime &pStop, FbxTime &pPeriod, FbxAnimCurveDef::EInterpolationType pInterpolation, FbxAnimCurveDef::ETangentMode pTangentMode, bool pAddStopKey = false); |
187 | static void Resample(FbxAnimCurve &pSourceCurve, FbxAnimCurve &pTargetCurve, FbxTime &pStart, FbxTime &pStop, FbxTime &pPeriod, bool pAddStopKey = false); |
188 | static void Resample(FbxAnimCurve &pCurve, FbxTime pPeriod, FbxTime pStart = FBXSDK_TIME_MINUS_INFINITE, FbxTime pStop = FBXSDK_TIME_INFINITE, bool pKeysOnFrame = false); |
189 | }; |
190 | |
191 | #include <fbxsdk/fbxsdk_nsend.h> |
192 | |
193 | #endif /* _FBXSDK_SCENE_ANIMATION_UTILITIES_H_ */ |
194 | |