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 fbxanimcurve.h |
13 | #ifndef _FBXSDK_SCENE_ANIMATION_CURVE_H_ |
14 | #define _FBXSDK_SCENE_ANIMATION_CURVE_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/core/fbxobject.h> |
19 | #include <fbxsdk/scene/animation/fbxanimcurvebase.h> |
20 | |
21 | #include <fbxsdk/fbxsdk_nsbegin.h> |
22 | |
23 | class KFCurve; |
24 | |
25 | /** Definitions used for the FBX animation curves and keys. */ |
26 | class FBXSDK_DLL FbxAnimCurveDef |
27 | { |
28 | public: |
29 | static const float sDEFAULT_WEIGHT; |
30 | static const float sMIN_WEIGHT; |
31 | static const float sMAX_WEIGHT; |
32 | static const float sDEFAULT_VELOCITY; |
33 | |
34 | //! Key tangent mode for cubic interpolation. |
35 | enum ETangentMode |
36 | { |
37 | eTangentAuto = 0x00000100, //!< Auto key (spline cardinal). |
38 | eTangentTCB = 0x00000200, //!< Spline TCB (Tension, Continuity, Bias) |
39 | eTangentUser = 0x00000400, //!< Next slope at the left equal to slope at the right. |
40 | eTangentGenericBreak = 0x00000800, //!< Independent left and right slopes. |
41 | eTangentBreak = eTangentGenericBreak|eTangentUser, //!< Independent left and right slopes, with next slope at the left equal to slope at the right. |
42 | eTangentAutoBreak = eTangentGenericBreak|eTangentAuto, //!< Independent left and right slopes, with auto key. |
43 | eTangentGenericClamp = 0x00001000, //!< Clamp: key should be flat if next or previous key has the same value (overrides tangent mode). |
44 | eTangentGenericTimeIndependent = 0x00002000, //!< Time independent tangent (overrides tangent mode). |
45 | eTangentGenericClampProgressive = 0x00004000|eTangentGenericTimeIndependent //!< Clamp progressive: key should be flat if tangent control point is outside [next-previous key] range (overrides tangent mode). |
46 | }; |
47 | |
48 | //! Key interpolation type. |
49 | enum EInterpolationType |
50 | { |
51 | eInterpolationConstant = 0x00000002, //!< Constant value until next key. |
52 | eInterpolationLinear = 0x00000004, //!< Linear progression to next key. |
53 | eInterpolationCubic = 0x00000008 //!< Cubic progression to next key. |
54 | }; |
55 | |
56 | //! Weighted mode. |
57 | enum EWeightedMode |
58 | { |
59 | eWeightedNone = 0x00000000, //!< Tangent has default weights of 0.333; we define this state as not weighted. |
60 | eWeightedRight = 0x01000000, //!< Right tangent is weighted. |
61 | eWeightedNextLeft = 0x02000000, //!< Left tangent is weighted. |
62 | eWeightedAll = eWeightedRight|eWeightedNextLeft //!< Both left and right tangents are weighted. |
63 | }; |
64 | |
65 | //! Key constant mode. |
66 | enum EConstantMode |
67 | { |
68 | eConstantStandard = 0x00000000, //!< Curve value is constant between this key and the next |
69 | eConstantNext = 0x00000100 //!< Curve value is constant, with next key's value |
70 | }; |
71 | |
72 | //! Velocity mode. Velocity settings speed up or slow down animation on either side of a key without changing the trajectory of the animation. Unlike Auto and Weight settings, Velocity changes the animation in time, but not in space. |
73 | enum EVelocityMode |
74 | { |
75 | eVelocityNone = 0x00000000, //!< No velocity (default). |
76 | eVelocityRight = 0x10000000, //!< Right tangent has velocity. |
77 | eVelocityNextLeft = 0x20000000, //!< Left tangent has velocity. |
78 | eVelocityAll = eVelocityRight|eVelocityNextLeft //!< Both left and right tangents have velocity. |
79 | }; |
80 | |
81 | //! Tangent visibility. |
82 | enum ETangentVisibility |
83 | { |
84 | eTangentShowNone = 0x00000000, //!< No tangent is visible. |
85 | eTangentShowLeft = 0x00100000, //!< Left tangent is visible. |
86 | eTangentShowRight = 0x00200000, //!< Right tangent is visible. |
87 | eTangentShowBoth = eTangentShowLeft|eTangentShowRight //!< Both left and right tangents are visible. |
88 | }; |
89 | |
90 | //! FbxAnimCurveKey data indices for cubic interpolation tangent information. |
91 | enum EDataIndex |
92 | { |
93 | eRightSlope = 0, //!< Index of the right derivative, User and Break tangent mode (data are float). |
94 | eNextLeftSlope = 1, //!< Index of the left derivative for the next key, User and Break tangent mode. |
95 | eWeights = 2, //!< Start index of weight values, User and Break tangent break mode (data are FbxInt16 tokens from weight and converted to float). |
96 | eRightWeight = 2, //!< Index of weight on right tangent, User and Break tangent break mode. |
97 | eNextLeftWeight = 3, //!< Index of weight on next key's left tangent, User and Break tangent break mode. |
98 | eVelocity = 4, //!< Start index of velocity values, Velocity mode |
99 | eRightVelocity = 4, //!< Index of velocity on right tangent, Velocity mode |
100 | eNextLeftVelocity = 5, //!< Index of velocity on next key's left tangent, Velocity mode |
101 | eTCBTension = 0, //!< Index of Tension, TCB tangent mode (data are floats). |
102 | eTCBContinuity = 1, //!< Index of Continuity, TCB tangent mode. |
103 | eTCBBias = 2 //!< Index of Bias, TCB tangent mode. |
104 | }; |
105 | }; |
106 | |
107 | struct FBXSDK_DLL FbxAnimCurveTangentInfo |
108 | { |
109 | inline FbxAnimCurveTangentInfo() |
110 | { |
111 | mDerivative = 0; |
112 | mWeight = FbxAnimCurveDef::sDEFAULT_WEIGHT; |
113 | mWeighted = false; |
114 | mVelocity = FbxAnimCurveDef::sDEFAULT_VELOCITY; |
115 | mHasVelocity = false; |
116 | mAuto = 0; |
117 | } |
118 | |
119 | float mDerivative; |
120 | float mWeight; |
121 | float mVelocity; |
122 | float mAuto; |
123 | bool mWeighted; |
124 | bool mHasVelocity; |
125 | }; |
126 | |
127 | /** This is the interface for implementation of animation key objects. |
128 | * \nosubgrouping |
129 | * |
130 | * \remarks Users should not use this class directly, but always use FbxAnimCurveKey. |
131 | * A FbxAnimCurveKey has a FbxAnimCurveKey_Impl. |
132 | * But FbxAnimCurveKey_Impl is just an implementation interface, |
133 | */ |
134 | class FBXSDK_DLL FbxAnimCurveKey_Impl |
135 | { |
136 | public: |
137 | /** Destructor. |
138 | */ |
139 | virtual ~FbxAnimCurveKey_Impl() {}; |
140 | |
141 | /** Assignment operator. |
142 | */ |
143 | virtual FbxAnimCurveKey_Impl& operator=(const FbxAnimCurveKey_Impl& pFKey) = 0; |
144 | |
145 | /** Set time and value of key. |
146 | * \param pTime New time of this key. |
147 | * \param pValue New value of this key. |
148 | */ |
149 | virtual void Set(FbxTime pTime, float pValue) = 0; |
150 | |
151 | /** Set a key with cubic interpolation, TCB tangent mode. |
152 | * The key is modified according to the other parameters. |
153 | * The TCB mode controls the tension, continuity, |
154 | * and bias of the curve. |
155 | * \param pTime Key time. |
156 | * \param pValue Key value. |
157 | * \param pData0 Tension. Controls the amount of curvature in the animation curve. The higher the tension is, the more linear |
158 | * the curve looks. When the tension is low, the curve looks rounder or wider. |
159 | * \param pData1 Continuity. Controls the smoothness or singularity of the curve on the key. |
160 | * \param pData2 Bias. Controls if the effect of tension and continuity affect the curve before or after the key. |
161 | */ |
162 | virtual void SetTCB(FbxTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f) = 0; |
163 | |
164 | /** Get the key value. |
165 | * \return The value of the key. |
166 | */ |
167 | virtual float GetValue() const = 0; |
168 | |
169 | /** Set the key value. |
170 | * \param pValue The value to set. |
171 | */ |
172 | virtual void SetValue(float pValue) = 0; |
173 | |
174 | /** Get key's interpolation type. |
175 | * \return Interpolation type of the queried key. |
176 | */ |
177 | virtual FbxAnimCurveDef::EInterpolationType GetInterpolation() const = 0; |
178 | |
179 | /** Set key's interpolation type. |
180 | * \param pInterpolation Interpolation type of the key. |
181 | */ |
182 | virtual void SetInterpolation (FbxAnimCurveDef::EInterpolationType pInterpolation) = 0; |
183 | |
184 | /** Get key's tangent mode. |
185 | * \param pIncludeOverrides Include override flags: Break, Clamp, Time-Independent. |
186 | * \return Tangent mode of the key. |
187 | * \remarks This method is meaningful for cubic interpolation only. |
188 | * Using this method for non cubic interpolated key will return unpredictable value. |
189 | */ |
190 | virtual FbxAnimCurveDef::ETangentMode GetTangentMode(bool pIncludeOverrides = false) const = 0; |
191 | |
192 | /** Set tangent mode. |
193 | * \param pTangentMode Tangent mode to set. |
194 | */ |
195 | virtual void SetTangentMode (FbxAnimCurveDef::ETangentMode pTangentMode) = 0; |
196 | |
197 | /** Get key's tangent weight mode. |
198 | * \return Tangent weight mode of the key. |
199 | * \remarks This method is meaningful for cubic interpolation only. |
200 | */ |
201 | virtual FbxAnimCurveDef::EWeightedMode GetTangentWeightMode() const = 0; |
202 | |
203 | /** Set key's tangent weight mode as double value (cubic interpolation, non TCB tangent mode). |
204 | * \param pTangentWeightMode Weight mode. |
205 | * \param pMask Used to select the affected tangents. |
206 | * \remarks This method is meaningful for cubic interpolation only. |
207 | * The pMask will be used to cancel out the current tangent weight mode first, and then be used to |
208 | * define which tangent to select to affect. |
209 | * |
210 | * Sample01: |
211 | * \code |
212 | * FbxAnimCurveKey* lAnimCurveKey = FbxSdkNew<FbxAnimCurveKey>(); |
213 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedNextLeft); |
214 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedRight, FbxAnimCurveDef::eWeightedRight); |
215 | * \endcode |
216 | * pMask is eWeightedRight, it will first be used to cancel out the current tangent weight mode eWeightedNextLeft, |
217 | * since they are not the same, it fails to cancel it out. |
218 | * Then the mask eWeightedRight will be used to define which tangent should be affected, |
219 | * since it is the same as pTangentWeightMode (eWeightedRight), so the eWeightedRight should be affected. |
220 | * In total, after above calls, both eWeightedNextLeft and eWeightedRight of this key are affected, so |
221 | * lAnimCurveKey->GetTangentWeightMode() will be FbxAnimCurveDef::eWeightedAll. |
222 | * |
223 | * Sample02: |
224 | * \code |
225 | * FbxAnimCurveKey* lAnimCurveKey = FbxSdkNew<FbxAnimCurveKey>(); |
226 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedAll); |
227 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedRight, FbxAnimCurveDef::eWeightedNextLeft); |
228 | * \endcode |
229 | * pMask is eWeightedNextLeft, it will first be used to cancel out the current tangent weight mode eWeightedAll, |
230 | * it will cancel out affect on eWeightedNextLeft, but leave affect on eWeightedRight. |
231 | * Then the mask eWeightedNextLeft will be used to define which tangent should be affected, |
232 | * since it is not the same as pTangentWeightMode (eWeightedRight), so the pMask won't affect anything in this step. |
233 | * In total, after above calls, only eWeightedRight of this key is still affected, so |
234 | * lAnimCurveKey->GetTangentWeightMode() will be FbxAnimCurveDef::eWeightedRight. |
235 | */ |
236 | virtual void SetTangentWeightMode(FbxAnimCurveDef::EWeightedMode pTangentWeightMode, FbxAnimCurveDef::EWeightedMode pMask = FbxAnimCurveDef::eWeightedAll ) = 0; |
237 | |
238 | /** Adjust the actual tangent of the key so that the tangent control point (tangent extremity) |
239 | * stays closer to where it should be. This is required because the weight value gets imprecise |
240 | * when it is small (it is stored as a fixed point value). This method must be called when |
241 | * setting the weight coming from a source where the precision is the same. It must be called |
242 | * after the tangent value has been set. |
243 | * \remark Do not use this call repetitively (from an interactive editor for example) because |
244 | * this function will create imprecision on the tangent value. |
245 | * \param pIndex FbxAnimCurveDef::EDataIndex |
246 | * \param pWeight New tangent weight value. |
247 | */ |
248 | virtual void SetTangentWeightAndAdjustTangent(FbxAnimCurveDef::EDataIndex pIndex, double pWeight ) = 0; |
249 | |
250 | /** Get key's tangent velocity mode. |
251 | * \return Tangent velocity mode of the key. |
252 | * \remarks This method is meaningful for cubic interpolation only. |
253 | */ |
254 | virtual FbxAnimCurveDef::EVelocityMode GetTangentVelocityMode() const = 0; |
255 | |
256 | /** Set key's tangent velocity mode as double value (cubic interpolation, non TCB tangent mode). |
257 | * \param pTangentVelocityMode Velocity mode. |
258 | * \param pMask Used to select the affected tangents |
259 | * \remarks This method is meaningful for cubic interpolation only. |
260 | * The pMask will be used to cancel out the current tangent velocity mode first, and then be used to |
261 | * define which tangent to select to affect. |
262 | * |
263 | * \see The documentation of SetTangentWeightMode for more details and samples about how the pMask works. |
264 | */ |
265 | virtual void SetTangentVelocityMode(FbxAnimCurveDef::EVelocityMode pTangentVelocityMode, FbxAnimCurveDef::EVelocityMode pMask = FbxAnimCurveDef::eVelocityAll ) = 0; |
266 | |
267 | /** Get key constant mode. |
268 | * \return Key constant mode. |
269 | * \remarks This method is meaningful for constant interpolation only. |
270 | * Using this method for non constant interpolated key will return unpredicted value. |
271 | */ |
272 | virtual FbxAnimCurveDef::EConstantMode GetConstantMode() const = 0; |
273 | |
274 | /** Set key's constant mode. |
275 | * \param pMode Constant mode to set. |
276 | * \remarks This method is meaningful for constant interpolation only. |
277 | */ |
278 | virtual void SetConstantMode(FbxAnimCurveDef::EConstantMode pMode) = 0; |
279 | |
280 | /** Get the value of specified data of the key. |
281 | * \param pIndex Data index to specify which data to get value, the index is dependent on the key tangent mode. |
282 | * \return The value of the specified data. |
283 | * |
284 | * \code |
285 | * FbxAnimCurveKey* lKey; // we suppose this is a valid pointer |
286 | * if(lKey->GetTangentMode() == FbxAnimCurveDef::eTangentTCB) |
287 | * { |
288 | * lKey->GetDataFloat(FbxAnimCurveDef::eTCBTension); |
289 | * lKey->GetDataFloat(FbxAnimCurveDef::eTCBContinuity); |
290 | * lKey->GetDataFloat(FbxAnimCurveDef::eTCBBias); |
291 | * } |
292 | * \endcode |
293 | */ |
294 | virtual float GetDataFloat(FbxAnimCurveDef::EDataIndex pIndex) const = 0; |
295 | |
296 | /** Set the value of specified data of the key. |
297 | * \param pIndex Data index to specify which data to get value, the index is dependent on the key tangent mode. |
298 | * \param pValue The data value to set. |
299 | * |
300 | * \code |
301 | * FbxAnimCurveKey* lKey; // we suppose this is a valid pointer |
302 | * lKey->SetInterpolation(FbxAnimCurveDef::eInterpolationCubic); |
303 | * lKey->SetTangentMode(FbxAnimCurveDef::eTangentAuto); |
304 | * lKey->SetDataFloat(FbxAnimCurveDef::eRightSlope, 0.0); |
305 | * \endcode |
306 | */ |
307 | virtual void SetDataFloat(FbxAnimCurveDef::EDataIndex pIndex, float pValue) = 0; |
308 | |
309 | /** Set tangent visibility mode. This would indicate what part of the tangent is visible in a graphical interface. |
310 | * \param pVisibility Tangent visibility mode. |
311 | * \remarks This method is meaningful for cubic interpolation only. |
312 | */ |
313 | virtual void SetTangentVisibility (FbxAnimCurveDef::ETangentVisibility pVisibility) = 0; |
314 | |
315 | /** Return tangent visibility mode. |
316 | * \return Tangent visibility mode. |
317 | * \remarks This method is meaningful for cubic interpolation only. |
318 | */ |
319 | virtual FbxAnimCurveDef::ETangentVisibility GetTangentVisibility () const = 0; |
320 | |
321 | /** Turn on or turn off the tangent break. |
322 | * When this flag is on (FbxAnimCurveDef::eTANGEAT_BREAK will be set), the key's left and right slopes are independent. |
323 | * When this flag is off, the key's left and right slope are equal. |
324 | * \param pVal Break flag (\c true or \c false). |
325 | * \remarks This method is meaningful for User (FbxAnimCurveDef::eTangentUser) and Auto (FbxAnimCurveDef::eTangentAuto) tangent modes only. |
326 | */ |
327 | virtual void SetBreak(bool pVal) = 0; |
328 | |
329 | /** Get if the tangent has a break. |
330 | * When this flag is set (FbxAnimCurveDef::eTANGEAT_BREAK), the key's left and right slopes are independent. |
331 | * When this flag is off, the key's left and right slope are equal. |
332 | * \return Break flag (\c true or \c false). |
333 | * \remarks This method is meaningful for User (FbxAnimCurveDef::eTangentUser) and Auto (FbxAnimCurveDef::eTangentAuto) tangent modes only. |
334 | */ |
335 | virtual bool GetBreak() const = 0; |
336 | }; |
337 | |
338 | /** This is the interface for the FBX animation curve keys. |
339 | * A key is defined by a time and a value. It also has tangents that control how the animation curve enters and exits the key. |
340 | * \nosubgrouping |
341 | * |
342 | *\remarks This class is now the main animation key object of the SDK, |
343 | * Users should always use this class to handle animation curve key. |
344 | * This class has a FbxAnimCurveKey_Impl as its implementation interface, |
345 | * Default constructor does not initialize data members. |
346 | * If an instance has to be initialized, use function FbxAnimCurveKey::Set(). |
347 | */ |
348 | class FBXSDK_DLL FbxAnimCurveKey : public FbxAnimCurveKeyBase |
349 | { |
350 | public: |
351 | /** Constructor with no argument |
352 | */ |
353 | FbxAnimCurveKey() : FbxAnimCurveKeyBase() |
354 | { |
355 | FBX_ASSERT(mAllocatorFct != NULL); |
356 | mImpl = (*mAllocatorFct)(); |
357 | } |
358 | |
359 | /** Constructor with time. |
360 | * \param pTime The time of key. |
361 | */ |
362 | FbxAnimCurveKey(FbxTime pTime) : FbxAnimCurveKeyBase() |
363 | { |
364 | FBX_ASSERT(mAllocatorFct != NULL); |
365 | mImpl = (*mAllocatorFct)(); |
366 | SetTime(pTime); |
367 | } |
368 | |
369 | /** Constructor with time and value. |
370 | * \param pTime The time of key. |
371 | * \param pVal The value of key. |
372 | */ |
373 | FbxAnimCurveKey(FbxTime pTime, float pVal) : FbxAnimCurveKeyBase() |
374 | { |
375 | FBX_ASSERT(mAllocatorFct != NULL); |
376 | mImpl = (*mAllocatorFct)(); |
377 | Set(pTime, pVal); |
378 | } |
379 | |
380 | /** Copy constructor |
381 | */ |
382 | FbxAnimCurveKey(FbxAnimCurveKey const& pFKey) : FbxAnimCurveKeyBase() |
383 | { |
384 | FBX_ASSERT(mCopyAllocatorFct != NULL); |
385 | SetTime(pFKey.GetTime()); |
386 | mImpl = mCopyAllocatorFct(pFKey.GetImpl()); |
387 | } |
388 | |
389 | /** Destructor |
390 | */ |
391 | ~FbxAnimCurveKey() |
392 | { |
393 | FBX_ASSERT(mDeallocatorFct != NULL); |
394 | (*mDeallocatorFct)(mImpl); |
395 | } |
396 | |
397 | /** Assignment operator |
398 | */ |
399 | FbxAnimCurveKey& operator=(const FbxAnimCurveKey& pFKey) |
400 | { |
401 | FBX_ASSERT(mImpl); |
402 | if (mImpl) |
403 | { |
404 | *mImpl = *(pFKey.GetImpl()); |
405 | } |
406 | SetTime(pFKey.GetTime()); |
407 | return *this; |
408 | } |
409 | |
410 | /** Get time value. |
411 | * \return Time value. |
412 | */ |
413 | FbxTime GetTime() const |
414 | { |
415 | return FbxAnimCurveKeyBase::GetTime(); |
416 | } |
417 | |
418 | /** Set time value. |
419 | * \param pTime Time value to set. |
420 | */ |
421 | void SetTime(const FbxTime& pTime) |
422 | { |
423 | FbxAnimCurveKeyBase::SetTime(pTime); |
424 | } |
425 | |
426 | /** Set time and value of key. |
427 | * \param pTime New time of this key. |
428 | * \param pValue New value of this key. |
429 | */ |
430 | void Set(FbxTime pTime, float pValue) |
431 | { |
432 | FbxAnimCurveKeyBase::SetTime(pTime); |
433 | mImpl->Set(pTime, pValue); |
434 | } |
435 | |
436 | /** Set a key with cubic interpolation, TCB tangent mode. |
437 | * The key is modified according to the other parameters. |
438 | * The TCB mode controls the tension, continuity, |
439 | * and bias of the curve. |
440 | * \param pTime Key time. |
441 | * \param pValue Key value. |
442 | * \param pData0 Tension. Controls the amount of curvature in the animation curve. The higher the tension is, the more linear |
443 | * the curve looks. When the tension is low, the curve looks rounder or wider. |
444 | * \param pData1 Continuity. Controls the smoothness or singularity of the curve on the key. |
445 | * \param pData2 Bias. Controls if the effect of tension and continuity affect the curve before or after the key. |
446 | */ |
447 | void SetTCB(FbxTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f) |
448 | { |
449 | FbxAnimCurveKeyBase::SetTime(pTime); |
450 | mImpl->SetTCB(pTime, pValue, pData0, pData1, pData2); |
451 | } |
452 | |
453 | /** Get the key value. |
454 | * \return The value of the key. |
455 | */ |
456 | float GetValue() const |
457 | { |
458 | return mImpl->GetValue(); |
459 | } |
460 | |
461 | /** Set the key value. |
462 | * \param pValue The value to set. |
463 | */ |
464 | void SetValue(float pValue) |
465 | { |
466 | mImpl->SetValue(pValue); |
467 | } |
468 | |
469 | |
470 | /** Get key's interpolation type. |
471 | * \return Interpolation type of the queried key. |
472 | */ |
473 | FbxAnimCurveDef::EInterpolationType GetInterpolation() |
474 | { |
475 | return mImpl->GetInterpolation(); |
476 | } |
477 | |
478 | /** Set key's interpolation type. |
479 | * \param pInterpolation Interpolation type of the key. |
480 | */ |
481 | void SetInterpolation (FbxAnimCurveDef::EInterpolationType pInterpolation) |
482 | { |
483 | mImpl->SetInterpolation(pInterpolation); |
484 | } |
485 | |
486 | /** Get key's tangent mode. |
487 | * \param pIncludeOverrides Include override flags: Break, Clamp, Time-Independent. |
488 | * \return Tangent mode of the key. |
489 | * \remarks This method is meaningful for cubic interpolation only. |
490 | * Using this method for non cubic interpolated key will return unpredictable value. |
491 | */ |
492 | FbxAnimCurveDef::ETangentMode GetTangentMode(bool pIncludeOverrides = false) |
493 | { |
494 | return mImpl->GetTangentMode(pIncludeOverrides); |
495 | } |
496 | |
497 | /** Set tangent mode. |
498 | * \param pTangentMode Tangent mode to set. |
499 | */ |
500 | void SetTangentMode (FbxAnimCurveDef::ETangentMode pTangentMode) |
501 | { |
502 | mImpl->SetTangentMode(pTangentMode); |
503 | } |
504 | |
505 | /** Get key's tangent weight mode. |
506 | * \return Tangent weight mode of the key. |
507 | * \remarks This method is meaningful for cubic interpolation only. |
508 | */ |
509 | FbxAnimCurveDef::EWeightedMode GetTangentWeightMode() const |
510 | { |
511 | return mImpl->GetTangentWeightMode(); |
512 | } |
513 | |
514 | /** Set key's tangent weight mode as double value (cubic interpolation, non TCB tangent mode). |
515 | * \param pTangentWeightMode Weight mode. |
516 | * \param pMask Used to select the affected tangents. |
517 | * \remarks This method is meaningful for cubic interpolation only. |
518 | * The pMask will be used to cancel out the current tangent weight mode first, and then be used to |
519 | * define which tangent to select to affect. |
520 | * |
521 | * Sample01: |
522 | * \code |
523 | * FbxAnimCurveKey* lAnimCurveKey = FbxSdkNew<FbxAnimCurveKey>(); |
524 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedNextLeft); |
525 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedRight, FbxAnimCurveDef::eWeightedRight); |
526 | * \endcode |
527 | * pMask is eWeightedRight, it will first be used to cancel out the current tangent weight mode eWeightedNextLeft, |
528 | * since they are not the same, it fails to cancel it out. |
529 | * Then the mask eWeightedRight will be used to define which tangent should be affected, |
530 | * since it is the same as pTangentWeightMode (eWeightedRight), so the eWeightedRight should be affected. |
531 | * In total, after above calls, both eWeightedNextLeft and eWeightedRight of this key are affected, so |
532 | * lAnimCurveKey->GetTangentWeightMode() will be FbxAnimCurveDef::eWeightedAll. |
533 | * |
534 | * Sample02: |
535 | * \code |
536 | * FbxAnimCurveKey* lAnimCurveKey = FbxSdkNew<FbxAnimCurveKey>(); |
537 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedAll); |
538 | * lAnimCurveKey->SetTangentWeightMode(FbxAnimCurveDef::eWeightedRight, FbxAnimCurveDef::eWeightedNextLeft); |
539 | * \endcode |
540 | * pMask is eWeightedNextLeft, it will first be used to cancel out the current tangent weight mode eWeightedAll, |
541 | * it will cancel out affect on eWeightedNextLeft, but leave affect on eWeightedRight. |
542 | * Then the mask eWeightedNextLeft will be used to define which tangent should be affected, |
543 | * since it is not the same as pTangentWeightMode (eWeightedRight), so the pMask won't affect anything in this step. |
544 | * In total, after above calls, only eWeightedRight of this key is still affected, so |
545 | * lAnimCurveKey->GetTangentWeightMode() will be FbxAnimCurveDef::eWeightedRight. |
546 | */ |
547 | void SetTangentWeightMode(FbxAnimCurveDef::EWeightedMode pTangentWeightMode, FbxAnimCurveDef::EWeightedMode pMask = FbxAnimCurveDef::eWeightedAll ) |
548 | { |
549 | mImpl->SetTangentWeightMode(pTangentWeightMode, pMask); |
550 | } |
551 | |
552 | /** Adjust the actual tangent of the key so that the tangent control point (tangent extremity) |
553 | * stays closer to where it should be. This is required because the weight value gets imprecise |
554 | * when it is small (it is stored as a fixed point value). This method must be called when |
555 | * setting the weight coming from a source where the precision is the same. It must be called |
556 | * after the tangent value has been set. |
557 | * \remark Do not use this call repetitively (from an interactive editor for example) because |
558 | * this function will create imprecision on the tangent value. |
559 | * \param pIndex FbxAnimCurveDef::EDataIndex |
560 | * \param pWeight New tangent weight value. |
561 | */ |
562 | void SetTangentWeightAndAdjustTangent(FbxAnimCurveDef::EDataIndex pIndex, double pWeight ) |
563 | { |
564 | mImpl->SetTangentWeightAndAdjustTangent(pIndex, pWeight); |
565 | } |
566 | |
567 | /** Get key's tangent velocity mode. |
568 | * \return Tangent velocity mode of the key. |
569 | * \remarks This method is meaningful for cubic interpolation only. |
570 | */ |
571 | FbxAnimCurveDef::EVelocityMode GetTangentVelocityMode() const |
572 | { |
573 | return mImpl->GetTangentVelocityMode(); |
574 | } |
575 | |
576 | /** Set key's tangent velocity mode as double value (cubic interpolation, non TCB tangent mode). |
577 | * \param pTangentVelocityMode Velocity mode. |
578 | * \param pMask Used to select the affected tangents |
579 | * \remarks This method is meaningful for cubic interpolation only. |
580 | * The pMask will be used to cancel out the current tangent velocity mode first, and then be used to |
581 | * define which tangent to select to affect. |
582 | * |
583 | * \see The documentation of SetTangentWeightMode for more details and samples about how the pMask works. |
584 | */ |
585 | void SetTangentVelocityMode(FbxAnimCurveDef::EVelocityMode pTangentVelocityMode, FbxAnimCurveDef::EVelocityMode pMask = FbxAnimCurveDef::eVelocityAll ) |
586 | { |
587 | mImpl->SetTangentVelocityMode(pTangentVelocityMode, pMask); |
588 | } |
589 | |
590 | /** Get key constant mode. |
591 | * \return Key constant mode. |
592 | * \remarks This method is meaningful for constant interpolation only. |
593 | * Using this method for non constant interpolated key will return unpredicted value. |
594 | */ |
595 | FbxAnimCurveDef::EConstantMode GetConstantMode() const |
596 | { |
597 | return mImpl->GetConstantMode(); |
598 | } |
599 | |
600 | /** Set key's constant mode. |
601 | * \param pMode Constant mode to set. |
602 | * \remarks This method is meaningful for constant interpolation only. |
603 | */ |
604 | void SetConstantMode(FbxAnimCurveDef::EConstantMode pMode) |
605 | { |
606 | mImpl->SetConstantMode(pMode); |
607 | } |
608 | |
609 | /** Get the value of specified data of the key. |
610 | * \param pIndex Data index to specify which data to get value, the index is dependent on the key tangent mode. |
611 | * \return The value of the specified data. |
612 | * |
613 | * \code |
614 | * FbxAnimCurveKey* lKey; // we suppose this is a valid pointer |
615 | * if(lKey->GetTangentMode() == FbxAnimCurveDef::eTangentTCB) |
616 | * { |
617 | * lKey->GetDataFloat(FbxAnimCurveDef::eTCBTension); |
618 | * lKey->GetDataFloat(FbxAnimCurveDef::eTCBContinuity); |
619 | * lKey->GetDataFloat(FbxAnimCurveDef::eTCBBias); |
620 | * } |
621 | * \endcode |
622 | */ |
623 | float GetDataFloat(FbxAnimCurveDef::EDataIndex pIndex) const |
624 | { |
625 | return mImpl->GetDataFloat(pIndex); |
626 | } |
627 | |
628 | /** Set the value of specified data of the key. |
629 | * \param pIndex Data index to specify which data to get value, the index is dependent on the key tangent mode. |
630 | * \param pValue The data value to set. |
631 | * |
632 | * \code |
633 | * FbxAnimCurveKey* lKey; // we suppose this is a valid pointer |
634 | * lKey->SetInterpolation(FbxAnimCurveDef::eInterpolationCubic); |
635 | * lKey->SetTangentMode(FbxAnimCurveDef::eTangentAuto); |
636 | * lKey->SetDataFloat(FbxAnimCurveDef::eRightSlope, 0.0); |
637 | * \endcode |
638 | */ |
639 | void SetDataFloat(FbxAnimCurveDef::EDataIndex pIndex, float pValue) |
640 | { |
641 | mImpl->SetDataFloat(pIndex, pValue); |
642 | } |
643 | |
644 | /** Set tangent visibility mode. This would indicate what part of the tangent is visible in a graphical interface. |
645 | * \param pVisibility Tangent visibility mode. |
646 | * \remarks This method is meaningful for cubic interpolation only. |
647 | */ |
648 | void SetTangentVisibility (FbxAnimCurveDef::ETangentVisibility pVisibility) |
649 | { |
650 | mImpl->SetTangentVisibility(pVisibility); |
651 | } |
652 | |
653 | /** Return tangent visibility mode. |
654 | * \return Tangent visibility mode. |
655 | * \remarks This method is meaningful for cubic interpolation only. |
656 | */ |
657 | FbxAnimCurveDef::ETangentVisibility GetTangentVisibility () const |
658 | { |
659 | return mImpl->GetTangentVisibility(); |
660 | } |
661 | |
662 | /** Turn on or turn off the tangent break. |
663 | * When this flag is on (FbxAnimCurveDef::eTANGEAT_BREAK will be set), the key's left and right slopes are independent. |
664 | * When this flag is off, the key's left and right slope are equal. |
665 | * \param pVal Break flag (\c true or \c false). |
666 | * \remarks This method is meaningful for User (FbxAnimCurveDef::eTangentUser) and Auto (FbxAnimCurveDef::eTangentAuto) tangent modes only. |
667 | */ |
668 | void SetBreak(bool pVal) |
669 | { |
670 | mImpl->SetBreak(pVal); |
671 | } |
672 | |
673 | /** Get if the tangent has a break. |
674 | * When this flag is set (FbxAnimCurveDef::eTANGEAT_BREAK), the key's left and right slopes are independent. |
675 | * When this flag is off, the key's left and right slope are equal. |
676 | * \return Break flag (\c true or \c false). |
677 | * \remarks This method is meaningful for User (FbxAnimCurveDef::eTangentUser) and Auto (FbxAnimCurveDef::eTangentAuto) tangent modes only. |
678 | */ |
679 | bool GetBreak() const |
680 | { |
681 | return mImpl->GetBreak(); |
682 | } |
683 | |
684 | /** Get key implementation. |
685 | * \return Pointer to implemented instance. |
686 | */ |
687 | FbxAnimCurveKey_Impl* GetImpl() const |
688 | { |
689 | return mImpl; |
690 | } |
691 | |
692 | /** Set allocator function |
693 | * \param pAllocatorFct Allocator function |
694 | */ |
695 | static void SetAllocatorFct(FbxAnimCurveKey_Impl* (*pAllocatorFct)()); |
696 | |
697 | /** Set copy allocator function |
698 | * \param pCopyAllocatorFct Copy allocator function |
699 | */ |
700 | static void SetCopyAllocatorFct(FbxAnimCurveKey_Impl* (*pCopyAllocatorFct)(FbxAnimCurveKey_Impl*)); |
701 | |
702 | /** Set deallocator function |
703 | * \param pDeallocatorFct Deallocator function |
704 | */ |
705 | static void SetDeallocatorFct(void (*pDeallocatorFct)(FbxAnimCurveKey_Impl*)); |
706 | |
707 | private: |
708 | static FbxAnimCurveKey_Impl* (*mAllocatorFct)(); |
709 | static FbxAnimCurveKey_Impl* (*mCopyAllocatorFct)(FbxAnimCurveKey_Impl*); |
710 | static void (*mDeallocatorFct)(FbxAnimCurveKey_Impl*); |
711 | FbxAnimCurveKey_Impl* mImpl; |
712 | }; |
713 | |
714 | class FbxScene; |
715 | |
716 | /** An animation curve, defined by a collection of keys (FbxAnimCurveKey), and indicating how a value changes over time. |
717 | * Since an animation curve is a function, on a given animation curve, only one key per time is |
718 | * allowed. The keys are sorted |
719 | * in time order. They can be accessed by their index on the curve, from 0 to FbxAnimCurve::KeyGetCount-1. |
720 | * The time unit in FBX (FbxTime) is 1/46186158000 of one second. |
721 | * |
722 | * Each key defines tangents and interpolation that modify the animation curve. |
723 | * Tangents control the way the animation curve enters and exits the keys. |
724 | * Interpolation indicates the animation curve's behavior between keys. |
725 | * |
726 | * Interpolation modes are |
727 | * \li Constant - Curve value stays the same until next key |
728 | * \li Linear - Animation curve is a straight line |
729 | * \li Cubic - Animation curve is a Bezier spline |
730 | * |
731 | * Tangent modes are |
732 | * \li Auto (Spline cardinal) |
733 | * \li Spline TCB (Tension, Continuity, Bias) |
734 | * \li User (Next slope at the left equal to slope at the right) |
735 | * |
736 | * Tangent modes can be overridden by more tangent options: |
737 | * \li Break (Independent left and right slopes) |
738 | * \li Clamp (Key should be flat if next or previous key has the same value) |
739 | * \li Time independent |
740 | * |
741 | * Tangent can be modified some more by adding weights and velocity. |
742 | * By default, the weights are 0.333 on either side of the key, and there is |
743 | * no velocity. Velocity settings speed up or slow down animation on either side of |
744 | * a key without changing the trajectory of the animation. Unlike Auto and Weight settings, |
745 | * Velocity changes the animation in time, but not in space. |
746 | * |
747 | * \nosubgrouping |
748 | * \remarks FbxAnimCurve is now the main animation animation curve object of the SDK. |
749 | * Users should always use this class to handle animation curve. |
750 | * |
751 | * \note When adding keys to an animation curve, use FbxAnimCurve::KeyModifyBegin and FbxAnimCurve::KeyModifyEnd. |
752 | * please refer to the following sample code: |
753 | * \code |
754 | * FbxTime lTime; |
755 | * int lKeyIndex = 0; |
756 | |
757 | * // Create curve |
758 | * FbxAnimCurve* lAnimCurve = FbxAnimCurve::Create(pScene, "Cube Animation"); |
759 | |
760 | * // Add keys to the curve |
761 | * lAnimCurve->KeyModifyBegin(); |
762 | |
763 | * // First key: time 0, value 0 |
764 | * lTime.SetSecondDouble(0.0); |
765 | * lKeyIndex = lAnimCurve->KeyAdd(lTime); |
766 | * lAnimCurve->KeySet(lKeyIndex, lTime, 0.0, FbxAnimCurveDef::eInterpolationLinear); |
767 | |
768 | * // Second key: time 20s, value -3600 |
769 | * // Since this curve will describe rotation, each cube will rotate 10 times around itself during 20 seconds. |
770 | * lTime.SetSecondDouble(20.0); |
771 | * lKeyIndex = lAnimCurve->KeyAdd(lTime); |
772 | * lAnimCurve->KeySet(lKeyIndex, lTime, -3600, FbxAnimCurveDef::eInterpolationLinear); |
773 | |
774 | * // Done adding keys. |
775 | * lAnimCurve->KeyModifyEnd(); |
776 | * \endcode |
777 | * |
778 | */ |
779 | class FBXSDK_DLL FbxAnimCurve : public FbxAnimCurveBase |
780 | { |
781 | FBXSDK_ABSTRACT_OBJECT_DECLARE(FbxAnimCurve, FbxAnimCurveBase); |
782 | |
783 | public: |
784 | /** |
785 | * \name Animation curve creation. |
786 | * |
787 | */ |
788 | //@{ |
789 | /** Create a FbxAnimCurve. |
790 | * \param pContainer Scene to which the created animation curve belongs. |
791 | * \param pName Name of the animation curve. |
792 | * \return Newly created animation curve |
793 | */ |
794 | static FbxAnimCurve* Create(FbxScene* pContainer, const char* pName); |
795 | //@} |
796 | |
797 | /** |
798 | * \name Key management. |
799 | * |
800 | */ |
801 | //@{ |
802 | /** Resize animation curve buffer to hold a certain number of keys. |
803 | * \param pKeyCount Number of keys the animation curve will eventually hold. |
804 | */ |
805 | virtual void ResizeKeyBuffer(int pKeyCount) = 0; |
806 | |
807 | /** Call this function prior to adding, removing or editing keys of an animation curve. |
808 | * Call function FbxAnimCurve::KeyModifyEnd() after modification. |
809 | */ |
810 | virtual void KeyModifyBegin () = 0; |
811 | |
812 | /** Call this function after adding, removing or editing keys of an animation curve. |
813 | * Function FbxAnimCurve::KeyModifyBegin() must have been called prior to modify the keys. |
814 | */ |
815 | virtual void KeyModifyEnd () = 0; |
816 | |
817 | //! Remove all the keys of the animation curve and free buffer memory. |
818 | virtual void KeyClear () = 0; |
819 | |
820 | /** Get the number of keys. |
821 | * \return Key count. |
822 | */ |
823 | virtual int KeyGetCount () const = 0; |
824 | |
825 | /** Add a given key at given time. The new key is appended after all the other animation curve's keys. |
826 | * Function FbxAnimCurve::KeyInsert() should be used instead if the key |
827 | * is to be added in the curve and not at the end. This function does not |
828 | * respect the interpolation type and tangents of the neighboring keys. |
829 | * If there is already a key at the given time, the key is modified and no |
830 | * new key is added. |
831 | * |
832 | * \param pTime Time of the new key. |
833 | * \param pKey Key to add. |
834 | * \param pLast Index of the last processed key to speed up search. If this function is called in a loop, |
835 | * initialize this value to 0 and let it be updated by each call. |
836 | * \return Index of the key at given time, no matter if it was added |
837 | * or already present. |
838 | * |
839 | * \remark Key value, interpolation type and tangent mode must be set |
840 | * explicitly afterwards. |
841 | */ |
842 | virtual int KeyAdd (FbxTime pTime, FbxAnimCurveKeyBase& pKey, int* pLast = NULL) = 0; |
843 | |
844 | /** Add a key at given time. The new key is appended after all the other animation curve's keys. |
845 | * Function FbxAnimCurve::KeyInsert() should be used instead if the key |
846 | * is to be added in the curve and not at the end. This function does not |
847 | * respect of the interpolation type and tangents of the neighboring keys. |
848 | * If there is already a key a the given time, no key is added. |
849 | * |
850 | * \param pTime Time of the new key. |
851 | * \param pLast Index of the last processed key to speed up search. If this function is called in a loop, |
852 | * initialize this value to 0 and let it be updated by each call. |
853 | * \return Index of the key at given time, no matter if it was added |
854 | * or already present. |
855 | * \remark Key value, interpolation type and tangent mode must be set |
856 | * explicitly afterwards. |
857 | */ |
858 | virtual int KeyAdd (FbxTime pTime, int* pLast = NULL) = 0; |
859 | |
860 | /** Set (or replace) key at given index with given key. |
861 | * \param pIndex Index of the key to be set or replaced. |
862 | * \param pKey New key at this index. |
863 | * \return \c true if key time is superior to previous key time |
864 | * and inferior to next key time, \c false otherwise. |
865 | * \remark Result is undetermined if animation curve has no key or if index |
866 | * is out of bounds. |
867 | */ |
868 | virtual bool KeySet(int pIndex, FbxAnimCurveKeyBase& pKey) = 0; |
869 | |
870 | /** Remove key at given index. Other key indices are updated automatically. |
871 | * \param pIndex Index of key to remove. |
872 | * \return \c true on success, \c false otherwise. |
873 | */ |
874 | virtual bool KeyRemove(int pIndex) = 0; |
875 | |
876 | /** Remove all the keys in the given range. |
877 | * \param pStartIndex Index of the first key to remove (inclusive). |
878 | * \param pEndIndex Index of the last key to remove (inclusive). |
879 | * \return true on success. |
880 | */ |
881 | virtual bool KeyRemove(int pStartIndex, int pEndIndex) = 0; |
882 | |
883 | /** Insert a key at given time. |
884 | * This function should be used instead of FbxAnimCurve::KeyAdd() if the key |
885 | * is to be added in the curve and not at the end. It inserts the key in |
886 | * respect to the interpolation type and tangents of the neighboring keys. |
887 | * If there is already a key a the given time, the key is modified and no |
888 | * new key is added. |
889 | * \param pTime Time of the new key. |
890 | * \param pLast Index of the last processed key to speed up search. If this |
891 | * function is called in a loop, initialize this value to 0 and let it |
892 | * be updated by each call. |
893 | * \return Index of the key at given time, no matter if it was inserted |
894 | * or already present. |
895 | * \remark Key value must be set explicitly afterwards. The |
896 | * interpolation type and tangent mode are copied from the previous key. |
897 | */ |
898 | virtual int KeyInsert ( FbxTime pTime, int* pLast = NULL ) = 0; |
899 | |
900 | /** Find key index for a given time. |
901 | * \param pTime Time of the key looked for. |
902 | * \param pLast Index of the last processed key to speed up search. If this |
903 | * function is called in a loop, initialize this value to 0 and let it |
904 | * be updated by each call. |
905 | * \return Key index. The integer part of the key index gives the |
906 | * index of the closest key with a smaller time. The decimals give |
907 | * the relative position of given time compared to previous and next |
908 | * key times. Returns -1 if animation curve has no key. |
909 | * |
910 | * For example (using seconds for clarity), if there is a key at time 10s with index 5, and a key at |
911 | * time 11s with index 6, KeyFind(10.3s) would return 5.3. |
912 | */ |
913 | virtual double KeyFind (FbxTime pTime, int* pLast = NULL) = 0; |
914 | |
915 | /** Scale value of all keys. |
916 | * \param pMultValue Scale applied on key values. |
917 | * \return \c true on success, \c false otherwise. |
918 | */ |
919 | virtual bool KeyScaleValue (float pMultValue) = 0; |
920 | |
921 | /** Scale value and tangent of all keys. |
922 | * \param pMultValue Scale applied on key values and tangents. |
923 | * \return \c true on success, \c false otherwise. |
924 | */ |
925 | virtual bool KeyScaleValueAndTangent (float pMultValue) = 0; |
926 | //@} |
927 | |
928 | /** |
929 | * \name Key Manipulation |
930 | */ |
931 | |
932 | //@{ |
933 | /** General function to set key properties. |
934 | * The key at index pKeyIndex is retrieved and modified according to the other parameters. |
935 | * The key must have been previously created, for example using KeyAdd. |
936 | * Use FbxAnimCurve::SetTCB() in the specific case of setting a key with cubic interpolation and TCB tangent mode. |
937 | * \param pKeyIndex Index of the key. |
938 | * \param pTime Key time. |
939 | * \param pValue Key value. |
940 | * \param pInterpolation Key interpolation type. |
941 | * \param pTangentMode Key tangent mode (meaningful for cubic interpolation only). |
942 | * \param pData0 Value of right slope. |
943 | * \param pData1 Value of next left slope. |
944 | * \param pTangentWeightMode Weight mode, if used. |
945 | * \param pWeight0 Weight for right slope, if tangent weight mode is eWeightedRight or eWeightedAll. |
946 | * \param pWeight1 Weight for next left slope, if tangent weight mode is eWeightedNextLeft or eWeightedAll. |
947 | * \param pVelocity0 Velocity for right slope, if tangent velocity mode is eVelocityRight or eVelocityAll. |
948 | * \param pVelocity1 Velocity for next left slope, if tangent velocity mode is eVelocityNextLeft or eVelocityAll. |
949 | */ |
950 | virtual void KeySet(int pKeyIndex,FbxTime pTime, float pValue, FbxAnimCurveDef::EInterpolationType pInterpolation = FbxAnimCurveDef::eInterpolationCubic, FbxAnimCurveDef::ETangentMode pTangentMode = FbxAnimCurveDef::eTangentAuto, float pData0 = 0.0,float pData1 = 0.0,FbxAnimCurveDef::EWeightedMode pTangentWeightMode = FbxAnimCurveDef::eWeightedNone, float pWeight0 = FbxAnimCurveDef::sDEFAULT_WEIGHT,float pWeight1 = FbxAnimCurveDef::sDEFAULT_WEIGHT,float pVelocity0 = FbxAnimCurveDef::sDEFAULT_VELOCITY,float pVelocity1 = FbxAnimCurveDef::sDEFAULT_VELOCITY) = 0; |
951 | |
952 | /** Set a key with cubic interpolation, TCB tangent mode. |
953 | * The key at index pKeyIndex is retrieved and modified according to the other parameters. |
954 | * The TCB mode controls the tension, continuity, |
955 | * and bias of the curve. |
956 | * \param pKeyIndex Index of the key. |
957 | * \param pTime Key time. |
958 | * \param pValue Key value. |
959 | * \param pData0 Tension. Controls the amount of curvature in the animation curve. The higher the tension is, the more linear |
960 | * the curve looks. When the tension is low, the curve looks rounder or wider. |
961 | * \param pData1 Continuity. Controls the smoothness or singularity of the curve on the key. |
962 | * \param pData2 Bias. Controls if the effect of tension and continuity affect the curve before or after the key. |
963 | */ |
964 | virtual void KeySetTCB(int pKeyIndex,FbxTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f) = 0; |
965 | |
966 | /** Get key's interpolation type. |
967 | * \param pKeyIndex Index of the queried key. |
968 | * \return Interpolation type of the queried key. |
969 | */ |
970 | virtual FbxAnimCurveDef::EInterpolationType KeyGetInterpolation(int pKeyIndex) const = 0; |
971 | |
972 | /** Set key's interpolation type. |
973 | * \param pKeyIndex Index of the key. |
974 | * \param pInterpolation Key interpolation type. |
975 | */ |
976 | virtual void KeySetInterpolation(int pKeyIndex, FbxAnimCurveDef::EInterpolationType pInterpolation) = 0; |
977 | |
978 | /** Get key's constant mode. |
979 | * \note This method is only relevant if the key's interpolation type is constant (eInterpolationConstant). |
980 | * Using this method on a key with an other interpolation type will return unpredictable value. |
981 | * \param pKeyIndex Index of the queried key. |
982 | * \return Key constant mode. |
983 | */ |
984 | virtual FbxAnimCurveDef::EConstantMode KeyGetConstantMode(int pKeyIndex) const = 0; |
985 | |
986 | /** Get key's tangent mode. |
987 | * \param pKeyIndex Index of the key. |
988 | * \param pIncludeOverrides Include override flags: Break, Clamp, Time-Independent. |
989 | * This method is meaningful for cubic interpolation only. |
990 | * Using this method for non cubic interpolated key will return unpredictable value. |
991 | * \return Key tangent mode. |
992 | */ |
993 | virtual FbxAnimCurveDef::ETangentMode KeyGetTangentMode(int pKeyIndex, bool pIncludeOverrides = false ) const = 0; |
994 | |
995 | /** Set key's constant mode. |
996 | * This method is meaningful for constant interpolation only. |
997 | * \param pKeyIndex Index of the key. |
998 | * \param pMode Key constant mode. |
999 | */ |
1000 | virtual void KeySetConstantMode(int pKeyIndex, FbxAnimCurveDef::EConstantMode pMode) = 0; |
1001 | |
1002 | /** Set key's tangent mode. |
1003 | * This method is meaningful for cubic interpolation only. |
1004 | * \param pKeyIndex Index of the key. |
1005 | * \param pTangent Key tangent mode. |
1006 | */ |
1007 | virtual void KeySetTangentMode(int pKeyIndex, FbxAnimCurveDef::ETangentMode pTangent) = 0; |
1008 | |
1009 | /** Get key at given index. |
1010 | * \param pIndex Index of the key on the animation curve. |
1011 | * \return The key at the given index. |
1012 | * \remark Result is undetermined if animation curve has no key or if index |
1013 | * is out of bounds. |
1014 | */ |
1015 | virtual FbxAnimCurveKey KeyGet(int pIndex) const = 0; |
1016 | |
1017 | /** Get key value. |
1018 | * \param pKeyIndex Index of the queried key. |
1019 | * \return Key value. |
1020 | */ |
1021 | virtual float KeyGetValue(int pKeyIndex) const = 0; |
1022 | |
1023 | /** Set key value. |
1024 | * \param pKeyIndex Index of the key. |
1025 | * \param pValue The value to set. |
1026 | */ |
1027 | virtual void KeySetValue(int pKeyIndex, float pValue) = 0; |
1028 | |
1029 | /** Increment key value. |
1030 | * \param pKeyIndex Index of the key. |
1031 | * \param pValue Term added to the key value. |
1032 | */ |
1033 | virtual void KeyIncValue(int pKeyIndex, float pValue) = 0; |
1034 | |
1035 | /** Multiply key value. |
1036 | * \param pKeyIndex Index of the key. |
1037 | * \param pValue Factor multiplying the key value. |
1038 | * \see FbxAnimCurve::KeyMultTangent. |
1039 | */ |
1040 | virtual void KeyMultValue(int pKeyIndex, float pValue) = 0; |
1041 | |
1042 | /** Multiply key tangents. |
1043 | * \remark When multiplying a key value, tangents must be |
1044 | * multiplied to conserve the same topology. |
1045 | * \param pKeyIndex Index of the key. |
1046 | * \param pValue Factor multiplying the key tangents. |
1047 | */ |
1048 | virtual void KeyMultTangent(int pKeyIndex, float pValue) = 0; |
1049 | |
1050 | /** Get key time |
1051 | * \param pKeyIndex Index of the queried key. |
1052 | * \return Key time (time at which this key is occurring). |
1053 | */ |
1054 | virtual FbxTime KeyGetTime(int pKeyIndex) const = 0; |
1055 | |
1056 | /** Set key time. |
1057 | * \param pKeyIndex Index of the key. |
1058 | * \param pTime Key time (time at which this key is occurring). |
1059 | * \remark The new key time might modify the key index. |
1060 | */ |
1061 | virtual void KeySetTime(int pKeyIndex, FbxTime pTime) = 0; |
1062 | |
1063 | /** Set or unset the tangent break. When this flag is set (FbxAnimCurveDef::eTangentBreak), the key's left and right slopes are independent. |
1064 | * When this flag is off, the key's left and right slope are equal. |
1065 | * This method is relevant for User (FbxAnimCurveDef::eTangentUser) and Auto (FbxAnimCurveDef::eTangentAuto) tangent modes only. |
1066 | * \param pKeyIndex Index of the key. |
1067 | * \param pVal Break flag (\c true or \c false). |
1068 | */ |
1069 | virtual void KeySetBreak(int pKeyIndex, bool pVal) = 0; |
1070 | |
1071 | /** Get if the tangent has a break. When this flag is set (FbxAnimCurveDef::eTangentBreak), the key's left and right slopes are independent. |
1072 | * When this flag is off, the key's left and right slope are equal. |
1073 | * This method is relevant for User (FbxAnimCurveDef::eTangentUser) and Auto (FbxAnimCurveDef::eTangentAuto) tangent modes only. |
1074 | * \param pKeyIndex Index of the queried key. |
1075 | * \return Break flag (\c true or \c false). |
1076 | */ |
1077 | virtual bool KeyGetBreak(int pKeyIndex) const = 0; |
1078 | //@} |
1079 | |
1080 | /** |
1081 | * \name Key Tangent Management |
1082 | */ |
1083 | //@{ |
1084 | /** Get the left derivative of a key. |
1085 | * \param pIndex Index of the queried key. |
1086 | * \return Left derivative (Value over time (s)). |
1087 | * \remark Result is undetermined if animation curve has no key or if index |
1088 | * is out of bounds. |
1089 | */ |
1090 | virtual float KeyGetLeftDerivative(int pIndex) = 0; |
1091 | |
1092 | /** Set the left derivative of a key. |
1093 | * \param pIndex Index of the key. |
1094 | * \param pValue Left derivative. |
1095 | * \remark Result is undetermined if animation curve has no key or if index |
1096 | * is out of bounds. |
1097 | * This function is only relevant if previous key interpolation |
1098 | * type is eInterpolationCubic and tangent mode is |
1099 | * FbxAnimCurveDef::eTangentUser, FbxAnimCurveDef::eTangentBreak or FbxAnimCurveDef::eTangentAuto. |
1100 | */ |
1101 | virtual void KeySetLeftDerivative(int pIndex, float pValue) = 0; |
1102 | |
1103 | /** Get the left auto parametric of a key. This is used to compute the slope of Auto and User keys. |
1104 | * \param pIndex Index of the key. |
1105 | * \param pApplyOvershootProtection Clamp flag (eGENERIC_CLAMP) is taken into account. |
1106 | * \return Left auto parametric. |
1107 | * \remark Result is undetermined if animation curve has no key or if index |
1108 | * is out of bounds. |
1109 | */ |
1110 | virtual float KeyGetLeftAuto(int pIndex, bool pApplyOvershootProtection = false) = 0; |
1111 | |
1112 | /** Get the left derivative info (of type FbxAnimCurveTangentInfo) of a key. |
1113 | * \param pIndex Index of the queried key. |
1114 | * \return Left derivative info. |
1115 | * \remark Result is undetermined if animation curve has no key or if index |
1116 | * is out of bounds. |
1117 | */ |
1118 | virtual FbxAnimCurveTangentInfo KeyGetLeftDerivativeInfo(int pIndex) = 0; |
1119 | |
1120 | /** Set the left derivative info (of type FbxAnimCurveTangentInfo) of a key. |
1121 | * \param pIndex Index of the key. |
1122 | * \param pValue Left derivative info. |
1123 | * \param pForceDerivative If \c true, assign the tangent info's derivative value to the key derivative. |
1124 | * If \c false, use the tangent info's auto parametric value to recompute the key derivative. |
1125 | * \remark Result is undetermined if animation curve has no key or if index |
1126 | * is out of bounds. |
1127 | * This function is only relevant if previous key interpolation |
1128 | * type is eInterpolationCubic and tangent mode is |
1129 | * FbxAnimCurveDef::eTangentUser or FbxAnimCurveDef::eTangentBreak. |
1130 | */ |
1131 | virtual void KeySetLeftDerivativeInfo(int pIndex, const FbxAnimCurveTangentInfo& pValue, bool pForceDerivative = false) = 0; |
1132 | |
1133 | /** Get the right derivative of a key. |
1134 | * \param pIndex Index of the key. |
1135 | * \return Right derivative (Value over time (s)). |
1136 | * \remark Result is undetermined if animation curve has no key or if index |
1137 | * is out of bounds. |
1138 | */ |
1139 | virtual float KeyGetRightDerivative(int pIndex) = 0; |
1140 | |
1141 | /** Set the right derivative of a key. |
1142 | * \param pIndex Index of the key. |
1143 | * \param pValue Right derivative. |
1144 | * \remark Result is undetermined if animation curve has no key or if index |
1145 | * is out of bounds. |
1146 | * This function is only relevant if previous key interpolation |
1147 | * type is eInterpolationCubic and tangent mode is |
1148 | * FbxAnimCurveDef::eTangentUser, FbxAnimCurveDef::eTangentBreak or FbxAnimCurveDef::eTangentAuto. |
1149 | */ |
1150 | virtual void KeySetRightDerivative(int pIndex, float pValue) = 0; |
1151 | |
1152 | /** Get the right auto parametric of a key. This is used to compute the slope of Auto and User keys. |
1153 | * \param pIndex Index of the key. |
1154 | * \param pApplyOvershootProtection Clamp flag (eGENERIC_CLAMP) is taken into account. |
1155 | * \return Right auto parametric. |
1156 | * \remark Result is undetermined if animation curve has no key or if index |
1157 | * is out of bounds. |
1158 | */ |
1159 | virtual float KeyGetRightAuto(int pIndex, bool pApplyOvershootProtection = false) = 0; |
1160 | |
1161 | /** Get the right derivative info (of type FbxAnimCurveTangentInfo) of a key. |
1162 | * \param pIndex Index of the queried key. |
1163 | * \return Right derivative info. |
1164 | * \remark Result is undetermined if animation curve has no key or if index |
1165 | * is out of bounds. |
1166 | */ |
1167 | virtual FbxAnimCurveTangentInfo KeyGetRightDerivativeInfo(int pIndex) = 0; |
1168 | |
1169 | /** Set the right derivative info (of type FbxAnimCurveTangentInfo) of a key. |
1170 | * \param pIndex Index of the key. |
1171 | * \param pValue Right derivative info. |
1172 | * \param pForceDerivative If \c true, assign the tangent info's derivative value to the key derivative. |
1173 | * If \c false, use the tangent info's auto parametric value to recompute the key derivative. |
1174 | * \remark Result is undetermined if animation curve has no key or if index |
1175 | * is out of bounds. |
1176 | * This function is only relevant if previous key interpolation |
1177 | * type is eInterpolationCubic and tangent mode is |
1178 | * FbxAnimCurveDef::eTangentUser or FbxAnimCurveDef::eTangentBreak. |
1179 | */ |
1180 | virtual void KeySetRightDerivativeInfo(int pIndex, const FbxAnimCurveTangentInfo& pValue, bool pForceDerivative = false) = 0; |
1181 | |
1182 | /** Get the left tangent weight mode of a key. |
1183 | * \param pIndex Index of queried key. |
1184 | * \return \c true if the key is left weighted (Weight mode is eWEIGHT_WEIGHTED_RIGHT or eWeightedAll). \c false otherwise. |
1185 | * \remark Result is undetermined if animation curve has no key or if index |
1186 | * is out of bounds. |
1187 | */ |
1188 | virtual bool KeyIsLeftTangentWeighted(int pIndex) const = 0; |
1189 | |
1190 | /** Get the right tangent weight mode of a key. |
1191 | * \param pIndex Index of queried key. |
1192 | * \return \c true if the key is right weighted (Weight mode is eWeightedRight or eWeightedAll). \c false otherwise. |
1193 | * \remark Result is undetermined if animation curve has no key or if index |
1194 | * is out of bounds. |
1195 | */ |
1196 | virtual bool KeyIsRightTangentWeighted(int pIndex) const = 0; |
1197 | |
1198 | /** Get the weight value component of the left tangent of a key. |
1199 | * \param pIndex Index of the key. |
1200 | * \return Left tangent weight, or eDEFAULT_WEIGHT (0.333...) if left tangent is not weighted. |
1201 | * \remark This function is only relevant if key interpolation |
1202 | * type is eInterpolationCubic. |
1203 | */ |
1204 | virtual float KeyGetLeftTangentWeight(int pIndex) const = 0; |
1205 | |
1206 | /** Get the weight value component of the right tangent of a key. |
1207 | * \param pIndex Index of the key. |
1208 | * \return Right tangent weight, or eDEFAULT_WEIGHT (0.333...) if right tangent is not weighted. |
1209 | * \remark This function is only relevant if key interpolation |
1210 | * type is eInterpolationCubic. |
1211 | */ |
1212 | virtual float KeyGetRightTangentWeight(int pIndex) const = 0; |
1213 | |
1214 | /** Set the left tangent weight of a key. |
1215 | * \param pIndex Index of the key. |
1216 | * \param pWeight Weight to set on the left tangent. |
1217 | * \param pAdjustTan If true, recompute the tangent height to compensate for very small weights. |
1218 | * \remarks This function is only relevant if previous key interpolation |
1219 | * type is eInterpolationCubic and tangent mode is |
1220 | * FbxAnimCurveDef::eTangentUser or FbxAnimCurveDef::eTangentBreak. The tangent is |
1221 | * automatically set in weighted mode. |
1222 | * The pAdjustTan option will only produce correct results provided that the tangent has already been |
1223 | * set before calling this function. |
1224 | */ |
1225 | virtual void KeySetLeftTangentWeight( int pIndex, float pWeight, bool pAdjustTan = false ) = 0; |
1226 | |
1227 | /** Set the right tangent weight of a key. |
1228 | * \param pIndex Index of the key. |
1229 | * \param pWeight Weight to set on the right tangent. |
1230 | * \param pAdjustTan If true, recompute the tangent height to compensate for very small weights. |
1231 | * \remarks This function is only relevant if key interpolation |
1232 | * type is eInterpolationCubic and tangent mode is |
1233 | * FbxAnimCurveDef::eTangentUser or FbxAnimCurveDef::eTangentBreak. The tangent is |
1234 | * automatically set in weighted mode. |
1235 | * The pAdjustTan option will only produce correct results provided that the tangent has already been |
1236 | * set before calling this function. |
1237 | */ |
1238 | virtual void KeySetRightTangentWeight( int pIndex, float pWeight, bool pAdjustTan = false ) = 0; |
1239 | |
1240 | /** Get the velocity value component of the left tangent of a key. |
1241 | * \param pIndex Index of the key. |
1242 | * \return Tangent velocity of the left tangent. |
1243 | * \remarks This function is only relevant if key interpolation |
1244 | * type is eInterpolationCubic |
1245 | */ |
1246 | virtual float KeyGetLeftTangentVelocity( int pIndex) const = 0; |
1247 | |
1248 | /** Get the velocity value component of the right tangent of a key. |
1249 | * \param pIndex Index of the key. |
1250 | * \return Tangent velocity of the right tangent. |
1251 | * \remarks This function is only relevant if key interpolation |
1252 | * type is eInterpolationCubic |
1253 | */ |
1254 | virtual float KeyGetRightTangentVelocity( int pIndex) const = 0; |
1255 | //@} |
1256 | |
1257 | /** |
1258 | * \name Evaluation and Analysis |
1259 | */ |
1260 | //@{ |
1261 | /** Evaluate animation curve value at a given time. |
1262 | * \param pTime Time of evaluation. |
1263 | * If time falls between two keys, animation curve value is |
1264 | * interpolated according to previous key interpolation type and |
1265 | * tangent mode if relevant. |
1266 | * \param pLast Index of the last processed key to speed up search. If this |
1267 | * function is called in a loop, initialize this value to 0 and let it |
1268 | * be updated by each call. |
1269 | * \return Animation curve value on given time, or animation curve's default value if animation curve |
1270 | * has no key. |
1271 | * \remarks This function takes extrapolation into account. |
1272 | */ |
1273 | virtual float Evaluate (FbxTime pTime, int* pLast = NULL) = 0; |
1274 | |
1275 | /** Evaluate animation curve value at a given key index. |
1276 | * \param pIndex Any value from 0 to FbxAnimCurve::KeyGetCount() - 1. |
1277 | * \return Animation curve value, or default value if animation curve |
1278 | * has no key. |
1279 | * |
1280 | * \remarks If key index is not an integer value, animation curve value is |
1281 | * interpolated according to previous key interpolation type and |
1282 | * tangent mode, if relevant. |
1283 | * This function does not take extrapolation into account. |
1284 | * Result is undetermined if index is out of bounds. |
1285 | */ |
1286 | virtual float EvaluateIndex( double pIndex) = 0; |
1287 | |
1288 | /** Evaluate function left derivative at given time. |
1289 | * \param pTime Time of evaluation. |
1290 | * \param pLast Index of the last processed key to speed up search. If this |
1291 | * function is called in a loop, initialize this value to 0 and let it |
1292 | * be updated by each call. |
1293 | * \return Left derivative at given time. |
1294 | * \remarks This function does not take extrapolation into account. |
1295 | * Result is undetermined if index is out of bounds. |
1296 | */ |
1297 | virtual float EvaluateLeftDerivative (FbxTime pTime, int* pLast = NULL) = 0; |
1298 | |
1299 | /** Evaluate function right derivative at given time. |
1300 | * \param pTime Time of evaluation. |
1301 | * \param pLast Index of the last processed key to speed up search. If this |
1302 | * function is called in a loop, initialize this value to 0 and let it |
1303 | * be updated by each call. |
1304 | * \return Right derivative at given time. |
1305 | * \remarks This function does not take extrapolation into account. |
1306 | * Result is undetermined if index is out of bounds. |
1307 | */ |
1308 | virtual float EvaluateRightDerivative (FbxTime pTime, int* pLast = NULL) = 0; |
1309 | //@} |
1310 | |
1311 | /** |
1312 | * \name Utility functions. |
1313 | * |
1314 | */ |
1315 | //@{ |
1316 | /** Find out start and end time of the animation animation curve. |
1317 | * This function retrieves the animation curve's time span. |
1318 | * \param pTimeInterval Reference to receive start and end time. |
1319 | * \return \c true on success, \c false otherwise. |
1320 | */ |
1321 | virtual bool GetTimeInterval(FbxTimeSpan& pTimeInterval) = 0; |
1322 | |
1323 | /** Copy animation curve content into current animation curve. |
1324 | * \param pSource Animation curve to be copied (which will not be modified). |
1325 | * \param pWithKeys If \c true, clear keys in current animation curve and copy |
1326 | * keys from source animation curve. If \c false, keys in current animation curve |
1327 | * are left as is. |
1328 | */ |
1329 | virtual void CopyFrom(FbxAnimCurve& pSource, bool pWithKeys = true) = 0; |
1330 | |
1331 | /** Retrieve the value of the parent curve node channel. |
1332 | * \param pCurveNodeIndex The index of the parent curve node, if more than one exist. |
1333 | * \return The value of the parent curve node channel of this curve. |
1334 | * \remark In most case, the curve will have a single curve node channel as destination. However, |
1335 | * it is possible that more are connected, hence why we provide the curve node index parameter. */ |
1336 | virtual float GetValue(int pCurveNodeIndex=0) = 0; |
1337 | |
1338 | /** Set the value to the parent curve node channel. |
1339 | * \param pValue The value to set to the parent curve node channel of this curve. |
1340 | * \param pCurveNodeIndex The index of the parent curve node, if more than one exist. |
1341 | * \remark In most case, the curve will have a single curve node channel as destination. However, |
1342 | * it is possible that more are connected, hence why we provide the curve node index parameter. */ |
1343 | virtual void SetValue(float pValue, int pCurveNodeIndex=0) = 0; |
1344 | //@} |
1345 | |
1346 | /***************************************************************************************************************************** |
1347 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
1348 | *****************************************************************************************************************************/ |
1349 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
1350 | virtual KFCurve* GetKFCurve() = 0; |
1351 | virtual bool Store(FbxIO* pFileObject, bool pLegacyVersion=false) = 0; |
1352 | virtual bool Retrieve(FbxIO* pFileObject) = 0; |
1353 | virtual void () = 0; |
1354 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
1355 | }; |
1356 | |
1357 | #include <fbxsdk/fbxsdk_nsend.h> |
1358 | |
1359 | #endif /* _FBXSDK_SCENE_ANIMATION_CURVE_H_ */ |
1360 | |