kfbxcache.h

Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_CACHE_H_ 
00005 #define _FBXSDK_CACHE_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2006 - 2007 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 
00064 class KFBX_DLL KFbxCache : public KFbxObject
00065 {
00066     KFBXOBJECT_DECLARE(KFbxCache);
00067 
00068 public:
00073 
00079     typedef enum    
00080     {
00081         eUNKNOWN,
00082         ePC2,
00083         eMC
00084     } EFileFormat;
00085 
00089     void SetCacheFileFormat(EFileFormat pFileFormat);
00090 
00094     EFileFormat GetCacheFileFormat();   
00095 
00100     void SetCacheFileName(const char* pRelativeFileName, const char* pAbsoluteFileName);
00101 
00106     void GetCacheFileName(KString& pRelativeFileName, KString& pAbsoluteFileName);
00107 
00112     bool OpenFileForRead();
00113 
00117     bool IsOpen();
00118 
00122     bool CloseFile();
00123 
00125 
00130 
00135     typedef enum 
00136     {
00137         eMC_ONE_FILE,
00138         eMC_ONE_FILE_PER_FRAME
00139     } EMCFileCount; 
00140 
00146     bool OpenFileForWrite(EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName);    
00147 
00151     int  GetChannelCount();
00152     
00159     bool GetChannelName(int pChannelIndex, KString& pChannelName);
00160     
00166     int  GetChannelIndex(const char* pChannelName);
00167     
00177     bool Read(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00178     
00188     bool Write(int pChannelIndex, KTime& pTime, double* pBuffer, unsigned int pPointCount);
00189 
00191 
00196 
00205     bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount); 
00206     
00210     unsigned int GetSampleCount();
00211     
00215     unsigned int GetPointCount();
00216     
00220     double GetFrameStartOffset();
00221     
00225     double GetSamplingFrameRate();
00226     
00235     bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount);
00236     
00245     bool Write(unsigned int pFrameIndex, double* pBuffer);
00246 
00248 
00253 
00261     bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate);
00262     
00270     bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex);
00271 
00273 
00278 
00282     KError& GetError();
00283 
00300     typedef enum 
00301     {
00302         eUNSUPPORTED_ARCHITECTURE,
00303         eINVALID_ABSOLUTE_PATH,
00304         eINVALID_SAMPLING_RATE,
00305         eINVALID_CACHE_FORMAT,
00306         eUNSUPPORTED_FILE_VERSION,
00307         eCONVERSION_FROM_PC2_FAILED,
00308         eCONVERSION_FROM_MC_FAILED,
00309         eCACHE_FILE_NOT_FOUND,
00310         eCACHE_FILE_NOT_OPENED,
00311         eCACHE_FILE_NOT_CREATED,
00312         eINVALID_OPEN_FLAG,
00313         eERROR_WRITING_SAMPLE,
00314         eERROR_READING_SAMPLE,
00315         eERROR_COUNT
00316     } EError;   
00317 
00321     EError GetLastErrorID();
00322 
00326     char* GetLastErrorString();
00327 
00329 
00331     KFbxCache& operator=( const KFbxCache& pOther );
00332 
00336     virtual KFbxObject::ENameSpace GetNameSpace() const;
00337 
00339 //
00340 //  WARNING!
00341 //
00342 //  Anything beyond these lines may not be documented accurately and is 
00343 //  subject to change without notice.
00344 //
00346 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00347     static const char* CacheFilePropertyName;
00348     static const char* CacheFileAbsolutePathPropertyName;
00349     static const char* CacheFileTypePropertyName;
00350 
00351     // Clone
00352     virtual KFbxObject* Clone(KFbxObject::ECloneType pCloneType) const;
00353 
00354     void FillPropertyList(void* pPropertyList);
00355 
00356     typedef enum
00357     {
00358         _O_RDONLY,
00359         _O_WRONLY
00360     } EOpenFlag;
00361 
00362 protected:
00363     bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset); 
00364 
00365     static char const* GetNamePrefix() { return CACHE_PREFIX; }
00366 
00367     KFbxCache(KFbxSdkManager& pManager, char const* pName);
00368     virtual ~KFbxCache();
00369 
00370     virtual void Destruct(bool pRecursive, bool pDependents);
00371 
00372     // Properties Handler
00373     virtual KObject* GetFbxObject_internal();
00374     virtual KObject const*  GetFbxObject_internal() const;
00375 
00376     // Cache
00377     KFbxCache_internal* mData;
00378 
00379     friend class KFbxReaderFbx;
00380     friend class KFbxReaderFbx6;
00381     friend class KFbxWriterFbx;
00382     friend class KFbxWriterFbx6;
00383 
00384 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00385 };
00386 
00387 typedef KFbxCache* HKFbxCache;
00388 
00389 #include <fbxfilesdk_nsend.h>
00390 
00391 #endif //_FBXSDK_CACHE_H_