kfbxcache.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXCACHE_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXCACHE_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2001 - 2010 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxgroupname.h>
00045 
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047 
00048 class KFbxCache_internal;
00049 class KFbxVertexCacheDeformer;
00050 
00062 class KFBX_DLL KFbxCache : public KFbxObject
00063 {
00064     KFBXOBJECT_DECLARE(KFbxCache,KFbxObject);
00065 
00066 public:
00071 
00077         typedef enum
00078         {
00079             eUNKNOWN,
00080             ePC2,
00081             eMC
00082         } EFileFormat;
00083 
00087         void SetCacheFileFormat(EFileFormat pFileFormat);
00088 
00092         EFileFormat GetCacheFileFormat() const;
00093 
00098         void SetCacheFileName(const char* pRelativeFileName, const char* pAbsoluteFileName);
00099 
00104         void GetCacheFileName(KString& pRelativeFileName, KString& pAbsoluteFileName) const;
00105 
00110         bool OpenFileForRead();
00111 
00115         bool IsOpen() const;
00116 
00120         bool CloseFile();
00121 
00125         double GetSamplingFrameRate();
00126 
00130         KTime GetCacheTimePerFrame();
00131 
00133 
00138 
00143         typedef enum
00144         {
00145             eMC_ONE_FILE,
00146             eMC_ONE_FILE_PER_FRAME
00147         } EMCFileCount;
00148 
00158         typedef enum
00159         {
00160             kUnknownData,
00161             kDouble,             // not used
00162             kDoubleArray,        //KArrayTemplate<kDouble>
00163             kDoubleVectorArray,  //KArrayTemplate<fbxDouble3> 
00164             kInt32Array,         //KArrayTemplate<kInt>
00165             kFloatArray,    
00166             kFloatVectorArray    //KArrayTemplate<fbxFloat3>
00167         }EMCDataType;
00168 
00176         bool OpenFileForWrite(EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, EMCDataType pMCDataType = kDoubleVectorArray, const char* pInterpretation = "Points");
00177 
00187         bool AddChannel(const char* pChannelName, EMCDataType pMCDataType, const char* pInterpretation, unsigned int& pChannelIndex);     
00188 
00192         int  GetChannelCount();
00193 
00200         bool GetChannelName(int pChannelIndex, KString& pChannelName);
00201 
00208         bool GetChannelDataType(int pChannelIndex, EMCDataType& pChannelType);
00209 
00210 
00216         int  GetChannelIndex(const char* pChannelName);
00217 
00227         bool Read(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00228 
00238         bool Read(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00239 
00249         bool Read(int pChannelIndex, KTime& pTime, int* pBuffer, unsigned int pPointCount);
00250 
00257         bool BeginWriteAt( KTime& pTime );
00258 
00273         bool Write(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00274 
00289         bool Write(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00290 
00305         bool Write(int pChannelIndex, KTime& pTime, int* pBuffer, unsigned int pPointCount);
00306 
00313         bool EndWriteAt();
00314 
00322         bool GetAnimationRange(int pChannelIndex, KTime &pTimeStart, KTime &pTimeEnd);
00323 
00329         bool GetCacheType(EMCFileCount& pFileCount);
00330 
00337         bool GetChannelInterpretation(int pChannelIndex, KString& pInterpretation);
00338 
00343         typedef enum
00344         {
00345             eSAMPLING_REGULAR,
00346             eSAMPLING_IRREGULAR
00347         }EMCSamplingType;
00348 
00356         bool GetChannelSamplingType(int pChannelIndex, EMCSamplingType& pSamplingType);
00357 
00365         bool GetChannelSamplingRate(int pChannelIndex, KTime& pSamplingRate);
00366 
00373         bool GetChannelSampleCount(int pChannelIndex, unsigned int& pSampleCount);
00374 
00382         bool GetChannelPointCount(int pChannelIndex, KTime pTime, unsigned int& pPointCount);
00383 
00388         int  GetCacheDataFileCount() const;
00389 
00398         bool GetCacheDataFileName(int pIndex, KString& pRelativeFileName, KString& pAbsoluteFileName);
00399 
00408         bool EnableMultiChannelFetching(bool pMultiChannelFetching);
00409         
00417         bool GetNextTimeWithData(KTime pCurTime, KTime& pNextTime, int pChannelIndex = -1);
00418         
00423         int GetDataCount(int pChannelIndex);
00424         
00431         bool GetDataTime(int pChannelIndex, unsigned int pDataIndex, KTime& pTime);
00432 
00434 
00439 
00448         bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount);
00449 
00453         unsigned int GetSampleCount();
00454 
00458         unsigned int GetPointCount();
00459 
00463         double GetFrameStartOffset();
00464 
00473         bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount);
00474 
00483         bool Write(unsigned int pFrameIndex, double* pBuffer);
00484 
00486 
00491 
00499         bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate);
00500 
00508         bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex);
00509 
00511 
00516 
00520         KError& GetError();
00521 
00549         typedef enum
00550         {
00551             eUNSUPPORTED_ARCHITECTURE,
00552             eINVALID_ABSOLUTE_PATH,
00553             eINVALID_SAMPLING_RATE,
00554             eINVALID_CACHE_FORMAT,
00555             eUNSUPPORTED_FILE_VERSION,
00556             eCONVERSION_FROM_PC2_FAILED,
00557             eCONVERSION_FROM_MC_FAILED,
00558             eCACHE_FILE_NOT_FOUND,
00559             eCACHE_FILE_NOT_OPENED,
00560             eCACHE_FILE_NOT_CREATED,
00561             eINVALID_OPEN_FLAG,
00562             eERROR_WRITING_SAMPLE,
00563             eERROR_READING_SAMPLE,
00564             eERROR_DATATYPE,
00565             eERROR_INVALIDCHANNELINDEX,
00566             eERROR_IRREGULARCHANNELSAMPLING,
00567             eERROR_CHANNELINTERPRETATION,
00568             eERROR_CHANNELSAMPLING,
00569             eERROR_INVALID_FILEINDEX,
00570             eERROR_CACHEDATAFILENAME,
00571             eERROR_CHANNELSTARTTIME,
00572             eERROR_CHANNELPOINTCOUNT,
00573             eERROR_INVALIDTIME,
00574             eERROR_BEGINWRITEAT_NOTCALLED,
00575             eERROR_COUNT
00576         } EError;
00577 
00581         EError GetLastErrorID() const;
00582 
00586         const char* GetLastErrorString() const;
00587 
00589 
00590 
00592 //
00593 //  WARNING!
00594 //
00595 //  Anything beyond these lines may not be documented accurately and is
00596 //  subject to change without notice.
00597 //
00599 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00600     
00601     static const char* sCacheFilePropertyName;
00602     static const char* sCacheFileAbsolutePathPropertyName;
00603     static const char* sCacheFileTypePropertyName;
00604     
00605     typedef enum
00606     {
00607         eO_RDONLY,
00608         eO_WRONLY
00609     } EOpenFlag;
00610 
00611 protected:
00612     bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, const char* pInterpretation, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset, EMCDataType pMCDataType = kDoubleVectorArray); 
00613 
00614     KFbxCache(KFbxSdkManager& pManager, char const* pName);
00615 
00616     virtual void Construct( const KFbxCache* pFrom );
00617     virtual bool ConstructProperties( bool pForceSet );
00618     virtual void Destruct(bool pRecursive, bool pDependents);
00619 
00620     // Cache
00621     KFbxCache_internal* mData;
00622 
00623 private:
00624     KFbxTypedProperty<fbxString> CacheFile;
00625     KFbxTypedProperty<fbxString> CacheFileAbsolutePath;
00626     KFbxTypedProperty<fbxEnum> CacheFileType;
00627 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00628 };
00629 
00630 typedef KFbxCache* HKFbxCache;
00631 
00632 inline EFbxType FbxTypeOf( KFbxCache::EFileFormat const &pItem )            { return eENUM; }
00633 
00634 
00635 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00636 
00637 #endif // FBXFILESDK_KFBXPLUGINS_KFBXCACHE_H
00638