FBX SDK Reference Guide: kfbxcache.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_CACHE_H_
00005 #define _FBXSDK_CACHE_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2001 - 2008 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 <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,             //kDouble
00166         kDoubleArray,         //KArrayTemplate<kDouble>
00167         kDoubleVectorArray,  //KArrayTemplate<fbxDouble3> 
00168         kInt32Array,         //KArrayTemplate<kInt>
00169         kFloatVectorArray    //KArrayTemplate<fbxFloat3>
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 //  WARNING!
00516 //
00517 //  Anything beyond these lines may not be documented accurately and is
00518 //  subject to change without notice.
00519 //
00521 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00522     static const char* CacheFilePropertyName;
00523     static const char* CacheFileAbsolutePathPropertyName;
00524     static const char* CacheFileTypePropertyName;
00525 
00526     // Clone
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     // Cache
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_