fbxanimcurve.h 59 KB

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