- Main Page
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# fbxtime.h

Go to the documentation of this file.

    00001 /****************************************************************************************
    00002
    00003    Copyright (C) 2012 Autodesk, Inc.
    00004    All rights reserved.
    00005
    00006    Use of this software is subject to the terms of the Autodesk license agreement
    00007    provided at the time of installation or download, or which otherwise accompanies
    00008    this software in either electronic or hard copy form.
    00009
    00010 ****************************************************************************************/
    00011
    00013 #ifndef _FBXSDK_CORE_BASE_TIME_H_
    00014 #define _FBXSDK_CORE_BASE_TIME_H_
    00015
    00016 #include <fbxsdk/fbxsdk_def.h>
    00017
    00018 #include <fbxsdk/core/base/fbxtimecode.h>
    00019
    00020 #include <fbxsdk/fbxsdk_nsbegin.h>
    00021
    00022 #define FBXSDK_TIME_INFINITE        FbxTime(FBXSDK_TC_INFINITY)
    00023 #define FBXSDK_TIME_MINUS_INFINITE  FbxTime(FBXSDK_TC_MINFINITY)
    00024 #define FBXSDK_TIME_ZERO            FbxTime(FBXSDK_TC_ZERO)
    00025 #define FBXSDK_TIME_EPSILON         FbxTime(FBXSDK_TC_EPSILON)
    00026 #define FBXSDK_TIME_ONE_SECOND      FbxTime(FBXSDK_TC_SECOND)
    00027 #define FBXSDK_TIME_ASSERT_EPSILON  0.5
    00028 #define FBXSDK_TIME_FORWARD         1
    00029 #define FBXSDK_TIME_BACKWARD        -1
    00030
    00031 class FbxTimeModeObject;
    00032
    00041 class FBXSDK_DLL FbxTime
    00042 {
    00043 public:
    00047     FbxTime(const FbxLongLong& pTime=0){ mTime = pTime; }
    00048
    00087         enum EMode
    00088         {
    00089             eDefaultMode,
    00090             eFrames120,
    00091             eFrames100,
    00092             eFrames60,
    00093             eFrames50,
    00094             eFrames48,
    00095             eFrames30,
    00096             eFrames30Drop,
    00097             eNTSCDropFrame,
    00098             eNTSCFullFrame,
    00099             ePAL,
    00100             eFrames24,
    00101             eFrames1000,
    00102             eFilmFullFrame,
    00103             eCustom,
    00104             eFrames96,
    00105             eFrames72,
    00106             eFrames59dot94,
    00107             eModesCount
    00108         };
    00109
    00115         enum EProtocol {eSMPTE, eFrameCount, eDefaultProtocol};
    00116
    00122         static void SetGlobalTimeMode(EMode pTimeMode, double pFrameRate=0.0);
    00123
    00128         static EMode GetGlobalTimeMode();
    00129
    00134         static void SetGlobalTimeProtocol(EProtocol pTimeProtocol);
    00135
    00140         static EProtocol GetGlobalTimeProtocol();
    00141
    00146         static double GetFrameRate(EMode pTimeMode);
    00147
    00154         static EMode ConvertFrameRateToTimeMode(double pFrameRate, double pPrecision=0.00000001);
    00156
    00164         inline void Set(FbxLongLong pTime){ mTime = pTime; }
    00165
    00169         inline const FbxLongLong& Get() const { return mTime; }
    00170
    00174         inline void SetMilliSeconds(FbxLongLong pMilliSeconds){ mTime = pMilliSeconds * FBXSDK_TC_MILLISECOND; }
    00175
    00179         inline FbxLongLong GetMilliSeconds() const { return mTime / FBXSDK_TC_MILLISECOND; }
    00180
    00184         void SetSecondDouble(double pTime);
    00185
    00189         double GetSecondDouble() const;
    00190
    00202         void SetTime(int pHour, int pMinute, int pSecond, int pFrame=0, int pField=0, EMode pTimeMode=eDefaultMode);
    00203
    00221         void SetTime(int pHour, int pMinute, int pSecond, int pFrame, int pField, int pResidual, EMode pTimeMode);
    00222
    00234         bool GetTime(int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField, int& pResidual, EMode pTimeMode=eDefaultMode) const;
    00235
    00240         FbxTime GetFramedTime(bool pRound=true);
    00241
    00246         void SetFrame(FbxLongLong pFrames, EMode pTimeMode=eDefaultMode);
    00247
    00251         int GetHourCount() const;
    00252
    00256         int GetMinuteCount() const;
    00257
    00261         int GetSecondCount() const;
    00262
    00268         FbxLongLong GetFrameCount(EMode pTimeMode=eDefaultMode) const;
    00269
    00274         FbxLongLong GetFieldCount(EMode pTimeMode=eDefaultMode) const;
    00275
    00280         int GetResidual(EMode pTimeMode=eDefaultMode) const;
    00281
    00286         static bool IsDropFrame(EMode pTimeMode=eDefaultMode);
    00287
    00292         char GetFrameSeparator(EMode pTimeMode=eDefaultMode) const;
    00293
    00309         FBX_DEPRECATED char* GetTimeString(char* pTimeString, int pInfo=5, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
    00310
    00326         char* GetTimeString(char* pTimeString, const FbxUShort& pTimeStringSize, int pInfo=5, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
    00327
    00340         bool SetTimeString(const char* pTime, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol);
    00342
    00351         inline bool operator==(const FbxTime& pTime) const { return mTime == pTime.mTime; }
    00352
    00357         inline bool operator!=(const FbxTime& pTime) const { return mTime != pTime.mTime; }
    00358
    00363         inline bool operator>=(const FbxTime& pTime) const { return mTime >= pTime.mTime; }
    00364
    00369         inline bool operator<=(const FbxTime& pTime) const { return mTime <= pTime.mTime; }
    00370
    00375         inline bool operator>(const FbxTime& pTime) const { return mTime > pTime.mTime; }
    00376
    00381         inline bool operator<(const FbxTime& pTime) const { return mTime < pTime.mTime; }
    00382
    00386         inline FbxTime& operator=(const FbxTime& pTime) { mTime = pTime.mTime; return *this; }
    00387
    00392         inline FbxTime& operator+=(const FbxTime& pTime) { mTime += pTime.mTime; return *this; }
    00393
    00398         inline FbxTime& operator-=(const FbxTime& pTime) { mTime -= pTime.mTime; return *this; }
    00399
    00404         FbxTime operator+(const FbxTime& pTime) const;
    00405
    00410         FbxTime operator-(const FbxTime& pTime) const;
    00411
    00416         FbxTime operator*(const int Mult) const;
    00417
    00422         FbxTime operator/(const FbxTime& pTime) const;
    00423
    00428         FbxTime operator*(const FbxTime& pTime) const;
    00429 /*
    00431         inline FbxTime& operator++() { mTime += 1; return (*this); }
    00432
    00434         inline const FbxTime operator++(int) { FbxTime lOld = *this; ++(*this); return lOld; }
    00435
    00437         inline FbxTime& operator--() { mTime -= 1; return (*this); }
    00438
    00440         inline const FbxTime operator--(int) { FbxTime lOld = *this; --(*this); return lOld; }*/
    00442
    00447     static FbxLongLong GetOneFrameValue(EMode pTimeMode=eDefaultMode);
    00448
    00450 //
    00451 //  WARNING!
    00452 //
    00453 //  Anything beyond these lines may not be documented accurately and is
    00454 //  subject to change without notice.
    00455 //
    00457 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00458     // Keep compatibility with old fbx format
    00459     enum EOldMode
    00460     {
    00461         eOLD_DEFAULT_MODE,      //Default mode set using FbxTime::SetGlobalTimeMode(EMode pTimeMode)
    00462         eOLD_CINEMA,            //24 frameOLD_s/s
    00463         eOLD_PAL,               //25 frameOLD_s/s    PAL/SECAM
    00464         eOLD_FRAMES30,          //30 frameOLD_s/s    BLACK & WHITE NTSC
    00465         eOLD_NTSC_DROP_FRAME,   //29.97002617 frameOLD_s/s COLOR NTSC
    00466         eOLD_FRAMES50,          //50 frameOLD_s/s
    00467         eOLD_FRAMES60,          //60 frameOLD_s/s
    00468         eOLD_FRAMES100,         //100 frameOLD_s/s
    00469         eOLD_FRAMES120,         //120 frameOLD_s/s
    00470         eOLD_NTSC_FULL_FRAME,   //29.97002617 frameOLD_s/s COLOR NTSC
    00471         eOLD_FRAMES30_DROP,     //30 frameOLD_s/s
    00472         eOLD_FRAMES1000         //1000 frameOLD_s/s
    00473     };
    00474
    00475 private:
    00476     FbxLongLong                 mTime; //In 1 / 46,186,158,000 Seconds
    00477
    00478     static EMode                    gsGlobalTimeMode;
    00479     static EProtocol                gsGlobalTimeProtocol;
    00480     static FbxTimeModeObject*   gsTimeObject;
    00481
    00482     void InternalSetTime(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField, EMode pTimeMode);
    00483
    00484     friend FBXSDK_DLL FbxTime::EMode            FbxGetGlobalTimeMode();
    00485     friend FBXSDK_DLL FbxTimeModeObject*    FbxGetGlobalTimeModeObject();
    00486     friend FBXSDK_DLL FbxTime::EProtocol        FbxGetGlobalTimeFormat();
    00487     friend FBXSDK_DLL void                  FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate);
    00488     friend FBXSDK_DLL void                  FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
    00489 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00490 };
    00491
    00495 FBXSDK_DLL inline FbxTime FbxTimeSeconds(const FbxDouble& pTime=0.0)
    00496 {
    00497     FbxTime lTime;
    00498     lTime.SetSecondDouble(pTime);
    00499     return lTime;
    00500 }
    00501
    00506 class FBXSDK_DLL FbxTimeSpan
    00507 {
    00508 public:
    00510     FbxTimeSpan() {}
    00511
    00516     FbxTimeSpan(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
    00517
    00522     inline void Set(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
    00523
    00527     inline void SetStart(FbxTime pStart){ mStart = pStart; }
    00528
    00532     inline void SetStop(FbxTime pStop){ mStop = pStop; }
    00533
    00537     inline FbxTime GetStart() const { return mStart; }
    00538
    00542     inline FbxTime GetStop() const { return mStop; }
    00543
    00547     inline FbxTime GetDuration() const { if( mStop > mStart ) return mStop - mStart; else return mStart - mStop; }
    00548
    00552     inline FbxTime GetSignedDuration() const { return mStop - mStart; }
    00553
    00557     inline int GetDirection() const { if( mStop >= mStart ) return FBXSDK_TIME_FORWARD; else return FBXSDK_TIME_BACKWARD; }
    00558
    00563     bool IsInside(FbxTime pTime) const;
    00564
    00569     FbxTimeSpan Intersect(const FbxTimeSpan& pTime) const;
    00570
    00575     bool operator!=(const FbxTimeSpan& pTime) const;
    00576
    00581     bool operator==(const FbxTimeSpan& pTime) const;
    00582
    00590     void UnionAssignment(const FbxTimeSpan& pSpan, int pDirection=FBXSDK_TIME_FORWARD);
    00591
    00593 //
    00594 //  WARNING!
    00595 //
    00596 //  Anything beyond these lines may not be documented accurately and is
    00597 //  subject to change without notice.
    00598 //
    00600 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00601 private:
    00602     FbxTime mStart;
    00603     FbxTime mStop;
    00604 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00605 };
    00606
    00607 class FBXSDK_DLL FbxLocalTime
    00608 {
    00609 public:
    00610     FbxLocalTime();
    00611
    00612     int mYear;
    00613     int mMonth;
    00614     int mDay;
    00615     int mHour;
    00616     int mMinute;
    00617     int mSecond;
    00618     int mMillisecond;
    00619 };
    00620
    00621 FBXSDK_DLL void                 FbxGetCurrentLocalTime(FbxLocalTime& pLocalTime);
    00622
    00623 FBXSDK_DLL FbxTime::EMode       FbxGetGlobalTimeMode();
    00624 FBXSDK_DLL FbxTimeModeObject*   FbxGetGlobalTimeModeObject();
    00625 FBXSDK_DLL FbxTime::EProtocol   FbxGetGlobalTimeFormat();
    00626 FBXSDK_DLL void                 FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate=0.0);
    00627 FBXSDK_DLL void                 FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
    00628
    00629 // Use those functions to keep the compatibility with old time mode since we added new time mode.
    00630 FBXSDK_DLL FbxTime::EOldMode        FbxGetOldTimeModeCorrespondance(FbxTime::EMode pMode);
    00631 FBXSDK_DLL FbxTime::EMode       FbxGetTimeModeFromOldValue(FbxTime::EOldMode pOldMode);
    00632
    00633 // We now store the framerate instead of the time mode.
    00634 FBXSDK_DLL FbxTime::EMode       FbxGetTimeModeFromFrameRate(char* pFrameRate);
    00635 FBXSDK_DLL void                 FbxGetControlStringList(char* pControlString, FbxTime::EProtocol pTimeFormat);
    00636 FBXSDK_DLL const char*          FbxGetGlobalFrameRateString(FbxTime::EMode pTimeMode);
    00637 FBXSDK_DLL const char*          FbxGetGlobalTimeModeString(FbxTime::EMode pTimeMode);
    00638 FBXSDK_DLL double               FbxGetFrameRate(FbxTime::EMode pTimeMode);
    00639
    00640 // Time format
    00641 FBXSDK_DLL FbxTime::EProtocol   FbxSelectionToTimeFormat(int pSelection);
    00642 FBXSDK_DLL FbxTime::EMode       FbxSelectionToTimeMode(int pSelection);
    00643 FBXSDK_DLL int                  FbxTimeToSelection(FbxTime::EMode pTimeMode=FbxTime::eDefaultMode, int pTimeFormat=FbxTime::eDefaultProtocol);
    00644 FBXSDK_DLL const char*          FbxGetTimeModeName(FbxTime::EMode pTimeMode);
    00645 FBXSDK_DLL int                  FbxGetFrameRateStringListIndex(FbxTime::EMode pTimeMode);
    00646 FBXSDK_DLL bool                 FbxIsValidCustomFrameRate(double pFramerate);
    00647 FBXSDK_DLL bool                 FbxGetNearestCustomFrameRate(double pFramerate, double& pNearestRate);
    00648
    00649 #include <fbxsdk/fbxsdk_nsend.h>
    00650
    00651 #endif /* _FBXSDK_CORE_BASE_TIME_H_ */