00001
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXSDKMANAGER_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXSDKMANAGER_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 #include <fbxfilesdk/fbxfilesdk_def.h>
00042
00043 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxmemoryallocator.h>
00045 #include <fbxfilesdk/kfbxplugins/kfbxgeometryconverter.h>
00046 #include <fbxfilesdk/kfbxplugins/kfbxproperty.h>
00047 #include <fbxfilesdk/kfbxplugins/kfbxtypes.h>
00048 #include <fbxfilesdk/kfbxplugins/kfbxlayer.h>
00049
00050 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00051
00052
00053 class KFbxIOPluginRegistry;
00054 class KFbxUserNotification;
00055 class KFbxMessageEmitter;
00056 class KFbxIOSettings;
00057 class KFbxSdkManager_internal;
00058 class KFbxPreviewManager;
00059 class KFbxXRefManager;
00060 class KFbxLocalizationManager;
00061 class KFbxPlugin;
00062 class KFbxAnimStack;
00063 class KFbxReference;
00064
00078 class KFBX_DLL KFbxSdkManager
00079 {
00080 public:
00085
00096 static bool SetMemoryAllocator(KFbxMemoryAllocator* pMemoryAllocator);
00098
00099
00108 static KFbxSdkManager* Create();
00109
00113 virtual void Destroy();
00114
00120 static void GetFileFormatVersion(int& pMajor, int& pMinor, int& pRevision);
00122
00123
00128 public:
00137 template <typename T1,typename T2> inline kFbxClassId RegisterFbxClass(char const *pName,T1 const *pFBX_TYPE_Class,T2 const *pFBX_TYPE_ParentClass,const char *pFbxFileTypeName=0,const char *pFbxFileSubTypeName=0) {
00138 T1::ClassId = Internal_RegisterFbxClass(pName,T2::ClassId,(kFbxPlugConstructor)T1::SdkManagerCreate,pFbxFileTypeName,pFbxFileSubTypeName );
00139 return T1::ClassId;
00140 }
00141
00149 template <typename T> inline kFbxClassId RegisterRuntimeFbxClass(char const *pName,T const *pFBX_TYPE_ParentClass,const char *pFbxFileTypeName=0,const char *pFbxFileSubTypeName=0) {
00150 return Internal_RegisterFbxClass(pName,T::ClassId,(kFbxPlugConstructor)T::SdkManagerCreate,pFbxFileTypeName,pFbxFileSubTypeName );
00151 }
00152
00156 inline void UnregisterRuntimeFbxClass(char const* pName)
00157 {
00158 kFbxClassId lClassId = FindClass(pName);
00159
00160 if( !(lClassId == kFbxClassId()) )
00161 {
00162 Internal_UnregisterFbxClass(lClassId);
00163 }
00164 }
00165
00171 template <typename T1,typename T2> inline kFbxClassId OverrideFbxClass(T1 const *pFBX_TYPE_Class,T2 const *pFBX_TYPE_OverridenClass) {
00172 T1::ClassId = Internal_OverrideFbxClass(T2::ClassId,(kFbxPlugConstructor)T1::SdkManagerCreate );
00173 return T1::ClassId;
00174 }
00175
00182 KFbxPlug* CreateClass(kFbxClassId pClassId, char const *pName, const char* pFBXType=0, const char* pFBXSubType=0);
00183
00191 KFbxPlug* CreateClass(KFbxObject* pContainer, kFbxClassId pClassId, const char* pName, const char* pFBXType=0, const char* pFBXSubType=0);
00192
00196 kFbxClassId FindClass(const char* pClassName) const;
00197
00202 kFbxClassId FindFbxFileClass(const char* pFbxFileTypeName, const char* pFbxFileSubTypeName) const;
00203
00207 template <typename T> inline void UnregisterFbxClass( T const* pFBX_TYPE_Class )
00208 {
00209 Internal_UnregisterFbxClass( T::ClassId );
00210 T::ClassId = kFbxClassId();
00211 }
00212
00214
00219 public:
00223 KError& GetError();
00224
00227 typedef enum
00228 {
00229 eOBJECT_NOT_FOUND,
00230 eNAME_ALREADY_IN_USE,
00231 eERROR_COUNT
00232 } EError;
00233
00237 EError GetLastErrorID() const;
00238
00242 const char* GetLastErrorString() const;
00243
00245
00255 KFbxDataType CreateFbxDataType(const char *pName,EFbxType pType);
00256
00261 KFbxDataType const &GetFbxDataTypeFromName(const char *pDataType);
00262
00266 int GetFbxDataTypeCount() const;
00267
00272 KFbxDataType &GetFbxDataType(int pIndex);
00274
00275
00284 KFbxUserNotification* GetUserNotification() const;
00285
00289 void SetUserNotification(KFbxUserNotification* pUN);
00291
00300 virtual KFbxIOSettings * GetIOSettings() const;
00301
00305 virtual void SetIOSettings(KFbxIOSettings * pIOSettings);
00307
00308
00316 KFbxMessageEmitter & GetMessageEmitter();
00321 bool SetMessageEmitter(KFbxMessageEmitter * pMessageEmitter);
00323
00324 private:
00325 KArrayTemplate<KFbxLocalizationManager *> mKFbxLocalizations;
00326 public:
00334 void AddLocalization( KFbxLocalizationManager * pLocManager );
00338 void RemoveLocalization( KFbxLocalizationManager * pLocManager );
00342 bool SetLocale( const char * pLocale );
00349 const char * Localize( const char * pID, const char * pDefault = NULL) const;
00351
00356
00360 KFbxPreviewManager& GetPreviewManager();
00361
00363
00371 KFbxXRefManager& GetXRefManager();
00373
00381 KFbxLibrary* GetRootLibrary() const;
00382 KFbxLibrary* GetSystemLibraries() const;
00383 KFbxLibrary* GetUserLibraries() const;
00385
00393 KFbxIOPluginRegistry* GetIOPluginRegistry() const;
00395
00405 bool LoadPluginsDirectory (char *pFilename,char *pExtensions);
00406
00411 bool LoadPlugin (char *pFilename);
00412
00415 bool UnloadPlugins();
00416
00420 bool EmitPluginsEvent(KFbxEventBase const &pEvent);
00421
00423 KArrayTemplate<KFbxPlugin const*> GetPlugins() const;
00424
00428 int GetPluginCount() const;
00429
00435 KFbxPlugin* FindPlugin(const char* pName, const char* pVersion) const;
00437
00438
00443
00444
00448 void FillIOSettingsForReadersRegistered(KFbxIOSettings & pIOS);
00449
00453 void FillIOSettingsForWritersRegistered(KFbxIOSettings & pIOS);
00454
00459 void FillCommonIOSettings(KFbxIOSettings & pIOS, bool pImport);
00460
00461 private:
00462
00466 void Create_Common_Import_IOSettings_Groups(KFbxIOSettings & pIOS);
00467
00471 void Create_Common_Export_IOSettings_Groups(KFbxIOSettings & pIOS);
00472
00476 void Add_Common_Import_IOSettings(KFbxIOSettings & pIOS);
00477
00481 void Add_Common_Export_IOSettings(KFbxIOSettings & pIOS);
00482
00486 void Add_Common_RW_Import_IOSettings(KFbxIOSettings & pIOS);
00487
00491 void Add_Common_RW_Export_IOSettings(KFbxIOSettings & pIOS);
00492
00494
00495
00500 protected:
00501 KArrayTemplate<KFbxObject *> mObjectArray;
00502
00503 public:
00507 void RegisterObject(KFbxPlug const * pPlug);
00511 void UnregisterObject(KFbxPlug const * pPlug);
00512
00513 private:
00514 KArrayTemplate<KFbxNode *> mKFbxNodeArray;
00515 public:
00518 inline int GetSrcObjectCount(KFbxNode const *) const { return mKFbxNodeArray.GetCount(); }
00522 inline KFbxNode* GetSrcObject(KFbxNode const *,int pIndex=0) const { return mKFbxNodeArray.GetAt(pIndex); }
00523 private:
00524 KArrayTemplate<KFbxTexture *> mKFbxTextureArray;
00525 public:
00528 inline int GetSrcObjectCount(KFbxTexture const *) const { return mKFbxTextureArray.GetCount(); }
00532 inline KFbxTexture* GetSrcObject(KFbxTexture const *,int pIndex=0) const { return mKFbxTextureArray.GetAt(pIndex); }
00533 private:
00534 KArrayTemplate<KFbxCluster *> mKFbxClusterArray;
00535 public:
00538 inline int GetSrcObjectCount(KFbxCluster const *) const { return mKFbxClusterArray.GetCount(); }
00542 inline KFbxCluster* GetSrcObject(KFbxCluster const *,int pIndex=0) const { return mKFbxClusterArray.GetAt(pIndex); }
00543 private:
00544 KArrayTemplate<KFbxScene *> mKFbxSceneArray;
00545 public:
00548 inline int GetSrcObjectCount(KFbxScene const *) const { return mKFbxSceneArray.GetCount(); }
00552 inline KFbxScene* GetSrcObject(KFbxScene const *,int pIndex=0) const { return mKFbxSceneArray.GetAt(pIndex); }
00553 private:
00554 KArrayTemplate<KFbxDocument *> mKFbxDocumentArray;
00555 public:
00558 inline int GetSrcObjectCount(KFbxDocument const *) const { return mKFbxDocumentArray.GetCount(); }
00562 inline KFbxDocument* GetSrcObject(KFbxDocument const *,int pIndex=0) const { return mKFbxDocumentArray.GetAt(pIndex); }
00563 private:
00564 KArrayTemplate<KFbxSurfaceMaterial *> mKFbxSurfaceMaterialArray;
00565 public:
00568 inline int GetSrcObjectCount(KFbxSurfaceMaterial const *) const { return mKFbxSurfaceMaterialArray.GetCount(); }
00572 inline KFbxSurfaceMaterial* GetSrcObject(KFbxSurfaceMaterial const *,int pIndex=0) const { return mKFbxSurfaceMaterialArray.GetAt(pIndex); }
00573
00574
00575 private:
00576 KArrayTemplate<KFbxReference *> mKFbxReferenceArray;
00577 public:
00582
00586 int GetReferenceCount() const;
00587
00592 KFbxReference* GetReference(int pIndex) const;
00593
00599 int AddReference(KFbxReference* pReference);
00600
00606 bool RemoveReference(KFbxReference* pReference);
00607
00613 bool ClearReference(KFbxReference* pReference);
00614
00616
00617 public:
00627 static KString PrefixName(char const* pPrefix, char const* pName);
00628
00629
00631
00632
00633
00634
00635
00636
00638
00639 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00640
00641 public:
00642
00643 static KFbxSdkManager* GetDefaultKFbxManager();
00644
00645 bool CanDestroyFbxSrcObject(KFbxObject* pObject, KFbxObject* pSrcObject, bool pRecursive, bool pDependents) const;
00646
00647 void CreateMissingBindPoses(KFbxScene *pScene);
00648 int GetBindPoseCount(KFbxScene *pScene) const;
00649
00650 KFbxPlug* CreateClassFrom(kFbxClassId, const char *pName, const KFbxObject* pFrom, const char* pFBXType=0, const char* pFBXSubType=0);
00651
00652 private:
00653 kFbxClassId Internal_RegisterFbxClass(const char* pClassName, kFbxClassId pParentClassId, kFbxPlugConstructor=0, char const* pFbxFileTypeName=0, char const* pFbxFileSubTypeName=0);
00654 bool Internal_RegisterFbxClass(kFbxClassId pClassId);
00655 kFbxClassId Internal_OverrideFbxClass(kFbxClassId pClassId, kFbxPlugConstructor=0);
00656
00657 void Internal_UnregisterFbxClass (kFbxClassId pClassId);
00658
00659 template< class T > void RemoveObjectsOfType( KArrayTemplate<T>& pArray, kFbxClassId pClassId );
00660 KArrayTemplate<KFbxObject*> mSystemLockedObjects;
00661
00662 #ifdef K_FBXNEWRENAMING
00663
00664 enum ERenamingMode
00665 {
00666 eMAYA_TO_FBX,
00667 eFBX_TO_MAYA,
00668 eLW_TO_FBX,
00669 eFBX_TO_LW,
00670 eXSI_TO_FBX,
00671 eFBX_TO_XSI,
00672 eMAX_TO_FBX,
00673 eFBX_TO_MAX,
00674 eMB_TO_FBX,
00675 eFBX_TO_MB
00676 };
00677
00678 void RenameFor(ERenamingMode pMode);
00679
00689 void ResolveNameClashing(bool pFromFbx, bool pIgnoreNS, bool pIsCaseSensitive, bool pComvertToWideChar, bool pReplaceNonAlphaNum, KString pNameSpaceSymbol);
00690
00691 #endif
00692
00693
00694 protected:
00695 KFBXNEW_DECLARE_FRIEND
00696 KFbxSdkManager();
00697 virtual ~KFbxSdkManager();
00698
00709 virtual void Clear(KArrayTemplate<kFbxClassId>* pExcludeList = NULL, bool pDestroyUserNotification=true);
00710
00711
00712 KFbxUserNotification* mUserNotification;
00713
00714
00715 KFbxIOSettings * mIOSettings;
00716
00717
00718 KFbxMessageEmitter * mMessageEmitter;
00719
00720
00721 KFbxIOPluginRegistry* mRegistry;
00722
00723 mutable KError mError;
00724
00725 friend class KFbxPose;
00726
00727
00728 bool ClassInit();
00729 bool ClassRelease();
00730
00731 public:
00732 int GetFbxClassCount() const;
00733 kFbxClassId GetNextFbxClass(kFbxClassId pClassId ) const;
00734
00735 private:
00736 KFbxSdkManager_internal* mInternal;
00737 static KFbxSdkManager* mDefaultManager;
00738
00739 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00740
00741 };
00742
00743 typedef KFbxSdkManager KFbxSdk;
00744
00745 typedef KFbxSdkManager* HKFbxSdkManager;
00746
00747
00748 template < class T > inline int KFbxGetSrcCount(KFbxSdkManager *pObject) { T const* FBXTYPE = 0; return pObject ? pObject->GetSrcObjectCount(FBXTYPE) : 0; }
00749 template < class T > inline int KFbxGetSrcCount(KFbxSdkManager *pObject, T const* FBXTYPE) { return pObject ? pObject->GetSrcObjectCount(FBXTYPE) : 0; }
00750 template < class T > inline T* KFbxGetSrc(KFbxSdkManager *pObject,int pIndex=0) { T const* FBXTYPE = 0; return pObject ? (T *)pObject->GetSrcObject(FBXTYPE,pIndex) : 0; }
00751 template < class T > inline T* KFbxFindSrc(KFbxSdkManager *pObject,char const *pName)
00752 {
00753 for (int i=0; i<KFbxGetSrcCount<T>(pObject); i++) {
00754 T* lObject = KFbxGetSrc<T>(pObject,i);
00755 if (strcmp(lObject->GetName(),pName)==0 ){
00756 return lObject;
00757 }
00758 }
00759 return 0;
00760 }
00761
00762
00763 #define TAKE_NO_ANIMATION 0
00764 #define TAKE_DEFAULT -1
00765 #define TAKE_INVALID -3
00766
00767
00768
00769 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00770
00771 #endif // FBXFILESDK_KFBXPLUGINS_KFBXSDKMANAGER_H
00772