fbxlibrary.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_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 
00231 //
00232 //  WARNING!
00233 //
00234 //  Anything beyond these lines may not be documented accurately and is
00235 //  subject to change without notice.
00236 //
00238 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00239 protected:
00240     // Constructor / Destructor
00241     FbxLibrary(FbxManager& pManager, const char* pName);
00242 
00243     virtual void Destruct(bool pRecursive, bool pDependents);
00244     virtual void Construct(const FbxLibrary* pFrom);
00245 
00246     mutable FbxLocalizationManager* mLocalizationManager;
00247 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00248 };
00249 
00250 
00251     template < class T > T* FbxLibrary::InstantiateMember( const T* pFBX_TYPE, const FbxObjectFilter& pFilter, bool pRecurse, FbxObject* pOptContainer )
00252     {
00253         // first check all materials in the library.
00254         int i;
00255         for(i = 0; i < GetMemberCount( FBX_TYPE(T) ); ++i )
00256         {
00257             T* lObject = GetMember( FBX_TYPE(T), i );
00258             if( pFilter.Match(lObject) )
00259                 return FbxCast<T>(CloneAsset(lObject,pOptContainer));
00260         }
00261 
00262         if( pRecurse )
00263         {
00264             // then check all materials in each sub-library.
00265             for( i = 0; i < GetMemberCount( FBX_TYPE(FbxLibrary) ); ++i )
00266             {
00267                 FbxLibrary* lLibrary = GetMember( FBX_TYPE(FbxLibrary), i );
00268                 T* lClonedObject = lLibrary->InstantiateMember( pFBX_TYPE, pFilter, pRecurse, pOptContainer );
00269                 if( lClonedObject )
00270                     return lClonedObject;
00271             }
00272         }
00273 
00274         return NULL;
00275     }
00276 
00278 //
00279 //  WARNING!
00280 //
00281 //  Anything beyond these lines may not be documented accurately and is
00282 //  subject to change without notice.
00283 //
00285 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00286 
00291     class FBXSDK_DLL FbxEventPopulateSystemLibrary : public FbxEvent<FbxEventPopulateSystemLibrary>
00292     {
00293       FBXSDK_EVENT_DECLARE(FbxEventPopulateSystemLibrary)
00294 
00295         public:         
00300 
00304             FbxEventPopulateSystemLibrary(FbxLibrary* pLibrary) { mLibrary = pLibrary; }
00305 
00307            
00312 
00313             inline FbxLibrary* GetLibrary() const { return mLibrary; }
00314         private:
00315             FbxLibrary*    mLibrary;
00317     };
00318 
00323     class FBXSDK_DLL FbxEventUpdateSystemLibrary : public FbxEvent<FbxEventUpdateSystemLibrary>
00324     {
00325         FBXSDK_EVENT_DECLARE(FbxEventUpdateSystemLibrary)
00326         public:
00331 
00335             FbxEventUpdateSystemLibrary(FbxLibrary *pLibrary) { mLibrary = pLibrary; }
00336 
00338 
00343 
00345             inline FbxLibrary* GetLibrary() const { return mLibrary; }
00346 
00348         private:
00349                 FbxLibrary*    mLibrary;
00350     };
00351 
00352 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00353 
00364     class FBXSDK_DLL FbxEventWriteLocalization : public FbxEvent<FbxEventWriteLocalization>
00365     {
00366         FBXSDK_EVENT_DECLARE(FbxEventWriteLocalization)
00367         public:
00368             FbxEventWriteLocalization(FbxLibrary* pAssetLibrary) { mAssetLibrary = pAssetLibrary; }
00369 
00371             inline FbxLibrary* GetLibrary() const { return mAssetLibrary; }
00372 
00373         private:
00374             FbxLibrary*    mAssetLibrary;
00375     };
00376 
00378     //
00379     //  WARNING!
00380     //
00381     //  Anything beyond these lines may not be documented accurately and is
00382     //  subject to change without notice.
00383     //
00385     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00386 
00387     // Some assets correspond 1:1 with files containing their actual data.
00388     class FBXSDK_DLL FbxEventMapAssetFileToAssetObject : public FbxEvent<FbxEventMapAssetFileToAssetObject>
00389     {
00390         FBXSDK_EVENT_DECLARE(FbxEventMapAssetFileToAssetObject)
00391         public:
00392 
00393             // pFile - The asset file to query
00394             FbxEventMapAssetFileToAssetObject(const char* pFile) :
00395                 mAsset(NULL),
00396                 mFilePath( pFile )
00397                 {}
00398 
00399             // listeners query this
00400             inline const char* GetFilePath() const { return mFilePath; }
00401 
00402             // listeners set this
00403             mutable FbxObject* mAsset;
00404 
00405         private:
00406             FbxString mFilePath;
00407     };
00408 
00409     #endif //DOXYGEN_SHOULD_SKIP_THIS
00410 
00411 #include <fbxsdk/fbxsdk_nsend.h>
00412 
00413 #endif /* _FBXSDK_SCENE_LIBRARY_H_ */