kfbxlibrary.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002 
00003    Copyright (C) 2010 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 
00015 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00016 #define FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00017 
00018 
00019 #include <fbxfilesdk/fbxfilesdk_def.h>
00020 
00021 #include <fbxfilesdk/fbxcore/fbxcollection/kfbxdocument.h>
00022 #include <fbxfilesdk/kfbxplugins/kfbxobjectfilter.h>
00023 
00024 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00025 
00026 class KFbxLocalizationManager;
00027 class KFbxCriteria;
00028 
00033 class KFBX_DLL KFbxLibrary : public KFbxDocument
00034 {
00035     KFBXOBJECT_DECLARE(KFbxLibrary,KFbxDocument);
00036 
00037 public:
00039     KFbxLibrary* GetParentLibrary(void) const;
00040 
00044     void SystemLibrary(bool pSystemLibrary);
00045 
00047     bool IsSystemLibrary() const;
00048 
00056     void LocalizationBaseNamePrefix(const char* pPrefix);
00057 
00059     KString LocalizationBaseNamePrefix() const;
00060 
00061     // =======================================================================
00062     //
00063     // sub-library
00064     //
00065     // =======================================================================
00066 
00071     bool AddSubLibrary(KFbxLibrary* pSubLibrary);
00072 
00077     bool RemoveSubLibrary(KFbxLibrary* pSubLibrary);
00078 
00080     int GetSubLibraryCount(void) const;
00081 
00085     KFbxLibrary* GetSubLibrary(int pIndex) const;
00086 
00092     KFbxObject* CloneAsset( KFbxObject* pToClone, KFbxObject* pOptionalDestinationContainer = NULL) const;
00093 
00094     
00101     static KFbxCriteria GetAssetCriteriaFilter();
00102 
00108     static KFbxCriteria GetAssetDependentsFilter();
00109 
00134     bool ImportAssets(KFbxLibrary* pSrcLibrary);
00135 
00161     bool ImportAssets(KFbxLibrary* pSrcLibrary, const KFbxCriteria& pAssetFilter);
00162 
00163 
00172     template < class T > T* InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse = true, KFbxObject* pOptContainer = NULL);
00173 
00174 
00175     // =======================================================================
00176     //
00177     // Localization
00178     //
00179     // =======================================================================
00183     KFbxLocalizationManager & GetLocalizationManager() const;
00184 
00191     virtual const char * Localize( const char * pID, const char * pDefault = NULL ) const;
00192 
00193     // =======================================================================
00194     //
00195     // Shading Object
00196     //
00197     // =======================================================================
00198 
00202     bool AddShadingObject(KFbxObject* pShadingObject);
00203 
00207     bool RemoveShadingObject(KFbxObject* pShadingObject);
00208 
00210     int GetShadingObjectCount(void) const;
00211 
00216     KFbxObject* GetShadingObject(int pIndex) const;
00217 
00223     int GetShadingObjectCount(
00224         const KFbxImplementationFilter & pCriteria
00225     ) const;
00226 
00233     KFbxObject* GetShadingObject(
00234         int pIndex,
00235         const KFbxImplementationFilter & pCriteria
00236     ) const;
00237 
00239 //
00240 //  WARNING!
00241 //
00242 //  Anything beyond these lines may not be documented accurately and is
00243 //  subject to change without notice.
00244 //
00246 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00247 protected:
00248     // Constructor / Destructor
00249     KFbxLibrary(KFbxSdkManager& pManager, char const* pName);
00250 
00251     virtual void Destruct(bool pRecursive, bool pDependents);
00252     virtual void Construct(const KFbxLibrary* pFrom);
00253 
00254     mutable KFbxLocalizationManager * mLocalizationManager;
00255 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00256 };
00257 
00258 
00259     template < class T > T* KFbxLibrary::InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse, KFbxObject* pOptContainer )
00260     {
00261         // first check all materials in the library.
00262         int i = 0;
00263         for( i = 0; i < GetMemberCount( FBX_TYPE(T) ); ++i )
00264         {
00265             T* lObject = GetMember( FBX_TYPE(T), i );
00266             if( pFilter.Match(lObject) )
00267                 return KFbxCast<T>(CloneAsset(lObject,pOptContainer));
00268         }
00269 
00270         if( pRecurse )
00271         {
00272             // then check all materials in each sub-library.
00273             for( i = 0; i < GetMemberCount( FBX_TYPE(KFbxLibrary) ); ++i )
00274             {
00275                 KFbxLibrary* lLibrary = GetMember( FBX_TYPE(KFbxLibrary), i );
00276                 T* lClonedObject = lLibrary->InstantiateMember( pFBX_TYPE, pFilter, pRecurse, pOptContainer );
00277                 if( lClonedObject )
00278                     return lClonedObject;
00279             }
00280         }
00281 
00282         return NULL;
00283     }
00284 
00285 
00290     class KFBX_DLL KFbxEventPopulateSystemLibrary : public KFbxEvent<KFbxEventPopulateSystemLibrary>
00291     {
00292       KFBXEVENT_DECLARE(KFbxEventPopulateSystemLibrary)
00293 
00294         public:         
00299 
00303             KFbxEventPopulateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00304 
00306        
00307             public:
00312 
00313                 inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00314             private:
00315                 KFbxLibrary*    mLibrary;
00317     };
00318 
00323     class KFBX_DLL KFbxEventUpdateSystemLibrary : public KFbxEvent<KFbxEventUpdateSystemLibrary>
00324     {
00325         KFBXEVENT_DECLARE(KFbxEventUpdateSystemLibrary)
00326         public:
00331 
00335             KFbxEventUpdateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00336 
00338 
00343 
00345             inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00346 
00348         private:
00349                 KFbxLibrary*    mLibrary;
00350     };
00351 
00362     class KFBX_DLL KFbxEventWriteLocalization : public KFbxEvent<KFbxEventWriteLocalization>
00363     {
00364         KFBXEVENT_DECLARE(KFbxEventWriteLocalization)
00365         public:
00366             KFbxEventWriteLocalization(KFbxLibrary *pAssetLibrary) { mAssetLibrary = pAssetLibrary; }
00367 
00369             inline KFbxLibrary* GetLibrary() const { return mAssetLibrary; }
00370 
00371         private:
00372             KFbxLibrary*    mAssetLibrary;
00373     };
00374 
00376     //
00377     //  WARNING!
00378     //
00379     //  Anything beyond these lines may not be documented accurately and is
00380     //  subject to change without notice.
00381     //
00383     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00384 
00385     // Some assets correspond 1:1 with files containing their actual data.
00386     class KFBX_DLL KFbxEventMapAssetFileToAssetObject : public KFbxEvent<KFbxEventMapAssetFileToAssetObject>
00387     {
00388         KFBXEVENT_DECLARE(KFbxEventMapAssetFileToAssetObject)
00389         public:
00390 
00391             // pFile - The asset file to query
00392             KFbxEventMapAssetFileToAssetObject(const char* pFile) :
00393                 mAsset(NULL),
00394                 mFilePath( pFile )
00395                 {}
00396 
00397             // listeners query this
00398             inline const char* GetFilePath() const { return mFilePath; }
00399 
00400             // listeners set this
00401             mutable KFbxObject* mAsset;
00402 
00403         private:
00404             KString mFilePath;
00405     };
00406 
00407     #endif //DOXYGEN_SHOULD_SKIP_THIS
00408 
00409 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00410 
00411 #endif // FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00412