FBX SDK Reference Guide: kfbxlibrary.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2001 - 2008 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00042 #include <fbxfilesdk/fbxcore/fbxcollection/kfbxdocument.h>
00043 #include <fbxfilesdk/kfbxplugins/kfbxobjectfilter.h>
00044 
00045 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00046 
00047 class KFbxLocalizationManager;
00048 class KFbxCriteria;
00049 
00053 class KFBX_DLL KFbxLibrary : public KFbxDocument
00054 {
00055     KFBXOBJECT_DECLARE(KFbxLibrary,KFbxDocument);
00056 
00057     public:
00058 
00060         KFbxLibrary* GetParentLibrary(void) const;
00061 
00062         void SystemLibrary(bool pSystemLibrary);
00063         bool IsSystemLibrary() const;
00064 
00076         void LocalizationBaseNamePrefix(const char* pPrefix);
00078         KString LocalizationBaseNamePrefix() const;
00079 
00080         // =======================================================================
00081         //
00082         // Sub library
00083         //
00084         // =======================================================================
00085 
00090         bool AddSubLibrary(KFbxLibrary* pSubLibrary);
00091 
00096         bool RemoveSubLibrary(KFbxLibrary* pSubLibrary);
00097 
00099         int GetSubLibraryCount(void) const;
00100 
00104         KFbxLibrary* GetSubLibrary(int pIndex) const;
00105 
00114         int GetSubLibraryCount(
00115             const KFbxImplementationFilter & pCriteria
00116         ) const;
00117 
00125         KFbxLibrary* GetSubLibrary(
00126             int pIndex,
00127             const KFbxImplementationFilter & pCriteria
00128         ) const;
00129 
00130 
00131         KFbxObject* CloneAsset( KFbxObject* pToClone, KFbxObject* pOptionalDestinationContainer = NULL) const;
00132 
00133         
00140         static KFbxCriteria GetAssetCriteriaFilter();
00141 
00148         static KFbxCriteria GetAssetDependentsFilter();
00149 
00174         bool ImportAssets(KFbxLibrary* pSrcLibrary);
00175 
00201         bool ImportAssets(KFbxLibrary* pSrcLibrary, const KFbxCriteria& pAssetFilter);
00202 
00203 
00212         template < class T > T* InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse = true, KFbxObject* pOptContainer = NULL);
00213 
00214 
00215     // =======================================================================
00216     //
00217     // Localization
00218     //
00219     // =======================================================================
00223         KFbxLocalizationManager & GetLocalizationManager() const;
00224 
00231         virtual const char * Localize( const char * pID, const char * pDefault = NULL ) const;
00232 
00233     // =======================================================================
00234     //
00235     // Shading Node
00236     //
00237     // =======================================================================
00238 
00242         bool AddShadingObject(KFbxObject* pShadingObject);
00243 
00247         bool RemoveShadingObject(KFbxObject* pShadingObject);
00248 
00250         int GetShadingObjectCount(void) const;
00251 
00256         KFbxObject* GetShadingObject(int pIndex) const;
00257 
00265         int GetShadingObjectCount(
00266             const KFbxImplementationFilter & pCriteria
00267         ) const;
00268 
00276         KFbxObject* GetShadingObject(
00277             int pIndex,
00278             const KFbxImplementationFilter & pCriteria
00279         ) const;
00280 
00282         //
00283         //  WARNING!
00284         //
00285         //  Anything beyond these lines may not be documented accurately and is
00286         //  subject to change without notice.
00287         //
00289         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00290 
00291         public:
00292                 // Clone
00293             virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00294 
00295         protected:
00296 
00297             // Constructor / Destructor
00298             KFbxLibrary(KFbxSdkManager& pManager, char const* pName);
00299             ~KFbxLibrary();
00300             virtual void Destruct   (bool pRecursive, bool pDependents);
00301 
00302             virtual void Construct(const KFbxLibrary* pFrom);
00303 
00304             mutable KFbxLocalizationManager * mLocalizationManager;
00305 
00306         #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00307     };
00308 
00309 
00310     template < class T > T* KFbxLibrary::InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse, KFbxObject* pOptContainer )
00311     {
00312         // first check all materials in the library.
00313         int i = 0;
00314         for( i = 0; i < GetMemberCount( FBX_TYPE(T) ); ++i )
00315         {
00316             T* lObject = GetMember( FBX_TYPE(T), i );
00317             if( pFilter.Match(lObject) )
00318                 return KFbxCast<T>(CloneAsset(lObject,pOptContainer));
00319         }
00320 
00321         if( pRecurse )
00322         {
00323             // then check all materials in each sub-library.
00324             for( i = 0; i < GetMemberCount( FBX_TYPE(KFbxLibrary) ); ++i )
00325             {
00326                 KFbxLibrary* lLibrary = GetMember( FBX_TYPE(KFbxLibrary), i );
00327                 T* lClonedObject = lLibrary->InstantiateMember( pFBX_TYPE, pFilter, pRecurse, pOptContainer );
00328                 if( lClonedObject )
00329                     return lClonedObject;
00330             }
00331         }
00332 
00333         return NULL;
00334     }
00335 
00336 
00341     class KFBX_DLL KFbxEventPopulateSystemLibrary : public KFbxEvent<KFbxEventPopulateSystemLibrary>
00342     {
00343       KFBXEVENT_DECLARE(KFbxEventPopulateSystemLibrary)
00344 
00345         public:         
00350 
00354             KFbxEventPopulateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00355 
00357        
00358             public:
00363 
00364                 inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00365             private:
00366                 KFbxLibrary*    mLibrary;
00368     };
00369 
00374     class KFBX_DLL KFbxEventUpdateSystemLibrary : public KFbxEvent<KFbxEventUpdateSystemLibrary>
00375     {
00376         KFBXEVENT_DECLARE(KFbxEventUpdateSystemLibrary)
00377         public:
00382 
00386             KFbxEventUpdateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00387 
00389 
00394 
00396             inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00397 
00399         private:
00400                 KFbxLibrary*    mLibrary;
00401     };
00402 
00413     class KFBX_DLL KFbxEventWriteLocalization : public KFbxEvent<KFbxEventWriteLocalization>
00414     {
00415         KFBXEVENT_DECLARE(KFbxEventWriteLocalization)
00416         public:
00417             KFbxEventWriteLocalization(KFbxLibrary *pAssetLibrary) { mAssetLibrary = pAssetLibrary; }
00418 
00419             inline KFbxLibrary* GetLibrary() const { return mAssetLibrary; }
00420 
00421         private:
00422             KFbxLibrary*    mAssetLibrary;
00423     };
00424 
00426     //
00427     //  WARNING!
00428     //
00429     //  Anything beyond these lines may not be documented accurately and is
00430     //  subject to change without notice.
00431     //
00433     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00434 
00435     // Some assets correspond 1:1 with files containing their actual data.
00436     class KFBX_DLL KFbxEventMapAssetFileToAssetObject : public KFbxEvent<KFbxEventMapAssetFileToAssetObject>
00437     {
00438         KFBXEVENT_DECLARE(KFbxEventMapAssetFileToAssetObject)
00439         public:
00440 
00441             // pFile - The asset file to query
00442             KFbxEventMapAssetFileToAssetObject(const char* pFile) :
00443                 mFilePath( pFile ), 
00444                 mAsset(NULL)
00445                 {}
00446 
00447             // listeners query this
00448             inline const char* GetFilePath() const { return mFilePath; }
00449 
00450             // listeners set this
00451             mutable KFbxObject* mAsset;
00452 
00453         private:
00454             KString mFilePath;
00455     };
00456 
00457     #endif //DOXYGEN_SHOULD_SKIP_THIS
00458 
00459 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00460 
00461 #endif // FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00462