fbxmanager.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2012 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_CORE_MANAGER_H_
00014 #define _FBXSDK_CORE_MANAGER_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/fbxobject.h>
00019 
00020 #include <fbxsdk/scene/geometry/fbxcluster.h>
00021 #include <fbxsdk/scene/geometry/fbxnode.h>
00022 #include <fbxsdk/scene/shading/fbxsurfacematerial.h>
00023 #include <fbxsdk/scene/shading/fbxtexture.h>
00024 
00025 #include <fbxsdk/fbxsdk_nsbegin.h>
00026 
00027 class FbxIOSettings;
00028 class FbxIOPluginRegistry;
00029 class FbxAnimStack;
00030 class FbxPlugin;
00031 class FbxSceneReference;
00032 class FbxUserNotification;
00033 class FbxMessageEmitter;
00034 class FbxLocalizationManager;
00035 class FbxXRefManager;
00036 class FbxPreviewManager;
00037 class FbxManager_internal;
00038 
00060 class FBXSDK_DLL FbxManager
00061 {
00062 public:
00071         static FbxManager* Create();
00072 
00076         virtual void Destroy();
00078 
00087         static const char* GetVersion(bool pFull=true);
00088 
00094         static void GetFileFormatVersion(int& pMajor, int& pMinor, int& pRevision);
00096 
00097 
00112         template <typename T1, typename T2> inline FbxClassId RegisterFbxClass(char const* pName, const T1*, const T2*, const char* pFbxFileTypeName=0, const char* pFbxFileSubTypeName=0)
00113         {
00114             T1::ClassId = Internal_RegisterFbxClass(pName, T2::ClassId, (FbxPlugCreateProc)T1::ManagerCreate, pFbxFileTypeName, pFbxFileSubTypeName);
00115             return T1::ClassId;
00116         }
00117      
00127         template <typename T> inline FbxClassId RegisterRuntimeFbxClass(char const* pName, const T*, const char* pFbxFileTypeName=0,const char* pFbxFileSubTypeName=0)
00128         {
00129             return Internal_RegisterFbxClass(pName, T::ClassId, (FbxPlugCreateProc)T::ManagerCreate, pFbxFileTypeName, pFbxFileSubTypeName);
00130         }
00131         
00135         inline void UnregisterRuntimeFbxClass(char const* pName)
00136         {
00137             FbxClassId lClassId = FindClass(pName);
00138             if( !(lClassId == FbxClassId()) )
00139             {
00140                 Internal_UnregisterFbxClass(lClassId);
00141             }
00142         }
00143         
00149         template <typename T1,typename T2> inline FbxClassId OverrideFbxClass(const T1* pFBX_TYPE_Class, const T2* pFBX_TYPE_OverridenClass)
00150         {
00151             T1::ClassId  = Internal_OverrideFbxClass(T2::ClassId,(FbxPlugCreateProc)T1::ManagerCreate );
00152             return T1::ClassId;
00153         }
00154 
00165         FbxObject* CreateNewObjectFromClassId(FbxClassId pClassId, char const* pName, FbxObject* pContainer=NULL, const FbxObject* pCloneFrom=NULL);
00166 
00170         FbxClassId FindClass(const char* pClassName) const;
00171 
00176         FbxClassId FindFbxFileClass(const char* pFbxFileTypeName, const char* pFbxFileSubTypeName) const;
00177 
00181         template <typename T> inline void UnregisterFbxClass(const T* pFBX_TYPE_Class)
00182         {
00183             Internal_UnregisterFbxClass(T::ClassId);
00184             T::ClassId = FbxClassId();
00185         }
00187 
00197         FbxDataType CreateDataType(const char* pName, const EFbxType pType);
00198 
00202         int GetDataTypeCount() const;
00203 
00208         FbxDataType& GetDataType(const int pIndex) const;
00209 
00214         FbxDataType& GetDataTypeFromName(const char* pDataType) const;
00216 
00225         FbxUserNotification* GetUserNotification() const;
00226 
00230         void SetUserNotification(FbxUserNotification* pUN);
00232 
00241         virtual FbxIOSettings* GetIOSettings() const;
00242 
00246         virtual void SetIOSettings(FbxIOSettings* pIOSettings);
00248 
00249 
00257         FbxMessageEmitter& GetMessageEmitter();
00262         bool SetMessageEmitter(FbxMessageEmitter* pMessageEmitter);
00264 
00265         
00273         void AddLocalization(FbxLocalizationManager* pLocManager);
00274 
00278         void RemoveLocalization(FbxLocalizationManager* pLocManager);
00279 
00283         bool SetLocale(const char* pLocale);
00284 
00291         const char* Localize(const char* pID, const char* pDefault=NULL) const;
00293 
00301         FbxPreviewManager& GetPreviewManager();
00303 
00311         FbxXRefManager& GetXRefManager();
00313 
00321         FbxLibrary* GetRootLibrary() const;
00322         FbxLibrary* GetSystemLibraries() const;
00323         FbxLibrary* GetUserLibraries() const;
00325 
00333         FbxIOPluginRegistry* GetIOPluginRegistry() const;
00335 
00345         bool LoadPluginsDirectory(const char* pFilename, const char* pExtensions=NULL);
00346 
00351         bool LoadPlugin(const char* pFilename);
00352 
00355         bool UnloadPlugins();
00356 
00360         bool EmitPluginsEvent(const FbxEventBase& pEvent);
00361        
00363         FbxArray<const FbxPlugin*> GetPlugins() const;
00364 
00368         int GetPluginCount() const;
00369 
00375         FbxPlugin* FindPlugin(const char* pName, const char* pVersion) const;
00377 
00378 
00383     // Add IOSettings in hierarchy from different modules
00384 
00388         void FillIOSettingsForReadersRegistered(FbxIOSettings& pIOS);
00389 
00393         void FillIOSettingsForWritersRegistered(FbxIOSettings& pIOS);
00394 
00399         void FillCommonIOSettings(FbxIOSettings& pIOS, bool pImport);
00401 
00411         void RegisterObject(const FbxPlug* pPlug);
00412 
00417         void UnregisterObject(const FbxPlug* pPlug);
00418 
00423         void RegisterObjects(const FbxArray<FbxObject*>& pArray);
00424 
00429         void UnregisterObjects(const FbxArray<FbxObject*>& pArray);
00430 
00434         void IncreaseDestroyingSceneFlag();
00439         void DecreaseDestroyingSceneFlag();
00447         int GetReferenceCount() const;
00448 
00453         FbxSceneReference* GetReference(int pIndex) const;
00454 
00460         int AddReference(FbxSceneReference* pReference);
00461 
00467         bool RemoveReference(FbxSceneReference* pReference);
00468 
00474         bool ClearReference(FbxSceneReference* pReference);
00476 
00486     static FbxString PrefixName(char const* pPrefix, char const* pName);
00487 
00491     int GetDocumentCount();
00492 
00497     FbxDocument* GetDocument(int pIndex);
00498 
00500 //
00501 //  WARNING!
00502 //
00503 //  Anything beyond these lines may not be documented accurately and is
00504 //  subject to change without notice.
00505 //
00507 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00508     static FbxManager*  GetDefaultManager();
00509     bool                CanDestroyFbxSrcObject(FbxObject* pObject, FbxObject* pSrcObject, bool pRecursive, bool pDependents) const;
00510     void                CreateMissingBindPoses(FbxScene* pScene);
00511     int                 GetBindPoseCount(FbxScene *pScene) const;
00512     int                 GetFbxClassCount() const;
00513     FbxClassId          GetNextFbxClass(FbxClassId pClassId /* invalid id: first one */) const;
00514 
00515 protected:
00516     FbxManager();
00517     virtual ~FbxManager();
00518 
00519     void Clear();
00520     void ClassInit();
00521     void ClassRelease();
00522     void DataTypeInit();
00523     void DataTypeRelease();
00524 
00525 private:
00526     void        Create_Common_Import_IOSettings_Groups(FbxIOSettings& pIOS);
00527     void        Create_Common_Export_IOSettings_Groups(FbxIOSettings& pIOS);
00528     void        Add_Common_Import_IOSettings(FbxIOSettings& pIOS);
00529     void        Add_Common_Export_IOSettings(FbxIOSettings& pIOS);
00530     void        Add_Common_RW_Import_IOSettings(FbxIOSettings& pIOS);
00531     void        Add_Common_RW_Export_IOSettings(FbxIOSettings& pIOS);
00532 
00533     FbxClassId  Internal_RegisterFbxClass(const char* pClassName, FbxClassId pParentClassId, FbxPlugCreateProc=0, char const* pFbxFileTypeName=0, char const* pFbxFileSubTypeName=0);
00534     bool        Internal_RegisterFbxClass(FbxClassId pClassId);
00535     FbxClassId  Internal_OverrideFbxClass(FbxClassId pClassId, FbxPlugCreateProc=0);
00536     void        Internal_UnregisterFbxClass(FbxClassId pClassId);
00537 
00538     void        RemoveObjectsOfType(const FbxClassId& pClassId);
00539 
00540     FbxArray<FbxObject*>                mObjects;
00541     FbxArray<FbxDocument*>              mDocuments;
00542 
00543     FbxIOSettings*                      mIOSettings;
00544     FbxIOPluginRegistry*                mRegistry;
00545     FbxUserNotification*                mUserNotification;
00546     FbxMessageEmitter*                  mMessageEmitter;
00547     FbxArray<FbxLocalizationManager*>   mLocalizationManagerArray;
00548     FbxArray<FbxSceneReference*>        mSceneReferenceArray;
00549 
00550     FbxArray<FbxObject*>                mDestroyingObjects;
00551     FbxArray<FbxDocument*>              mDestroyingDocuments;
00552     int                                 mIsDestroyingScene;
00553 
00554     FbxManager_internal*                mInternal;
00555     static FbxManager*                  smDefaultManager;
00556 
00557     FBXSDK_FRIEND_NEW();
00558     friend class FbxPose;
00559 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00560 };
00561 
00562 #include <fbxsdk/fbxsdk_nsend.h>
00563 
00564 #endif /* _FBXSDK_CORE_MANAGER_H_ */