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 - 2009 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 
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,             //kDouble
00162         kDoubleArray,         //KArrayTemplate<kDouble>
00163         kDoubleVectorArray,  //KArrayTemplate<fbxDouble3> 
00164         kInt32Array,         //KArrayTemplate<kInt>
00165         kFloatVectorArray    //KArrayTemplate<fbxFloat3>
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 Read(int pChannelIndex, KTime& pTime, int* pBuffer, unsigned int pPointCount);
00237 
00247     bool Write(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00248 
00258     bool Write(int pChannelIndex, KTime& pTime, float* pBuffer, unsigned int pPointCount);
00259 
00269     bool Write(int pChannelIndex, KTime& pTime, int* pBuffer, unsigned int pPointCount);
00270 
00278     bool GetAnimationRange(int pChannelIndex, KTime &pTimeStart, KTime &pTimeEnd);
00279 
00285     bool GetCacheType(EMCFileCount& pFileCount);
00286 
00293     bool GetChannelInterpretation(int pChannelIndex, KString& pInterpretation);
00294 
00299     typedef enum
00300     {
00301         eSAMPLING_REGULAR,
00302         eSAMPLING_IRREGULAR
00303     }EMCSamplingType;
00304 
00312     bool GetChannelSamplingType(int pChannelIndex, EMCSamplingType& pSamplingType);
00313 
00321     bool GetChannelSamplingRate(int pChannelIndex, KTime& pSamplingRate);
00322 
00329     bool GetChannelSampleCount(int pChannelIndex, unsigned int& pSampleCount);
00330 
00338     bool GetChannelPointCount(int pChannelIndex, KTime pTime, unsigned int& pPointCount);
00339 
00344     int  GetCacheDataFileCount();
00345 
00354     bool GetCacheDataFileName(int pIndex, KString& pRelativeFileName, KString& pAbsoluteFileName);
00355 
00364     bool EnableMultiChannelFetching(bool pMultiChannelFetching);
00365 
00367 
00372 
00381     bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount);
00382 
00386     unsigned int GetSampleCount();
00387 
00391     unsigned int GetPointCount();
00392 
00396     double GetFrameStartOffset();
00397 
00406     bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount);
00407 
00416     bool Write(unsigned int pFrameIndex, double* pBuffer);
00417 
00419 
00424 
00432     bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate);
00433 
00441     bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex);
00442 
00444 
00449 
00453     KError& GetError();
00454 
00481     typedef enum
00482     {
00483         eUNSUPPORTED_ARCHITECTURE,
00484         eINVALID_ABSOLUTE_PATH,
00485         eINVALID_SAMPLING_RATE,
00486         eINVALID_CACHE_FORMAT,
00487         eUNSUPPORTED_FILE_VERSION,
00488         eCONVERSION_FROM_PC2_FAILED,
00489         eCONVERSION_FROM_MC_FAILED,
00490         eCACHE_FILE_NOT_FOUND,
00491         eCACHE_FILE_NOT_OPENED,
00492         eCACHE_FILE_NOT_CREATED,
00493         eINVALID_OPEN_FLAG,
00494         eERROR_WRITING_SAMPLE,
00495         eERROR_READING_SAMPLE,
00496         eERROR_DATATYPE,
00497         eERROR_INVALIDCHANNELINDEX,
00498         eERROR_IRREGULARCHANNELSAMPLING,
00499         eERROR_CHANNELINTERPRETATION,
00500         eERROR_CHANNELSAMPLING,
00501         eERROR_INVALID_FILEINDEX,
00502         eERROR_CACHEDATAFILENAME,
00503         eERROR_CHANNELSTARTTIME,
00504         eERROR_CHANNELPOINTCOUNT,
00505         eERROR_INVALIDTIME,
00506         eERROR_COUNT
00507     } EError;
00508 
00512     EError GetLastErrorID() const;
00513 
00517     const char* GetLastErrorString() const;
00518 
00520 
00524     KFbxCache& operator=( const KFbxCache& pOther );
00525 
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     static const char* CacheFilePropertyName;
00538     static const char* CacheFileAbsolutePathPropertyName;
00539     static const char* CacheFileTypePropertyName;
00540 
00541     // Clone
00542     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00543 
00544     typedef enum
00545     {
00546         _O_RDONLY,
00547         _O_WRONLY
00548     } EOpenFlag;
00549 
00550 protected:
00551     bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset, EMCDataType pMCDataType = kDoubleVectorArray); 
00552 
00553     KFbxCache(KFbxSdkManager& pManager, char const* pName);
00554 
00555     virtual void Construct( const KFbxCache* pFrom );
00556     virtual bool ConstructProperties( bool pForceSet );
00557     virtual void Destruct(bool pRecursive, bool pDependents);
00558 
00559     // Cache
00560     KFbxCache_internal* mData;
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