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/components/kbaselib/kaydaradef_h.h>
00042 #include <fbxfilesdk/components/kbaselib/kaydara.h>
00043
00044 #include <fbxfilesdk/components/kbaselib/kbaselib_forward.h>
00045
00046 #include <fbxfilesdk/kfbxplugins/kfbxmemoryallocator.h>
00047 #include <fbxfilesdk/kfbxplugins/kfbxgeometryconverter.h>
00048 #include <fbxfilesdk/kfbxplugins/kfbximageconverter.h>
00049 #include <fbxfilesdk/kfbxplugins/kfbxproperty.h>
00050 #include <fbxfilesdk/kfbxplugins/kfbxtypes.h>
00051 #include <fbxfilesdk/kfbxplugins/kfbxlayer.h>
00052
00053 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00054
00055
00056 class KFbxIOPluginRegistry;
00057 class KFbxUserNotification;
00058 class KFbxMessageEmitter;
00059 class KFbxIOSettings;
00060 class KFbxSdkManager_internal;
00061 class KFbxPreviewManager;
00062 class KFbxXRefManager;
00063 class KFbxLocalizationManager;
00064 class KFbxPlugin;
00065
00079 class KFBX_DLL KFbxSdkManager
00080 {
00081 public:
00086
00097 static bool SetMemoryAllocator(KFbxMemoryAllocator* pMemoryAllocator);
00099
00100
00109 static KFbxSdkManager* Create();
00110
00114 virtual void Destroy();
00116
00117
00122 public:
00131 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) {
00132 T1::ClassId = Internal_RegisterFbxClass(pName,T2::ClassId,(kFbxPlugConstructor)T1::SdkManagerCreate,pFbxFileTypeName,pFbxFileSubTypeName );
00133 return T1::ClassId;
00134 }
00135
00143 template <typename T> inline kFbxClassId RegisterRuntimeFbxClass(char const *pName,T const *pFBX_TYPE_ParentClass,const char *pFbxFileTypeName=0,const char *pFbxFileSubTypeName=0) {
00144 return Internal_RegisterFbxClass(pName,T::ClassId,(kFbxPlugConstructor)T::SdkManagerCreate,pFbxFileTypeName,pFbxFileSubTypeName );
00145 }
00146
00150 inline void UnregisterRuntimeFbxClass(char const* pName)
00151 {
00152 kFbxClassId lClassId = FindClass(pName);
00153
00154 if( !(lClassId == kFbxClassId()) )
00155 {
00156 Internal_UnregisterFbxClass(lClassId);
00157 }
00158 }
00159
00165 template <typename T1,typename T2> inline kFbxClassId OverrideFbxClass(T1 const *pFBX_TYPE_Class,T2 const *pFBX_TYPE_OverridenClass) {
00166 T1::ClassId = Internal_OverrideFbxClass(T2::ClassId,(kFbxPlugConstructor)T1::SdkManagerCreate );
00167 return T1::ClassId;
00168 }
00169
00176 KFbxPlug* CreateClass(kFbxClassId pClassId, char const *pName, const char* pFBXType=0, const char* pFBXSubType=0);
00177
00185 KFbxPlug* CreateClass(KFbxObject* pContainer, kFbxClassId pClassId, const char* pName, const char* pFBXType=0, const char* pFBXSubType=0);
00186
00190 kFbxClassId FindClass(const char* pClassName);
00191
00196 kFbxClassId FindFbxFileClass(const char* pFbxFileTypeName, const char* pFbxFileSubTypeName);
00197
00201 template <typename T> inline void UnregisterFbxClass( T const* pFBX_TYPE_Class )
00202 {
00203 Internal_UnregisterFbxClass( T::ClassId );
00204 T::ClassId = kFbxClassId();
00205 }
00206
00208
00213 public:
00217 KError& GetError();
00218
00221 typedef enum
00222 {
00223 eOBJECT_NOT_FOUND,
00224 eNAME_ALREADY_IN_USE,
00225 eERROR_COUNT
00226 } EError;
00227
00231 EError GetLastErrorID() const;
00232
00236 const char* GetLastErrorString() const;
00237
00239
00249 KFbxDataType CreateFbxDataType(const char *pName,EFbxType pType);
00250
00255 KFbxDataType const &GetFbxDataTypeFromName(const char *pDataType);
00256
00260 int GetFbxDataTypeCount();
00261
00266 KFbxDataType &GetFbxDataType(int pIndex);
00268
00269
00278 KFbxUserNotification* GetUserNotification() const;
00279
00283 void SetUserNotification(KFbxUserNotification* pUN);
00285
00293 KFbxMessageEmitter & GetMessageEmitter();
00298 bool SetMessageEmitter(KFbxMessageEmitter * pMessageEmitter);
00300
00301 private:
00302 KArrayTemplate<KFbxLocalizationManager *> mKFbxLocalizations;
00303 public:
00311 void AddLocalization( KFbxLocalizationManager * pLocManager );
00315 void RemoveLocalization( KFbxLocalizationManager * pLocManager );
00319 bool SetLocale( const char * pLocale );
00326 const char * Localize( const char * pID, const char * pDefault = NULL) const;
00328
00333
00337 KFbxPreviewManager& GetPreviewManager();
00338
00340
00348 KFbxXRefManager& GetXRefManager();
00350
00358 KFbxLibrary* GetRootLibrary();
00359 KFbxLibrary* GetSystemLibraries();
00360 KFbxLibrary* GetUserLibraries();
00362
00370 KFbxIOPluginRegistry* GetIOPluginRegistry() const;
00372
00382 bool LoadPluginsDirectory (char *pFilename,char *pExtensions);
00383
00388 bool LoadPlugin (char *pFilename);
00389
00392 bool UnloadPlugins();
00393
00397 bool EmitPluginsEvent(KFbxEventBase const &pEvent);
00398
00400 KArrayTemplate<KFbxPlugin const*> GetPlugins() const;
00401
00406 int GetPluginCount(bool pOnlyReadWriteOnes);
00407
00413 KFbxPlugin* FindPlugin(char* pName, char* pVersion);
00415
00416
00421
00422
00426 void FillIOSettingsForReadersRegistered(KFbxIOSettings & pIOS);
00427
00431 void FillIOSettingsForWritersRegistered(KFbxIOSettings & pIOS);
00432
00437 void FillCommonIOSettings(KFbxIOSettings & pIOS, bool pImport);
00438
00442 void Create_Common_Import_IOSettings_Groups(KFbxIOSettings & pIOS);
00443
00447 void Create_Common_Export_IOSettings_Groups(KFbxIOSettings & pIOS);
00448
00452 void Add_Common_Import_IOSettings(KFbxIOSettings & pIOS);
00453
00457 void Add_Common_Export_IOSettings(KFbxIOSettings & pIOS);
00458
00462 void Add_Common_RW_Import_IOSettings(KFbxIOSettings & pIOS);
00463
00467 void Add_Common_RW_Export_IOSettings(KFbxIOSettings & pIOS);
00468
00472 void Fill_Motion_Base_ReaderIOSettings(KFbxIOSettings& pIOS);
00473
00477 void Fill_Motion_Base_WriterIOSettings(KFbxIOSettings& pIOS);
00479
00480
00485 protected:
00486 KArrayTemplate<KFbxObject *> mObjectArray;
00487
00488 public:
00492 void RegisterObject(KFbxPlug const * pPlug);
00496 void UnregisterObject(KFbxPlug const * pPlug);
00497
00498 private:
00499 KArrayTemplate<KFbxImageConverter *> mKFbxImageConverterArray;
00500 public:
00503 inline int GetSrcObjectCount(KFbxImageConverter const *) { return mKFbxImageConverterArray.GetCount(); }
00507 inline KFbxImageConverter* GetSrcObject(KFbxImageConverter const *,int pIndex=0) { return mKFbxImageConverterArray.GetAt(pIndex); }
00508 private:
00509 KArrayTemplate<KFbxNode *> mKFbxNodeArray;
00510 public:
00513 inline int GetSrcObjectCount(KFbxNode const *) { return mKFbxNodeArray.GetCount(); }
00517 inline KFbxNode* GetSrcObject(KFbxNode const *,int pIndex=0) { return mKFbxNodeArray.GetAt(pIndex); }
00518 private:
00519 KArrayTemplate<KFbxTexture *> mKFbxTextureArray;
00520 public:
00523 inline int GetSrcObjectCount(KFbxTexture const *) { return mKFbxTextureArray.GetCount(); }
00527 inline KFbxTexture* GetSrcObject(KFbxTexture const *,int pIndex=0) { return mKFbxTextureArray.GetAt(pIndex); }
00528 private:
00529 KArrayTemplate<KFbxCluster *> mKFbxClusterArray;
00530 public:
00533 inline int GetSrcObjectCount(KFbxCluster const *) { return mKFbxClusterArray.GetCount(); }
00537 inline KFbxCluster* GetSrcObject(KFbxCluster const *,int pIndex=0) { return mKFbxClusterArray.GetAt(pIndex); }
00538 private:
00539 KArrayTemplate<KFbxScene *> mKFbxSceneArray;
00540 public:
00543 inline int GetSrcObjectCount(KFbxScene const *) { return mKFbxSceneArray.GetCount(); }
00547 inline KFbxScene* GetSrcObject(KFbxScene const *,int pIndex=0) { return mKFbxSceneArray.GetAt(pIndex); }
00548 private:
00549 KArrayTemplate<KFbxDocument *> mKFbxDocumentArray;
00550 public:
00553 inline int GetSrcObjectCount(KFbxDocument const *) { return mKFbxDocumentArray.GetCount(); }
00557 inline KFbxDocument* GetSrcObject(KFbxDocument const *,int pIndex=0) { return mKFbxDocumentArray.GetAt(pIndex); }
00558 private:
00559 KArrayTemplate<KFbxSurfaceMaterial *> mKFbxSurfaceMaterialArray;
00560 public:
00563 inline int GetSrcObjectCount(KFbxSurfaceMaterial const *) { return mKFbxSurfaceMaterialArray.GetCount(); }
00567 inline KFbxSurfaceMaterial* GetSrcObject(KFbxSurfaceMaterial const *,int pIndex=0) { return mKFbxSurfaceMaterialArray.GetAt(pIndex); }
00568
00569 public:
00579 static KString PrefixName(char const* pPrefix, char const* pName);
00580
00581
00583
00584
00585
00586
00587
00588
00590
00591 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00592
00593 public:
00594 bool CanDestroyFbxSrcObject(KFbxObject* pObject, KFbxObject* pSrcObject, bool pRecursive, bool pDependents);
00595
00596 void CreateMissingBindPoses(KFbxScene *pScene);
00597 int GetBindPoseCount(KFbxScene *pScene);
00598
00599 KFbxPlug* CreateClassFrom(kFbxClassId, const char *pName, const KFbxObject* pFrom, const char* pFBXType=0, const char* pFBXSubType=0);
00600
00601 private:
00602 kFbxClassId Internal_RegisterFbxClass(const char* pClassName, kFbxClassId pParentClassId, kFbxPlugConstructor=0, char const* pFbxFileTypeName=0, char const* pFbxFileSubTypeName=0);
00603 bool Internal_RegisterFbxClass(kFbxClassId pClassId);
00604 kFbxClassId Internal_OverrideFbxClass(kFbxClassId pClassId, kFbxPlugConstructor=0);
00605
00606 void Internal_UnregisterFbxClass (kFbxClassId pClassId);
00607
00608 template< class T > void RemoveObjectsOfType( KArrayTemplate<T>& pArray, kFbxClassId pClassId );
00609 KArrayTemplate<KFbxObject*> mSystemLockedObjects;
00610
00611 #ifdef K_FBXNEWRENAMING
00612
00613 enum ERenamingMode
00614 {
00615 eMAYA_TO_FBX,
00616 eFBX_TO_MAYA,
00617 eLW_TO_FBX,
00618 eFBX_TO_LW,
00619 eXSI_TO_FBX,
00620 eFBX_TO_XSI,
00621 eMAX_TO_FBX,
00622 eFBX_TO_MAX,
00623 eMB_TO_FBX,
00624 eFBX_TO_MB
00625 };
00626
00627 void RenameFor(ERenamingMode pMode);
00628
00638 void ResolveNameClashing(bool pFromFbx, bool pIgnoreNS, bool pIsCaseSensitive, bool pComvertToWideChar, bool pReplaceNonAlphaNum, KString pNameSpaceSymbol);
00639
00640 #endif
00641
00642
00643 protected:
00644 KFbxSdkManager();
00645 virtual ~KFbxSdkManager();
00646
00657 virtual void Clear(KArrayTemplate<kFbxClassId>* pExcludeList = NULL, bool pDestroyUserNotification=true);
00658
00659
00660 KFbxUserNotification* mUserNotification;
00661
00662
00663 KFbxMessageEmitter * mMessageEmitter;
00664
00665
00666 KFbxIOPluginRegistry* mRegistry;
00667
00668 mutable KError mError;
00669
00670 friend class KFbxPose;
00671
00672
00673 bool ClassInit();
00674 bool ClassRelease();
00675
00676 public:
00677 int GetFbxClassCount() const;
00678 kFbxClassId GetNextFbxClass(kFbxClassId pClassId ) const;
00679
00680 private:
00681 KFbxSdkManager_internal* mInternal;
00682
00683 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00684
00685 };
00686
00687 typedef KFbxSdkManager KFbxSdk;
00688
00689 typedef KFbxSdkManager* HKFbxSdkManager;
00690
00691
00692 template < class T > inline int KFbxGetSrcCount(KFbxSdkManager *pObject) { T const* FBXTYPE = 0; return pObject ? pObject->GetSrcObjectCount(FBXTYPE) : 0; }
00693 template < class T > inline int KFbxGetSrcCount(KFbxSdkManager *pObject, T const* FBXTYPE) { return pObject ? pObject->GetSrcObjectCount(FBXTYPE) : 0; }
00694 template < class T > inline T* KFbxGetSrc(KFbxSdkManager *pObject,int pIndex=0) { T const* FBXTYPE = 0; return pObject ? (T *)pObject->GetSrcObject(FBXTYPE,pIndex) : 0; }
00695 template < class T > inline T* KFbxFindSrc(KFbxSdkManager *pObject,char const *pName)
00696 {
00697 for (int i=0; i<KFbxGetSrcCount<T>(pObject); i++) {
00698 T* lObject = KFbxGetSrc<T>(pObject,i);
00699 if (strcmp(lObject->GetName(),pName)==0 ){
00700 return lObject;
00701 }
00702 }
00703 return 0;
00704 }
00705
00706
00707 #define TAKE_NO_ANIMATION 0
00708 #define TAKE_DEFAULT -1
00709 #define TAKE_INVALID -3
00710
00711
00712
00713 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00714
00715 #endif // FBXFILESDK_KFBXPLUGINS_KFBXSDKMANAGER_H
00716