00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXCACHE_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXCACHE_H
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
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,             
00162             kDoubleArray,         
00163             kDoubleVectorArray,  
00164             kInt32Array,         
00165             kFloatArray,
00166             kFloatVectorArray    
00167         }EMCDataType;
00168 
00175         bool OpenFileForWrite(EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, EMCDataType pMCDataType = kDoubleVectorArray );     
00176 
00180         int  GetChannelCount();
00181 
00188         bool GetChannelName(int pChannelIndex, KString& pChannelName);
00189 
00196         bool GetChannelDataType(int pChannelIndex, EMCDataType& pChannelType);
00197 
00198 
00204         int  GetChannelIndex(const char* pChannelName);
00205 
00215         bool Read(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00216 
00226         bool Read(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00227 
00237         bool Read(int pChannelIndex, KTime& pTime, int* pBuffer, unsigned int pPointCount);
00238 
00248         bool Write(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00249 
00259         bool Write(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00260 
00270         bool Write(int pChannelIndex, KTime& pTime, int* pBuffer, unsigned int pPointCount);
00271 
00279         bool GetAnimationRange(int pChannelIndex, KTime &pTimeStart, KTime &pTimeEnd);
00280 
00286         bool GetCacheType(EMCFileCount& pFileCount);
00287 
00294         bool GetChannelInterpretation(int pChannelIndex, KString& pInterpretation);
00295 
00300         typedef enum
00301         {
00302             eSAMPLING_REGULAR,
00303             eSAMPLING_IRREGULAR
00304         }EMCSamplingType;
00305 
00313         bool GetChannelSamplingType(int pChannelIndex, EMCSamplingType& pSamplingType);
00314 
00322         bool GetChannelSamplingRate(int pChannelIndex, KTime& pSamplingRate);
00323 
00330         bool GetChannelSampleCount(int pChannelIndex, unsigned int& pSampleCount);
00331 
00339         bool GetChannelPointCount(int pChannelIndex, KTime pTime, unsigned int& pPointCount);
00340 
00345         int  GetCacheDataFileCount() const;
00346 
00355         bool GetCacheDataFileName(int pIndex, KString& pRelativeFileName, KString& pAbsoluteFileName);
00356 
00365         bool EnableMultiChannelFetching(bool pMultiChannelFetching);
00366 
00368 
00373 
00382         bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount);
00383 
00387         unsigned int GetSampleCount();
00388 
00392         unsigned int GetPointCount();
00393 
00397         double GetFrameStartOffset();
00398 
00407         bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount);
00408 
00417         bool Write(unsigned int pFrameIndex, double* pBuffer);
00418 
00420 
00425 
00433         bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate);
00434 
00442         bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex);
00443 
00445 
00450 
00454         KError& GetError();
00455 
00482         typedef enum
00483         {
00484             eUNSUPPORTED_ARCHITECTURE,
00485             eINVALID_ABSOLUTE_PATH,
00486             eINVALID_SAMPLING_RATE,
00487             eINVALID_CACHE_FORMAT,
00488             eUNSUPPORTED_FILE_VERSION,
00489             eCONVERSION_FROM_PC2_FAILED,
00490             eCONVERSION_FROM_MC_FAILED,
00491             eCACHE_FILE_NOT_FOUND,
00492             eCACHE_FILE_NOT_OPENED,
00493             eCACHE_FILE_NOT_CREATED,
00494             eINVALID_OPEN_FLAG,
00495             eERROR_WRITING_SAMPLE,
00496             eERROR_READING_SAMPLE,
00497             eERROR_DATATYPE,
00498             eERROR_INVALIDCHANNELINDEX,
00499             eERROR_IRREGULARCHANNELSAMPLING,
00500             eERROR_CHANNELINTERPRETATION,
00501             eERROR_CHANNELSAMPLING,
00502             eERROR_INVALID_FILEINDEX,
00503             eERROR_CACHEDATAFILENAME,
00504             eERROR_CHANNELSTARTTIME,
00505             eERROR_CHANNELPOINTCOUNT,
00506             eERROR_INVALIDTIME,
00507             eERROR_COUNT
00508         } EError;
00509 
00513         EError GetLastErrorID() const;
00514 
00518         const char* GetLastErrorString() const;
00519 
00521 
00522 
00524 
00525 
00526 
00527 
00528 
00529 
00531 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00532     static const char* CacheFilePropertyName;
00533     static const char* CacheFileAbsolutePathPropertyName;
00534     static const char* CacheFileTypePropertyName;
00535 
00536     
00537     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00538 
00539     typedef enum
00540     {
00541         _O_RDONLY,
00542         _O_WRONLY
00543     } EOpenFlag;
00544 
00545 protected:
00546     bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset, EMCDataType pMCDataType = kDoubleVectorArray); 
00547 
00548     KFbxCache(KFbxSdkManager& pManager, char const* pName);
00549 
00550     virtual void Construct( const KFbxCache* pFrom );
00551     virtual bool ConstructProperties( bool pForceSet );
00552     virtual void Destruct(bool pRecursive, bool pDependents);
00553 
00554     
00555     KFbxCache_internal* mData;
00556 
00557 private:
00558     KFbxTypedProperty<fbxString> CacheFile;
00559     KFbxTypedProperty<fbxString> CacheFileAbsolutePath;
00560     KFbxTypedProperty<fbxEnum> CacheFileType;
00561 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00562 };
00563 
00564 typedef KFbxCache* HKFbxCache;
00565 
00566 inline EFbxType FbxTypeOf( KFbxCache::EFileFormat const &pItem )            { return eENUM; }
00567 
00568 
00569 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00570 
00571 #endif // FBXFILESDK_KFBXPLUGINS_KFBXCACHE_H
00572