fbxsdk/scene/fbxlibrary.h Source File
 
 
 
fbxsdk/scene/fbxlibrary.h
Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2013 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_SCENE_LIBRARY_H_
00014 #define _FBXSDK_SCENE_LIBRARY_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/scene/fbxdocument.h>
00019 #include <fbxsdk/scene/fbxobjectfilter.h>
00020 
00021 #include <fbxsdk/fbxsdk_nsbegin.h>
00022 
00023 class FbxLocalizationManager;
00024 class FbxCriteria;
00025 
00030 class FBXSDK_DLL FbxLibrary : public FbxDocument
00031 {
00032     FBXSDK_OBJECT_DECLARE(FbxLibrary, FbxDocument);
00033 
00034 public:
00036     FbxLibrary* GetParentLibrary(void) const;
00037 
00041     void SystemLibrary(bool pSystemLibrary);
00042 
00044     bool IsSystemLibrary() const;
00045 
00053     void LocalizationBaseNamePrefix(const char* pPrefix);
00054 
00056     FbxString LocalizationBaseNamePrefix() const;
00057 
00058     // =======================================================================
00059     //
00060     // sub-library
00061     //
00062     // =======================================================================
00063 
00068     bool AddSubLibrary(FbxLibrary* pSubLibrary);
00069 
00074     bool RemoveSubLibrary(FbxLibrary* pSubLibrary);
00075 
00077     int GetSubLibraryCount(void) const;
00078 
00082     FbxLibrary* GetSubLibrary(int pIndex) const;
00083 
00089     FbxObject* CloneAsset( FbxObject* pToClone, FbxObject* pOptionalDestinationContainer = NULL) const;
00090 
00091     
00098     static FbxCriteria GetAssetCriteriaFilter();
00099 
00105     static FbxCriteria GetAssetDependentsFilter();
00106 
00131     bool ImportAssets(FbxLibrary* pSrcLibrary);
00132 
00158     bool ImportAssets(FbxLibrary* pSrcLibrary, const FbxCriteria& pAssetFilter);
00159 
00160 
00169     template < class T > T* InstantiateMember( const T* pFBX_TYPE, const FbxObjectFilter& pFilter, bool pRecurse = true, FbxObject* pOptContainer = NULL);
00170 
00171 
00172         // =======================================================================
00173         //
00174         // Localization
00175         //
00176         // =======================================================================
00180     FbxLocalizationManager& GetLocalizationManager() const;
00181 
00188     virtual const char* Localize( const char* pID, const char* pDefault = NULL ) const;
00189 
00190     // =======================================================================
00191     //
00192     // Shading Object
00193     //
00194     // =======================================================================
00195 
00199     bool AddShadingObject(FbxObject* pShadingObject);
00200 
00204     bool RemoveShadingObject(FbxObject* pShadingObject);
00205 
00207     int GetShadingObjectCount(void) const;
00208 
00213     FbxObject* GetShadingObject(int pIndex) const;
00214 
00220     int GetShadingObjectCount(const FbxImplementationFilter& pCriteria) const;
00221 
00228     FbxObject* GetShadingObject(int pIndex, const FbxImplementationFilter& pCriteria) const;
00229 
00230 /*****************************************************************************************************************************
00231 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00232 *****************************************************************************************************************************/
00233 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00234 protected:
00235         virtual void Construct(const FbxLibrary* pFrom);
00236         virtual void Destruct(bool pRecursive);
00237 
00238         mutable FbxLocalizationManager* mLocalizationManager;
00239 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00240 };
00241 
00242 /*****************************************************************************************************************************
00243 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00244 *****************************************************************************************************************************/
00245 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00246 
00247 template <class T> T* FbxLibrary::InstantiateMember(const T* pFBX_TYPE, const FbxObjectFilter& pFilter, bool pRecurse, FbxObject* pOptContainer)
00248 {
00249         //First check all materials in the library.
00250         for( int i = 0; i < GetMemberCount<T>(); ++i )
00251         {
00252                 T* lObject = GetMember<T>(i);
00253                 if( pFilter.Match(lObject) )
00254                         return FbxCast<T>(CloneAsset(lObject,pOptContainer));
00255         }
00256 
00257         if( pRecurse )
00258         {
00259                 // then check all materials in each sub-library.
00260                 for( int i = 0; i < GetMemberCount<FbxLibrary>(); ++i )
00261                 {
00262                         FbxLibrary* lLibrary = GetMember<FbxLibrary>(i);
00263                         T* lClonedObject = lLibrary->InstantiateMember(pFBX_TYPE, pFilter, pRecurse, pOptContainer);
00264                         if( lClonedObject )
00265                                 return lClonedObject;
00266                 }
00267         }
00268 
00269         return NULL;
00270 }
00271 
00272 class FBXSDK_DLL FbxEventPopulateSystemLibrary : public FbxEvent<FbxEventPopulateSystemLibrary>
00273 {
00274         FBXSDK_EVENT_DECLARE(FbxEventPopulateSystemLibrary)
00275 
00276 public:                 
00277         FbxEventPopulateSystemLibrary(FbxLibrary* pLibrary) { mLibrary = pLibrary; }
00278         inline FbxLibrary* GetLibrary() const { return mLibrary; }
00279 
00280 private:
00281         FbxLibrary* mLibrary;
00282 };
00283 
00284 class FBXSDK_DLL FbxEventUpdateSystemLibrary : public FbxEvent<FbxEventUpdateSystemLibrary>
00285 {
00286         FBXSDK_EVENT_DECLARE(FbxEventUpdateSystemLibrary)
00287 
00288 public:
00289         FbxEventUpdateSystemLibrary(FbxLibrary *pLibrary) { mLibrary = pLibrary; }
00290         inline FbxLibrary* GetLibrary() const { return mLibrary; }
00291 
00292 private:
00293         FbxLibrary* mLibrary;
00294 };
00295 
00296 class FBXSDK_DLL FbxEventWriteLocalization : public FbxEvent<FbxEventWriteLocalization>
00297 {
00298         FBXSDK_EVENT_DECLARE(FbxEventWriteLocalization)
00299 
00300 public:
00301         FbxEventWriteLocalization(FbxLibrary* pAssetLibrary) { mAssetLibrary = pAssetLibrary; }
00302         inline FbxLibrary* GetLibrary() const { return mAssetLibrary; }
00303 
00304 private:
00305         FbxLibrary* mAssetLibrary;
00306 };
00307 
00308 class FBXSDK_DLL FbxEventMapAssetFileToAssetObject : public FbxEvent<FbxEventMapAssetFileToAssetObject>
00309 {
00310         FBXSDK_EVENT_DECLARE(FbxEventMapAssetFileToAssetObject)
00311 
00312 public:
00313         FbxEventMapAssetFileToAssetObject(const char* pFile) :
00314                 mAsset(NULL),
00315                 mFilePath( pFile )
00316         {
00317         }
00318 
00319         inline const char* GetFilePath() const { return mFilePath; }
00320         mutable FbxObject* mAsset;
00321 
00322 private:
00323         FbxString mFilePath;
00324 };
00325 
00326 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00327 
00328 #include <fbxsdk/fbxsdk_nsend.h>
00329 
00330 #endif /* _FBXSDK_SCENE_LIBRARY_H_ */