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
00042 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <fbxfilesdk/components/kbaselib/kaydara.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00045 #include <fbxfilesdk/kfbxplugins/kfbxgroupname.h>
00046
00047 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00048
00049 class KFbxCache_internal;
00050 class KFbxVertexCacheDeformer;
00051
00063 class KFBX_DLL KFbxCache : public KFbxObject
00064 {
00065 KFBXOBJECT_DECLARE(KFbxCache,KFbxObject);
00066
00067 public:
00072
00078 typedef enum
00079 {
00080 eUNKNOWN,
00081 ePC2,
00082 eMC
00083 } EFileFormat;
00084
00088 void SetCacheFileFormat(EFileFormat pFileFormat);
00089
00093 EFileFormat GetCacheFileFormat();
00094
00099 void SetCacheFileName(const char* pRelativeFileName, const char* pAbsoluteFileName);
00100
00105 void GetCacheFileName(KString& pRelativeFileName, KString& pAbsoluteFileName);
00106
00111 bool OpenFileForRead();
00112
00116 bool IsOpen();
00117
00121 bool CloseFile();
00122
00126 double GetSamplingFrameRate();
00127
00131 KTime GetCacheTimePerFrame();
00132
00134
00139
00144 typedef enum
00145 {
00146 eMC_ONE_FILE,
00147 eMC_ONE_FILE_PER_FRAME
00148 } EMCFileCount;
00149
00158 typedef enum
00159 {
00160 kUnknownData,
00161 kDouble,
00162 kDoubleArray,
00163 kDoubleVectorArray,
00164 kInt32Array,
00165 kFloatVectorArray
00166 }EMCDataType;
00167
00174 bool OpenFileForWrite(EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, EMCDataType pMCDataType = kDoubleVectorArray );
00175
00179 int GetChannelCount();
00180
00187 bool GetChannelName(int pChannelIndex, KString& pChannelName);
00188
00195 bool GetChannelDataType(int pChannelIndex, EMCDataType& pChannelType);
00196
00197
00203 int GetChannelIndex(const char* pChannelName);
00204
00214 bool Read(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00215
00225 bool Read(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00226
00236 bool Write(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00237
00247 bool Write(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00248
00256 bool GetAnimationRange(int pChannelIndex, KTime &pTimeStart, KTime &pTimeEnd);
00257
00263 bool GetCacheType(EMCFileCount& pFileCount);
00264
00271 bool GetChannelInterpretation(int pChannelIndex, KString& pInterpretation);
00272
00277 typedef enum
00278 {
00279 eSAMPLING_REGULAR,
00280 eSAMPLING_IRREGULAR
00281 }EMCSamplingType;
00282
00290 bool GetChannelSamplingType(int pChannelIndex, EMCSamplingType& pSamplingType);
00291
00299 bool GetChannelSamplingRate(int pChannelIndex, KTime& pSamplingRate);
00300
00307 bool GetChannelSampleCount(int pChannelIndex, unsigned int& pSampleCount);
00308
00316 bool GetChannelPointCount(int pChannelIndex, KTime pTime, unsigned int& pPointCount);
00317
00322 int GetCacheDataFileCount();
00323
00332 bool GetCacheDataFileName(int pIndex, KString& pRelativeFileName, KString& pAbsoluteFileName);
00333
00342 bool EnableMultiChannelFetching(bool pMultiChannelFetching);
00343
00345
00350
00359 bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount);
00360
00364 unsigned int GetSampleCount();
00365
00369 unsigned int GetPointCount();
00370
00374 double GetFrameStartOffset();
00375
00376
00389 bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount);
00390
00399 bool Write(unsigned int pFrameIndex, double* pBuffer);
00400
00402
00407
00415 bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate);
00416
00424 bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex);
00425
00427
00432
00436 KError& GetError();
00437
00464 typedef enum
00465 {
00466 eUNSUPPORTED_ARCHITECTURE,
00467 eINVALID_ABSOLUTE_PATH,
00468 eINVALID_SAMPLING_RATE,
00469 eINVALID_CACHE_FORMAT,
00470 eUNSUPPORTED_FILE_VERSION,
00471 eCONVERSION_FROM_PC2_FAILED,
00472 eCONVERSION_FROM_MC_FAILED,
00473 eCACHE_FILE_NOT_FOUND,
00474 eCACHE_FILE_NOT_OPENED,
00475 eCACHE_FILE_NOT_CREATED,
00476 eINVALID_OPEN_FLAG,
00477 eERROR_WRITING_SAMPLE,
00478 eERROR_READING_SAMPLE,
00479 eERROR_DATATYPE,
00480 eERROR_INVALIDCHANNELINDEX,
00481 eERROR_IRREGULARCHANNELSAMPLING,
00482 eERROR_CHANNELINTERPRETATION,
00483 eERROR_CHANNELSAMPLING,
00484 eERROR_INVALID_FILEINDEX,
00485 eERROR_CACHEDATAFILENAME,
00486 eERROR_CHANNELSTARTTIME,
00487 eERROR_CHANNELPOINTCOUNT,
00488 eERROR_INVALIDTIME,
00489 eERROR_COUNT
00490 } EError;
00491
00495 EError GetLastErrorID() const;
00496
00500 const char* GetLastErrorString() const;
00501
00503
00507 KFbxCache& operator=( const KFbxCache& pOther );
00508
00509
00510
00512
00513
00514
00515
00516
00517
00519 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00520 static const char* CacheFilePropertyName;
00521 static const char* CacheFileAbsolutePathPropertyName;
00522 static const char* CacheFileTypePropertyName;
00523
00524
00525 virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00526
00527 typedef enum
00528 {
00529 _O_RDONLY,
00530 _O_WRONLY
00531 } EOpenFlag;
00532
00533 protected:
00534 bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset, EMCDataType pMCDataType = kDoubleVectorArray);
00535
00536
00537 KFbxCache(KFbxSdkManager& pManager, char const* pName);
00538 virtual ~KFbxCache();
00539
00540 virtual void Construct( const KFbxCache* pFrom );
00541 virtual bool ConstructProperties( bool pForceSet );
00542 virtual void Destruct(bool pRecursive, bool pDependents);
00543
00544
00545 KFbxCache_internal* mData;
00546 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00547 };
00548
00549 typedef KFbxCache* HKFbxCache;
00550
00551 inline EFbxType FbxTypeOf( KFbxCache::EFileFormat const &pItem ) { return eENUM; }
00552
00553
00554 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00555
00556 #endif // FBXFILESDK_KFBXPLUGINS_KFBXCACHE_H
00557