fbxcache.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_SCENE_GEOMETRY_CACHE_H_
00014 #define _FBXSDK_SCENE_GEOMETRY_CACHE_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/fbxobject.h>
00019 #include <fbxsdk/core/base/fbxerror.h>
00020 #include <fbxsdk/scene/fbxgroupname.h>
00021 
00022 #include <fbxsdk/fbxsdk_nsbegin.h>
00023 
00024 class FbxCache_internal;
00025 class FbxVertexCacheDeformer;
00026 
00039 class FBXSDK_DLL FbxCache : public FbxObject
00040 {
00041     FBXSDK_OBJECT_DECLARE(FbxCache,FbxObject);
00042 
00043 public:
00048 
00051         enum EFileFormat
00052         {
00053             eUnknownFileFormat, 
00054             eMaxPointCacheV2,   
00055             eMayaCache          
00056         };
00057 
00061         void SetCacheFileFormat(EFileFormat pFileFormat);
00062 
00066         EFileFormat GetCacheFileFormat() const;
00067 
00072         void SetCacheFileName(const char* pRelativeFileName_UTF8, const char* pAbsoluteFileName_UTF8);
00073 
00078         void GetCacheFileName(FbxString& pRelativeFileName_UTF8, FbxString& pAbsoluteFileName_UTF8) const;
00079 
00084         bool OpenFileForRead();
00085 
00089         bool IsOpen() const;
00090 
00094         bool CloseFile();
00095 
00099         double GetSamplingFrameRate();
00100 
00104         FbxTime GetCacheTimePerFrame();
00105 
00107 
00112 
00115         enum EMCFileCount
00116         {
00117             eMCOneFile,         
00118             eMCOneFilePerFrame  
00119         };
00120 
00123         enum EMCDataType
00124         {
00125             eUnknownData,       
00126             eDouble,            
00127             eDoubleArray,       
00128             eDoubleVectorArray, 
00129             eInt32Array,        
00130             eFloatArray,        
00131             eFloatVectorArray   
00132         };
00133 
00141         bool OpenFileForWrite(EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, EMCDataType pMCDataType = eDoubleVectorArray, const char* pInterpretation = "Points");
00142 
00152         bool AddChannel(const char* pChannelName, EMCDataType pMCDataType, const char* pInterpretation, unsigned int& pChannelIndex);     
00153 
00157         int  GetChannelCount();
00158 
00165         bool GetChannelName(int pChannelIndex, FbxString& pChannelName);
00166 
00173         bool GetChannelDataType(int pChannelIndex, EMCDataType& pChannelType);
00174 
00180         int  GetChannelIndex(const char* pChannelName);
00181 
00191         bool Read(int pChannelIndex, FbxTime& pTime, double* pBuffer, unsigned int pPointCount);
00192 
00202         bool Read(int pChannelIndex, FbxTime& pTime, float* pBuffer, unsigned int pPointCount);
00203 
00213         bool Read(int pChannelIndex, FbxTime& pTime, int* pBuffer, unsigned int pPointCount);
00214 
00221         bool BeginWriteAt( FbxTime& pTime );
00222 
00237         bool Write(int pChannelIndex, FbxTime& pTime, double* pBuffer, unsigned int pPointCount);
00238 
00253         bool Write(int pChannelIndex, FbxTime& pTime, float* pBuffer, unsigned int pPointCount);
00254 
00269         bool Write(int pChannelIndex, FbxTime& pTime, int* pBuffer, unsigned int pPointCount);
00270 
00277         bool EndWriteAt();
00278 
00286         bool GetAnimationRange(int pChannelIndex, FbxTime &pTimeStart, FbxTime &pTimeEnd);
00287 
00293         bool GetCacheType(EMCFileCount& pFileCount);
00294 
00301         bool GetChannelInterpretation(int pChannelIndex, FbxString& pInterpretation);
00302 
00305         enum EMCSamplingType
00306         {
00307             eSamplingRegular,   
00308             eSamplingIrregular  
00309         };
00310 
00318         bool GetChannelSamplingType(int pChannelIndex, EMCSamplingType& pSamplingType);
00319 
00327         bool GetChannelSamplingRate(int pChannelIndex, FbxTime& pSamplingRate);
00328 
00335         bool GetChannelSampleCount(int pChannelIndex, unsigned int& pSampleCount);
00336 
00344         bool GetChannelPointCount(int pChannelIndex, FbxTime pTime, unsigned int& pPointCount);
00345 
00350         int  GetCacheDataFileCount() const;
00351 
00360         bool GetCacheDataFileName(int pIndex, FbxString& pRelativeFileName, FbxString& pAbsoluteFileName);
00361 
00370         bool EnableMultiChannelFetching(bool pMultiChannelFetching);
00371         
00379         bool GetNextTimeWithData(FbxTime pCurTime, FbxTime& pNextTime, int pChannelIndex = -1);
00380         
00385         int GetDataCount(int pChannelIndex);
00386         
00393         bool GetDataTime(int pChannelIndex, unsigned int pDataIndex, FbxTime& pTime);
00394 
00396 
00401 
00410         bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount);
00411 
00415         unsigned int GetSampleCount();
00416 
00420         unsigned int GetPointCount();
00421 
00425         double GetFrameStartOffset();
00426 
00435         bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount);
00436 
00445         bool Write(unsigned int pFrameIndex, double* pBuffer);
00446 
00448 
00453 
00461         bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate);
00462 
00470         bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex);
00471 
00473 
00478 
00482         FbxError& GetError();
00483 
00486         enum EErrorCode
00487         {
00488             eUnsupportedArchitecture,       
00489             eInvalidAbsolutePath,           
00490             eInvalidSamplingRate,           
00491             eInvalidCacheFormat,            
00492             eUnsupportedFileVersion,        
00493             eConversionFromPC2Failed,       
00494             eConversionFromMCFailed,        
00495             eCacheFileNotFound,             
00496             eCacheFileNotOpened,            
00497             eCacheFileNotCreated,           
00498             eInvalidOpenFlag,               
00499             eErrorWritingSample,            
00500             eErrorReadingSample,            
00501             eErrorDataType,                 
00502             eErrorInvalidChannelIndex,      
00503             eErrorIrregularChannelSampling, 
00504             eErrorChannelInterpretation,    
00505             eErrorChannelSampling,          
00506             eErrorInvalidFileIndex,         
00507             eErrorCacheDataFileName,        
00508             eErrorChannelStartTime,         
00509             eErrorChannelPointCount,        
00510             eErrorInvalidTime,              
00511             eErrorBeginWriteAtNotCalled,    
00512             eErrorCount                     
00513         };
00514 
00518         EErrorCode GetLastErrorID() const;
00519 
00523         const char* GetLastErrorString() const;
00524 
00526 
00527 
00529 //
00530 //  WARNING!
00531 //
00532 //  Anything beyond these lines may not be documented accurately and is
00533 //  subject to change without notice.
00534 //
00536 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00537     
00538     static const char* sCacheFilePropertyName;
00539     static const char* sCacheFileAbsolutePathPropertyName;
00540     static const char* sCacheFileTypePropertyName;
00541     
00542     enum EOpenFlag
00543     {
00544         eReadOnly,
00545         eWriteOnly
00546     };
00547 
00548 protected:
00549     bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, const char* pInterpretation, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset, EMCDataType pMCDataType = eDoubleVectorArray); 
00550 
00551     FbxCache(FbxManager& pManager, char const* pName);
00552 
00553     virtual void Construct( const FbxCache* pFrom );
00554     virtual bool ConstructProperties( bool pForceSet );
00555     virtual void Destruct(bool pRecursive, bool pDependents);
00556 
00557     // Cache
00558     FbxCache_internal* mData;
00559 
00560 private:
00561     FbxPropertyT<FbxString> CacheFile;
00562     FbxPropertyT<FbxString> CacheFileAbsolutePath;
00563     FbxPropertyT<FbxEnum> CacheFileType;
00564 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00565 };
00566 
00567 inline EFbxType FbxTypeOf(const FbxCache::EFileFormat&){ return eFbxEnum; }
00568 
00569 #include <fbxsdk/fbxsdk_nsend.h>
00570 
00571 #endif /* _FBXSDK_SCENE_GEOMETRY_CACHE_H_ */