kfbxlibrary.h

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 (C) 2001 - 2009 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 
00300             virtual void Destruct(bool pRecursive, bool pDependents);
00301             virtual void Construct(const KFbxLibrary* pFrom);
00302 
00303             mutable KFbxLocalizationManager * mLocalizationManager;
00304 
00305         #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00306     };
00307 
00308 
00309     template < class T > T* KFbxLibrary::InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse, KFbxObject* pOptContainer )
00310     {
00311         // first check all materials in the library.
00312         int i = 0;
00313         for( i = 0; i < GetMemberCount( FBX_TYPE(T) ); ++i )
00314         {
00315             T* lObject = GetMember( FBX_TYPE(T), i );
00316             if( pFilter.Match(lObject) )
00317                 return KFbxCast<T>(CloneAsset(lObject,pOptContainer));
00318         }
00319 
00320         if( pRecurse )
00321         {
00322             // then check all materials in each sub-library.
00323             for( i = 0; i < GetMemberCount( FBX_TYPE(KFbxLibrary) ); ++i )
00324             {
00325                 KFbxLibrary* lLibrary = GetMember( FBX_TYPE(KFbxLibrary), i );
00326                 T* lClonedObject = lLibrary->InstantiateMember( pFBX_TYPE, pFilter, pRecurse, pOptContainer );
00327                 if( lClonedObject )
00328                     return lClonedObject;
00329             }
00330         }
00331 
00332         return NULL;
00333     }
00334 
00335 
00340     class KFBX_DLL KFbxEventPopulateSystemLibrary : public KFbxEvent<KFbxEventPopulateSystemLibrary>
00341     {
00342       KFBXEVENT_DECLARE(KFbxEventPopulateSystemLibrary)
00343 
00344         public:         
00349 
00353             KFbxEventPopulateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00354 
00356        
00357             public:
00362 
00363                 inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00364             private:
00365                 KFbxLibrary*    mLibrary;
00367     };
00368 
00373     class KFBX_DLL KFbxEventUpdateSystemLibrary : public KFbxEvent<KFbxEventUpdateSystemLibrary>
00374     {
00375         KFBXEVENT_DECLARE(KFbxEventUpdateSystemLibrary)
00376         public:
00381 
00385             KFbxEventUpdateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00386 
00388 
00393 
00395             inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00396 
00398         private:
00399                 KFbxLibrary*    mLibrary;
00400     };
00401 
00412     class KFBX_DLL KFbxEventWriteLocalization : public KFbxEvent<KFbxEventWriteLocalization>
00413     {
00414         KFBXEVENT_DECLARE(KFbxEventWriteLocalization)
00415         public:
00416             KFbxEventWriteLocalization(KFbxLibrary *pAssetLibrary) { mAssetLibrary = pAssetLibrary; }
00417 
00418             inline KFbxLibrary* GetLibrary() const { return mAssetLibrary; }
00419 
00420         private:
00421             KFbxLibrary*    mAssetLibrary;
00422     };
00423 
00425     //
00426     //  WARNING!
00427     //
00428     //  Anything beyond these lines may not be documented accurately and is
00429     //  subject to change without notice.
00430     //
00432     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00433 
00434     // Some assets correspond 1:1 with files containing their actual data.
00435     class KFBX_DLL KFbxEventMapAssetFileToAssetObject : public KFbxEvent<KFbxEventMapAssetFileToAssetObject>
00436     {
00437         KFBXEVENT_DECLARE(KFbxEventMapAssetFileToAssetObject)
00438         public:
00439 
00440             // pFile - The asset file to query
00441             KFbxEventMapAssetFileToAssetObject(const char* pFile) :
00442                 mFilePath( pFile ), 
00443                 mAsset(NULL)
00444                 {}
00445 
00446             // listeners query this
00447             inline const char* GetFilePath() const { return mFilePath; }
00448 
00449             // listeners set this
00450             mutable KFbxObject* mAsset;
00451 
00452         private:
00453             KString mFilePath;
00454     };
00455 
00456     #endif //DOXYGEN_SHOULD_SKIP_THIS
00457 
00458 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00459 
00460 #endif // FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00461