00001
00004 #ifndef _FBXSDK_CACHE_H_
00005 #define _FBXSDK_CACHE_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
00042 #include <kaydaradef.h>
00043 #ifndef KFBX_DLL
00044 #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046
00047 #include <kaydara.h>
00048 #include <kfbxplugins/kfbxobject.h>
00049 #include <kfbxplugins/kfbxgroupname.h>
00050
00051 #include <fbxfilesdk_nsbegin.h>
00052
00053 class KFbxCache_internal;
00054 class KFbxVertexCacheDeformer;
00055
00067 class KFBX_DLL KFbxCache : public KFbxObject
00068 {
00069 KFBXOBJECT_DECLARE(KFbxCache,KFbxObject);
00070
00071 public:
00076
00082 typedef enum
00083 {
00084 eUNKNOWN,
00085 ePC2,
00086 eMC
00087 } EFileFormat;
00088
00092 void SetCacheFileFormat(EFileFormat pFileFormat);
00093
00097 EFileFormat GetCacheFileFormat();
00098
00103 void SetCacheFileName(const char* pRelativeFileName, const char* pAbsoluteFileName);
00104
00109 void GetCacheFileName(KString& pRelativeFileName, KString& pAbsoluteFileName);
00110
00115 bool OpenFileForRead();
00116
00120 bool IsOpen();
00121
00125 bool CloseFile();
00126
00130 double GetSamplingFrameRate();
00131
00135 KTime GetCacheTimePerFrame();
00136
00138
00143
00148 typedef enum
00149 {
00150 eMC_ONE_FILE,
00151 eMC_ONE_FILE_PER_FRAME
00152 } EMCFileCount;
00153
00162 typedef enum
00163 {
00164 kUnknownData,
00165 kDouble,
00166 kDoubleArray,
00167 kDoubleVectorArray,
00168 kInt32Array,
00169 kFloatVectorArray
00170 }EMCDataType;
00171
00178 bool OpenFileForWrite(EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, EMCDataType pMCDataType = kDoubleVectorArray );
00179
00183 int GetChannelCount();
00184
00191 bool GetChannelName(int pChannelIndex, KString& pChannelName);
00192
00199 bool GetChannelDataType(int pChannelIndex, EMCDataType& pChannelType);
00200
00201
00207 int GetChannelIndex(const char* pChannelName);
00208
00218 bool Read(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00219
00229 bool Read(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00230
00240 bool Write(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00241
00251 bool Write(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00252
00260 bool GetAnimationRange(int pChannelIndex, KTime &pTimeStart, KTime &pTimeEnd);
00261
00267 bool GetCacheType(EMCFileCount& pFileCount);
00268
00275 bool GetChannelInterpretation(int pChannelIndex, KString& pInterpretation);
00276
00281 typedef enum
00282 {
00283 eSAMPLING_REGULAR,
00284 eSAMPLING_IRREGULAR
00285 }EMCSamplingType;
00286
00294 bool GetChannelSamplingType(int pChannelIndex, EMCSamplingType& pSamplingType);
00295
00303 bool GetChannelSamplingRate(int pChannelIndex, KTime& pSamplingRate);
00304
00311 bool GetChannelSampleCount(int pChannelIndex, unsigned int& pSampleCount);
00312
00320 bool GetChannelPointCount(int pChannelIndex, KTime pTime, unsigned int& pPointCount);
00321
00326 int GetCacheDataFileCount();
00327
00336 bool GetCacheDataFileName(int pIndex, KString& pRelativeFileName, KString& pAbsoluteFileName);
00337
00346 bool EnableMultiChannelFetching(bool pMultiChannelFetching);
00347
00349
00354
00363 bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount);
00364
00368 unsigned int GetSampleCount();
00369
00373 unsigned int GetPointCount();
00374
00378 double GetFrameStartOffset();
00379
00380
00393 bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount);
00394
00403 bool Write(unsigned int pFrameIndex, double* pBuffer);
00404
00406
00411
00419 bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate);
00420
00428 bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex);
00429
00431
00436
00440 KError& GetError();
00441
00468 typedef enum
00469 {
00470 eUNSUPPORTED_ARCHITECTURE,
00471 eINVALID_ABSOLUTE_PATH,
00472 eINVALID_SAMPLING_RATE,
00473 eINVALID_CACHE_FORMAT,
00474 eUNSUPPORTED_FILE_VERSION,
00475 eCONVERSION_FROM_PC2_FAILED,
00476 eCONVERSION_FROM_MC_FAILED,
00477 eCACHE_FILE_NOT_FOUND,
00478 eCACHE_FILE_NOT_OPENED,
00479 eCACHE_FILE_NOT_CREATED,
00480 eINVALID_OPEN_FLAG,
00481 eERROR_WRITING_SAMPLE,
00482 eERROR_READING_SAMPLE,
00483 eERROR_DATATYPE,
00484 eERROR_INVALIDCHANNELINDEX,
00485 eERROR_IRREGULARCHANNELSAMPLING,
00486 eERROR_CHANNELINTERPRETATION,
00487 eERROR_CHANNELSAMPLING,
00488 eERROR_INVALID_FILEINDEX,
00489 eERROR_CACHEDATAFILENAME,
00490 eERROR_CHANNELSTARTTIME,
00491 eERROR_CHANNELPOINTCOUNT,
00492 eERROR_INVALIDTIME,
00493 eERROR_COUNT
00494 } EError;
00495
00499 EError GetLastErrorID() const;
00500
00504 const char* GetLastErrorString() const;
00505
00507
00509 KFbxCache& operator=( const KFbxCache& pOther );
00510
00511
00512
00514
00515
00516
00517
00518
00519
00521 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00522 static const char* CacheFilePropertyName;
00523 static const char* CacheFileAbsolutePathPropertyName;
00524 static const char* CacheFileTypePropertyName;
00525
00526
00527 virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00528
00529 typedef enum
00530 {
00531 _O_RDONLY,
00532 _O_WRONLY
00533 } EOpenFlag;
00534
00535 protected:
00536 bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset, EMCDataType pMCDataType = kDoubleVectorArray);
00537
00538
00539 KFbxCache(KFbxSdkManager& pManager, char const* pName);
00540 virtual ~KFbxCache();
00541
00542 virtual void Construct( const KFbxCache* pFrom );
00543 virtual bool ConstructProperties( bool pForceSet );
00544 virtual void Destruct(bool pRecursive, bool pDependents);
00545
00546
00547 KFbxCache_internal* mData;
00548
00549 friend class KFbxReaderFbx;
00550 friend class KFbxReaderFbx6;
00551 friend class KFbxWriterFbx;
00552 friend class KFbxWriterFbx6;
00553
00554 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00555 };
00556
00557 typedef KFbxCache* HKFbxCache;
00558
00559 inline EFbxType FbxTypeOf( KFbxCache::EFileFormat const &pItem ) { return eENUM; }
00560
00561
00562 #include <fbxfilesdk_nsend.h>
00563
00564 #endif //_FBXSDK_CACHE_H_