fbxtime.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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 fbxtime.h
  9. #ifndef _FBXSDK_CORE_BASE_TIME_H_
  10. #define _FBXSDK_CORE_BASE_TIME_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/core/base/fbxtimecode.h>
  13. #include <fbxsdk/core/base/fbxstring.h>
  14. #include <fbxsdk/fbxsdk_nsbegin.h>
  15. #define FBXSDK_TIME_INFINITE FbxTime(FBXSDK_TC_INFINITY)
  16. #define FBXSDK_TIME_MINUS_INFINITE FbxTime(FBXSDK_TC_MINFINITY)
  17. #define FBXSDK_TIME_ZERO FbxTime(FBXSDK_TC_ZERO)
  18. #define FBXSDK_TIME_EPSILON FbxTime(FBXSDK_TC_EPSILON)
  19. #define FBXSDK_TIME_ONE_SECOND FbxTime(FBXSDK_TC_SECOND)
  20. #define FBXSDK_TIME_ONE_MINUTE FbxTime(FBXSDK_TC_MINUTE)
  21. #define FBXSDK_TIME_ONE_HOUR FbxTime(FBXSDK_TC_HOUR)
  22. #define FBXSDK_TIME_ASSERT_EPSILON 0.5
  23. #define FBXSDK_TIME_FORWARD 1
  24. #define FBXSDK_TIME_BACKWARD -1
  25. class FbxTimeModeObject;
  26. /** Class to encapsulate time units.
  27. * \nosubgrouping
  28. * FbxTime can measure time in hour, minute, second, frame, field, residual and also combination of these units.
  29. * It is recommended to use FbxTime for all time related operations. For example, currently it is used in FbxGlobalSettings,
  30. * FbxGlobalTimeSettings, FbxCache, all curve filters and all animation-related classes, etc.
  31. * FbxTime is just used to represent a moment, to represent a period of time, FbxTimeSpan should be used.
  32. * \see FbxTimeSpan
  33. */
  34. class FBXSDK_DLL FbxTime
  35. {
  36. public:
  37. /** Long long constructor.
  38. * \param pTime Initial value defined as a 64bit integer.
  39. */
  40. FbxTime(const FbxLongLong pTime=0){ mTime = pTime; }
  41. /**
  42. * \name Time Modes and Protocols
  43. */
  44. //@{
  45. /** Time modes.
  46. * \remarks
  47. * EMode \c eNTSCDropFrame is used for broadcasting operations where
  48. * clock time must be (almost) in sync with time code. To bring back color
  49. * NTSC time code with clock time, this mode drops 2 frames per minute
  50. * except for every 10 minutes (00, 10, 20, 30, 40, 50). 108 frames are
  51. * dropped per hour. Over 24 hours the error is 2 frames and 1/4 of a
  52. * frame. A time-code of 01:00:03:18 equals a clock time of 01:00:00:00
  53. *
  54. * \par
  55. * EMode \c eNTSCFullFrame represents a time address and therefore is NOT
  56. * IN SYNC with clock time. A time code of 01:00:00:00 equals a clock time
  57. * of 01:00:03:18.
  58. *
  59. * - \e eDefaultMode
  60. * - \e eFrames120 120 frames/s
  61. * - \e eFrames100 100 frames/s
  62. * - \e eFrames60 60 frames/s
  63. * - \e eFrames50 50 frames/s
  64. * - \e eFrames48 48 frame/s
  65. * - \e eFrames30 30 frames/s (black and white NTSC)
  66. * - \e eFrames30Drop 30 frames/s (use when display in frame is selected, equivalent to NTSC drop)
  67. * - \e eNTSCDropFrame ~29.97 frames/s drop color NTSC
  68. * - \e eNTSCFullFrame ~29.97 frames/s color NTSC
  69. * - \e ePAL 25 frames/s PAL/SECAM
  70. * - \e eFrames24 24 frames/s Film/Cinema
  71. * - \e eFrames1000 1000 milli/s (use for date time)
  72. * - \e eFilmFullFrame ~23.976 frames/s
  73. * - \e eCustom Custom frame rate value
  74. * - \e eFrames96 96 frames/s
  75. * - \e eFrames72 72 frames/s
  76. * - \e eFrames59dot94 ~59.94 frames/s
  77. * - \e eModesCount Number of time modes
  78. */
  79. enum EMode
  80. {
  81. eDefaultMode,
  82. eFrames120,
  83. eFrames100,
  84. eFrames60,
  85. eFrames50,
  86. eFrames48,
  87. eFrames30,
  88. eFrames30Drop,
  89. eNTSCDropFrame,
  90. eNTSCFullFrame,
  91. ePAL,
  92. eFrames24,
  93. eFrames1000,
  94. eFilmFullFrame,
  95. eCustom,
  96. eFrames96,
  97. eFrames72,
  98. eFrames59dot94,
  99. eModesCount
  100. };
  101. /** Time protocols enumaration
  102. * - \e eSMPTE SMPTE EProtocol
  103. * - \e eFrameCount Frame count
  104. * - \e eDefaultProtocol Default protocol (initialized to eFRAMES)
  105. */
  106. enum EProtocol {eSMPTE, eFrameCount, eDefaultProtocol};
  107. /** Set default time mode.
  108. * \param pTimeMode Time mode identifier.
  109. * \param pFrameRate Custom framerate, only have effect in case of pTimeMode = FbxTime::eCustom
  110. * \remarks It is meaningless to set default time mode to \c eDefaultMode.
  111. */
  112. static void SetGlobalTimeMode(EMode pTimeMode, double pFrameRate=0.0);
  113. /** Get default time mode.
  114. * \return Currently set time mode identifier.
  115. * \remarks Default time mode initial value is eFrames30.
  116. */
  117. static EMode GetGlobalTimeMode();
  118. /** Set default time protocol.
  119. * \param pTimeProtocol Time protocol identifier.
  120. * \remarks It is meaningless to set default time protocol to \c eDefaultProtocol.
  121. */
  122. static void SetGlobalTimeProtocol(EProtocol pTimeProtocol);
  123. /** Get default time protocol.
  124. * \return Currently set time protocol identifier.
  125. * \remarks Default time protocol initial value is eSMPTE.
  126. */
  127. static EProtocol GetGlobalTimeProtocol();
  128. /** Get frame rate associated with time mode, in frames per second.
  129. * \param pTimeMode Time mode identifier.
  130. * \return Frame rate value.
  131. */
  132. static double GetFrameRate(EMode pTimeMode);
  133. /** Get time mode associated with frame rate.
  134. * \param pFrameRate The frame rate value.
  135. * \param pPrecision The tolerance value.
  136. * \return The corresponding time mode identifier or \c eDefaultMode if no time
  137. * mode associated to the given frame rate is found.
  138. */
  139. static EMode ConvertFrameRateToTimeMode(double pFrameRate, double pPrecision=0.00000001);
  140. //@}
  141. /**
  142. * \name Time Conversion
  143. */
  144. //@{
  145. /** Set time in internal format.
  146. * \param pTime Time value to set.
  147. */
  148. inline void Set(FbxLongLong pTime){ mTime = pTime; }
  149. /** Get time in internal format.
  150. * \return Time value.
  151. */
  152. inline FbxLongLong Get() const { return mTime; }
  153. /** Set time in milliseconds.
  154. * \param pMilliSeconds Time value to set.
  155. */
  156. inline void SetMilliSeconds(FbxLongLong pMilliSeconds){ mTime = pMilliSeconds * FBXSDK_TC_MILLISECOND; }
  157. /** Get time in milliseconds.
  158. * \return Time value.
  159. */
  160. inline FbxLongLong GetMilliSeconds() const { return mTime / FBXSDK_TC_MILLISECOND; }
  161. /** Set time in seconds.
  162. * \param pTime Time value to set.
  163. */
  164. void SetSecondDouble(double pTime);
  165. /** Get time in seconds.
  166. * \return Time value.
  167. */
  168. double GetSecondDouble() const;
  169. /** Set time in hour/minute/second/frame/field format.
  170. * \param pHour The hours value.
  171. * \param pMinute The minutes value.
  172. * \param pSecond The seconds value.
  173. * \param pFrame The frames values.
  174. * \param pField The field value.
  175. * \param pTimeMode Time mode identifier.
  176. * \remarks Parameters pHour, pMinute, pSecond, pFrame and pField are summed together.
  177. * For example, it is possible to set the time to 83 seconds in the following
  178. * ways: SetTime(0,1,23) or SetTime(0,0,83).
  179. */
  180. void SetTime(int pHour, int pMinute, int pSecond, int pFrame=0, int pField=0, EMode pTimeMode=eDefaultMode);
  181. /** Set time in hour/minute/second/frame/field/residual format.
  182. * \param pHour The hours value.
  183. * \param pMinute The minutes value.
  184. * \param pSecond The seconds value.
  185. * \param pFrame The frames values.
  186. * \param pField The field value.
  187. * \param pResidual The hundredths of frame value.
  188. * \param pTimeMode Time mode identifier.
  189. * \remarks Parameters pHour, pMinute, pSecond, pFrame, pField and pResidual
  190. * are summed together, just like above.
  191. * pResidual represents hundredths of frame, and won't necessarily
  192. * correspond to an exact internal value.
  193. *
  194. * \remarks The time mode can't have a default value, because
  195. * otherwise SetTime(int, int, int, int, int, int)
  196. * would be ambiguous. Please specify DEFAULT_MODE.
  197. */
  198. void SetTime(int pHour, int pMinute, int pSecond, int pFrame, int pField, int pResidual, EMode pTimeMode);
  199. /** Get time in hour/minute/second/frame/field/residual format.
  200. * \param pHour The returned hours value.
  201. * \param pMinute The returned minutes value.
  202. * \param pSecond The returned seconds value.
  203. * \param pFrame The returned frames values.
  204. * \param pField The returned field value.
  205. * \param pResidual The returned hundredths of frame value.
  206. * \param pTimeMode The time mode identifier which will dictate the extraction algorithm.
  207. * \return \c true if the pTimeMode parameter is a valid identifier and thus the extraction
  208. * succeeded. If the function returns \c false, all the values are set to 0.
  209. */
  210. bool GetTime(int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField, int& pResidual, EMode pTimeMode=eDefaultMode) const;
  211. /** Snaps a time value to the time value associated with the nearest frame.
  212. * \param pRound If \c true the return value is rounded to the nearest integer.
  213. * \return The snapped time value.
  214. */
  215. FbxTime GetFramedTime(bool pRound=true) const;
  216. /** Set time in frame format.
  217. * \param pFrames The number of frames.
  218. * \param pTimeMode The time mode identifier which will dictate the extraction algorithm.
  219. */
  220. void SetFrame(FbxLongLong pFrames, EMode pTimeMode=eDefaultMode);
  221. /** Set time in frame format, including fractions.
  222. * \param pFrames The number of frames in decimal value.
  223. * \param pTimeMode The time mode identifier which will dictate the extraction algorithm.
  224. */
  225. void SetFramePrecise(FbxDouble pFrames, EMode pTimeMode=eDefaultMode);
  226. /** Get number of hours in time.
  227. * \return Hours value.
  228. */
  229. int GetHourCount() const;
  230. /** Get number of minutes in time.
  231. * \return Minutes value.
  232. */
  233. int GetMinuteCount() const;
  234. /** Get number of seconds in time.
  235. * \return Seconds value.
  236. */
  237. int GetSecondCount() const;
  238. /** Get number of frames in time.
  239. * \param pTimeMode Time mode identifier.
  240. * \return Integer value representing the frame count.
  241. */
  242. FbxLongLong GetFrameCount(EMode pTimeMode=eDefaultMode) const;
  243. /** Get precise number of frames in time, including fractions.
  244. * \param pTimeMode Time mode identifier.
  245. * \return Decimal value representing the frame count, including fractions.
  246. */
  247. FbxDouble GetFrameCountPrecise(EMode pTimeMode=eDefaultMode) const;
  248. /** Get number of fields in time.
  249. * \param pTimeMode Time mode identifier.
  250. * \return Fields value.
  251. */
  252. FbxLongLong GetFieldCount(EMode pTimeMode=eDefaultMode) const;
  253. /** Get residual time exceeding last full field.
  254. * \param pTimeMode Time mode identifier.
  255. * \return Residual value.
  256. */
  257. int GetResidual(EMode pTimeMode=eDefaultMode) const;
  258. /** Test for Drop Frame mode
  259. * \param pTimeMode Time mode identifier.
  260. * \return True if the pTimeMode is a Drop Frame mode.
  261. */
  262. static bool IsDropFrame(EMode pTimeMode=eDefaultMode);
  263. /** Separator char between second and frame.
  264. * \param pTimeMode Time mode identifier.
  265. * \return ';' is returned if pTimeMode is a DropFrame mode otherwise ':'.
  266. */
  267. char GetFrameSeparator(EMode pTimeMode=eDefaultMode) const;
  268. /** Get time in a human readable format.
  269. * \param pTimeString An array large enough to contain a minimum of 19 characters.
  270. * \param pTimeStringSize Size of the pTimeString buffer used with secure functions.
  271. * \param pInfo The amount of information if time protocol is \c eSMPTE:
  272. * <ul><li>1 means hours only
  273. * <li>2 means hours and minutes
  274. * <li>3 means hours, minutes and seconds
  275. * <li>4 means hours, minutes, seconds and frames
  276. * <li>5 means hours, minutes, seconds, frames and field
  277. * <li>6 means hours, minutes, seconds, frames, field and residual value</ul>
  278. * \param pTimeMode Requested time mode.
  279. * \param pTimeFormat Requested time protocol.
  280. * \return pTimeString parameter filled with a time value or set to a empty string
  281. * if parameter pInfo is not valid.
  282. */
  283. char* GetTimeString(char* pTimeString, const FbxUShort& pTimeStringSize, int pInfo=5, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
  284. enum EElement {eHours, eMinutes, eSeconds, eFrames, eField, eResidual};
  285. /** Get the time in a human readable format.
  286. * \param pStart The starting element type used to format the time string.
  287. * \param pEnd The last element type used to format the time string.
  288. * \param pTimeMode The time mode requested.
  289. * \param pTimeFormat The time format requested.
  290. * \return The human readable time string. */
  291. FbxString GetTimeString(EElement pStart=eHours, EElement pEnd=eResidual, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
  292. /** Set time in a human readable format.
  293. * \param pTime An array of a maximum of 18 characters.
  294. * If time protocol is \c eSMPTE, pTimeString must be formatted this way:
  295. * "[hours:]minutes[:seconds[.frames[.fields]]]". Hours, minutes, seconds,
  296. * frames and fields are parsed as integers and brackets indicate optional
  297. * parts.
  298. * If time protocol is \c eFRAME, pTimeString must be formatted this way:
  299. * "frames". Frames is parsed as a 64 bits integer.
  300. * \param pTimeMode Given time mode.
  301. * \param pTimeFormat Given time protocol.
  302. * \return True if the set time string succeed, otherwise return false.
  303. */
  304. bool SetTimeString(const char* pTime, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol);
  305. //@}
  306. /**
  307. * \name Time Operators
  308. */
  309. //@{
  310. /** Equality operator.
  311. * \param pTime The FbxTime to be compared.
  312. * \return \c true if equal, \c false otherwise.
  313. */
  314. inline bool operator==(const FbxTime& pTime) const { return mTime == pTime.mTime; }
  315. /** Inequality operator.
  316. * \param pTime The FbxTime to be compared.
  317. * \return \c true if unequal, \c false otherwise.
  318. */
  319. inline bool operator!=(const FbxTime& pTime) const { return mTime != pTime.mTime; }
  320. /** Superior or equal to operator.
  321. * \param pTime The FbxTime to be compared.
  322. * \return \c true if this FbxTime is superior or equal to the passed FbxTime, \c false otherwise.
  323. */
  324. inline bool operator>=(const FbxTime& pTime) const { return mTime >= pTime.mTime; }
  325. /** Inferior or equal to operator.
  326. * \param pTime The FbxTime to be compared.
  327. * \return \c true if this FbxTime is inferior or equal to the passed FbxTime, \c false otherwise.
  328. */
  329. inline bool operator<=(const FbxTime& pTime) const { return mTime <= pTime.mTime; }
  330. /** Superior to operator.
  331. * \param pTime The FbxTime to be compared.
  332. * \return \c true if this FbxTime is superior to the passed FbxTime, \c false otherwise.
  333. */
  334. inline bool operator>(const FbxTime& pTime) const { return mTime > pTime.mTime; }
  335. /** Inferior to operator.
  336. * \param pTime The FbxTime to be compared.
  337. * \return \c true if this FbxTime is inferior to the passed FbxTime, \c false otherwise.
  338. */
  339. inline bool operator<(const FbxTime& pTime) const { return mTime < pTime.mTime; }
  340. /** Assignment operator.
  341. * \param pTime The FbxTime to be assigned.
  342. */
  343. inline FbxTime& operator=(const FbxTime& pTime) { mTime = pTime.mTime; return *this; }
  344. /** Addition operator.
  345. * \param pTime The FbxTime to be added.
  346. * \return This FbxTime after addition.
  347. */
  348. inline FbxTime& operator+=(const FbxTime& pTime) { mTime += pTime.mTime; return *this; }
  349. /** Subtraction operator.
  350. * \param pTime The FbxTime to be subtracted.
  351. * \return This FbxTime after subtraction.
  352. */
  353. inline FbxTime& operator-=(const FbxTime& pTime) { mTime -= pTime.mTime; return *this; }
  354. /** Addition operator.
  355. * \param pTime The FbxTime to be added.
  356. * \return A temporary FbxTime after addition.
  357. */
  358. FbxTime operator+(const FbxTime& pTime) const;
  359. /** Subtraction operator.
  360. * \param pTime The FbxTime to be subtracted.
  361. * \return A temporary FbxTime after subtraction.
  362. */
  363. FbxTime operator-(const FbxTime& pTime) const;
  364. /** Multiplication operator.
  365. * \param Mult Multiply this FbxTime by int Mult.
  366. * \return A temporary FbxTime after multiplication.
  367. */
  368. FbxTime operator*(const int Mult) const;
  369. /** Division operator.
  370. * \param pTime Divide this FbxTime by pTime.
  371. * \return A temporary FbxTime after division.
  372. */
  373. FbxTime operator/(const FbxTime& pTime) const;
  374. /** Multiplication operator.
  375. * \param pTime Multiply this FbxTime by pTime.
  376. * \return A temporary FbxTime after multiplication.
  377. */
  378. FbxTime operator*(const FbxTime& pTime) const;
  379. /*
  380. //! Increment time of one unit of the internal format (prefix form).
  381. inline FbxTime& operator++() { mTime += 1; return (*this); }
  382. //! Increment time of one unit of the internal format (postfix form).
  383. inline const FbxTime operator++(int) { FbxTime lOld = *this; ++(*this); return lOld; }
  384. //! Decrement time of one unit of the internal format (prefix form).
  385. inline FbxTime& operator--() { mTime -= 1; return (*this); }
  386. //! Decrement time of one unit of the internal format (postfix form).
  387. inline const FbxTime operator--(int) { FbxTime lOld = *this; --(*this); return lOld; }*/
  388. //@}
  389. /** One frame value for a specified time mode.
  390. * \param pTimeMode Time mode identifier.
  391. * \return the time code of a one frame.
  392. */
  393. static FbxLongLong GetOneFrameValue(EMode pTimeMode=eDefaultMode);
  394. /*****************************************************************************************************************************
  395. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  396. *****************************************************************************************************************************/
  397. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  398. // Keep compatibility with old fbx format
  399. enum EOldMode
  400. {
  401. eOLD_DEFAULT_MODE, //Default mode set using FbxTime::SetGlobalTimeMode(EMode pTimeMode)
  402. eOLD_CINEMA, //24 frameOLD_s/s
  403. eOLD_PAL, //25 frameOLD_s/s PAL/SECAM
  404. eOLD_FRAMES30, //30 frameOLD_s/s BLACK & WHITE NTSC
  405. eOLD_NTSC_DROP_FRAME, //29.97002617 frameOLD_s/s COLOR NTSC
  406. eOLD_FRAMES50, //50 frameOLD_s/s
  407. eOLD_FRAMES60, //60 frameOLD_s/s
  408. eOLD_FRAMES100, //100 frameOLD_s/s
  409. eOLD_FRAMES120, //120 frameOLD_s/s
  410. eOLD_NTSC_FULL_FRAME, //29.97002617 frameOLD_s/s COLOR NTSC
  411. eOLD_FRAMES30_DROP, //30 frameOLD_s/s
  412. eOLD_FRAMES1000 //1000 frameOLD_s/s
  413. };
  414. private:
  415. FbxLongLong mTime; //In 1 / 46,186,158,000 Seconds
  416. static EMode gsGlobalTimeMode;
  417. static EProtocol gsGlobalTimeProtocol;
  418. static FbxTimeModeObject* gsTimeObject;
  419. void InternalSetTime(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField, EMode pTimeMode);
  420. friend FBXSDK_DLL FbxTime::EMode FbxGetGlobalTimeMode();
  421. friend FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
  422. friend FBXSDK_DLL FbxTime::EProtocol FbxGetGlobalTimeFormat();
  423. friend FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate);
  424. friend FBXSDK_DLL void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
  425. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  426. };
  427. /** FbxTime in seconds constructor.
  428. * \param pTime
  429. */
  430. FBXSDK_DLL inline FbxTime FbxTimeSeconds(const FbxDouble& pTime=0.0)
  431. {
  432. FbxTime lTime;
  433. lTime.SetSecondDouble(pTime);
  434. return lTime;
  435. }
  436. /** Class to encapsulate time intervals.
  437. * \nosubgrouping
  438. * \see FbxTime
  439. */
  440. class FBXSDK_DLL FbxTimeSpan
  441. {
  442. public:
  443. //! Constructor.
  444. FbxTimeSpan() {}
  445. /** Constructor.
  446. * \param pStart Beginning of the time interval.
  447. * \param pStop Ending of the time interval.
  448. */
  449. FbxTimeSpan(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
  450. /** Set start and stop time.
  451. * \param pStart Beginning of the time interval.
  452. * \param pStop Ending of the time interval.
  453. */
  454. inline void Set(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
  455. /** Set start time.
  456. * \param pStart Beginning of the time interval.
  457. */
  458. inline void SetStart(FbxTime pStart){ mStart = pStart; }
  459. /** Set stop time.
  460. * \param pStop Ending of the time interval.
  461. */
  462. inline void SetStop(FbxTime pStop){ mStop = pStop; }
  463. /** Get start time.
  464. * \return Beginning of time interval.
  465. */
  466. inline FbxTime GetStart() const { return mStart; }
  467. /** Get stop time.
  468. * \return Ending of time interval.
  469. */
  470. inline FbxTime GetStop() const { return mStop; }
  471. /** Get time interval in absolute value.
  472. * \return Time interval.
  473. */
  474. inline FbxTime GetDuration() const { if( mStop > mStart ) return mStop - mStart; else return mStart - mStop; }
  475. /** Get time interval.
  476. * \return Signed time interval.
  477. */
  478. inline FbxTime GetSignedDuration() const { return mStop - mStart; }
  479. /** Get direction of the time interval.
  480. * \return \c FBXSDK_TIME_FORWARD if time interval is forward, \c FBXSDK_TIME_BACKWARD if backward.
  481. */
  482. inline int GetDirection() const { if( mStop >= mStart ) return FBXSDK_TIME_FORWARD; else return FBXSDK_TIME_BACKWARD; }
  483. /** Return \c true if the time is inside the timespan.
  484. * \param pTime Judge whether pTime is inside the timespan.
  485. * \return \c True if is, \c false otherwise.
  486. */
  487. bool IsInside(FbxTime pTime) const;
  488. /** Return the intersection of the two time spans.
  489. * \param pTime
  490. * \return The intersection of pTime and this FbxTimeSpan.
  491. */
  492. FbxTimeSpan Intersect(const FbxTimeSpan& pTime) const;
  493. /** Inequality operator.
  494. * \param pTime FbxTimeSpan compared with this one.
  495. * \return \c True if unequal, \c false otherwise.
  496. */
  497. bool operator!=(const FbxTimeSpan& pTime) const;
  498. /** Equality operator.
  499. * \param pTime FbxTimeSpan compared with this one.
  500. * \return \c True if equal, \c false otherwise.
  501. */
  502. bool operator==(const FbxTimeSpan& pTime) const;
  503. /** Unite with another FbxTimeSpan
  504. * \param pSpan The FbxTimeSpan
  505. * \param pDirection FBXSDK_TIME_FORWARD or FBXSDK_TIME_BACKWARD
  506. * \remarks This function assumes both of the FbxTimeSpan objects are in the same direction.
  507. * Use FBXSDK_TIME_FORWARD when start < stop in both timespan
  508. * Use FBXSDK_TIME_BACKWARD when start > stop in both timespan
  509. */
  510. void UnionAssignment(const FbxTimeSpan& pSpan, int pDirection=FBXSDK_TIME_FORWARD);
  511. /*****************************************************************************************************************************
  512. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  513. *****************************************************************************************************************************/
  514. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  515. private:
  516. FbxTime mStart;
  517. FbxTime mStop;
  518. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  519. };
  520. class FBXSDK_DLL FbxLocalTime
  521. {
  522. public:
  523. FbxLocalTime();
  524. int mYear;
  525. int mMonth;
  526. int mDay;
  527. int mHour;
  528. int mMinute;
  529. int mSecond;
  530. int mMillisecond;
  531. };
  532. FBXSDK_DLL void FbxGetCurrentLocalTime(FbxLocalTime& pLocalTime);
  533. FBXSDK_DLL FbxTime::EMode FbxGetGlobalTimeMode();
  534. FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
  535. FBXSDK_DLL FbxTime::EProtocol FbxGetGlobalTimeFormat();
  536. FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate=0.0);
  537. FBXSDK_DLL void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
  538. // Use those functions to keep the compatibility with old time mode since we added new time mode.
  539. FBXSDK_DLL FbxTime::EOldMode FbxGetOldTimeModeCorrespondance(FbxTime::EMode pMode);
  540. FBXSDK_DLL FbxTime::EMode FbxGetTimeModeFromOldValue(FbxTime::EOldMode pOldMode);
  541. // We now store the framerate instead of the time mode.
  542. FBXSDK_DLL FbxTime::EMode FbxGetTimeModeFromFrameRate(char* pFrameRate);
  543. FBXSDK_DLL void FbxGetControlStringList(char* pControlString, FbxTime::EProtocol pTimeFormat);
  544. FBXSDK_DLL const char* FbxGetGlobalFrameRateString(FbxTime::EMode pTimeMode);
  545. FBXSDK_DLL const char* FbxGetGlobalTimeModeString(FbxTime::EMode pTimeMode);
  546. FBXSDK_DLL double FbxGetFrameRate(FbxTime::EMode pTimeMode);
  547. // Time format
  548. FBXSDK_DLL FbxTime::EProtocol FbxSelectionToTimeFormat(int pSelection);
  549. FBXSDK_DLL FbxTime::EMode FbxSelectionToTimeMode(int pSelection);
  550. FBXSDK_DLL int FbxTimeToSelection(FbxTime::EMode pTimeMode=FbxTime::eDefaultMode, int pTimeFormat=FbxTime::eDefaultProtocol);
  551. FBXSDK_DLL const char* FbxGetTimeModeName(FbxTime::EMode pTimeMode);
  552. FBXSDK_DLL int FbxGetFrameRateStringListIndex(FbxTime::EMode pTimeMode);
  553. FBXSDK_DLL bool FbxIsValidCustomFrameRate(double pFramerate);
  554. FBXSDK_DLL bool FbxGetNearestCustomFrameRate(double pFramerate, double& pNearestRate);
  555. #include <fbxsdk/fbxsdk_nsend.h>
  556. #endif /* _FBXSDK_CORE_BASE_TIME_H_ */