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/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/fbxcore/fbxcollection/kfbxdocument.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxobjectfilter.h>
00045 
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047 
00048 class KFbxLocalizationManager;
00049 class KFbxCriteria;
00050 
00055 class KFBX_DLL KFbxLibrary : public KFbxDocument
00056 {
00057     KFBXOBJECT_DECLARE(KFbxLibrary,KFbxDocument);
00058 
00059     public:
00060 
00062         KFbxLibrary* GetParentLibrary(void) const;
00063 
00067         void SystemLibrary(bool pSystemLibrary);
00068 
00070         bool IsSystemLibrary() const;
00071 
00079         void LocalizationBaseNamePrefix(const char* pPrefix);
00080 
00082         KString LocalizationBaseNamePrefix() const;
00083 
00084         // =======================================================================
00085         //
00086         // sub-library
00087         //
00088         // =======================================================================
00089 
00094         bool AddSubLibrary(KFbxLibrary* pSubLibrary);
00095 
00100         bool RemoveSubLibrary(KFbxLibrary* pSubLibrary);
00101 
00103         int GetSubLibraryCount(void) const;
00104 
00108         KFbxLibrary* GetSubLibrary(int pIndex) const;
00109 
00115         KFbxObject* CloneAsset( KFbxObject* pToClone, KFbxObject* pOptionalDestinationContainer = NULL) const;
00116 
00117         
00124         static KFbxCriteria GetAssetCriteriaFilter();
00125 
00131         static KFbxCriteria GetAssetDependentsFilter();
00132 
00157         bool ImportAssets(KFbxLibrary* pSrcLibrary);
00158 
00184         bool ImportAssets(KFbxLibrary* pSrcLibrary, const KFbxCriteria& pAssetFilter);
00185 
00186 
00195         template < class T > T* InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse = true, KFbxObject* pOptContainer = NULL);
00196 
00197 
00198     // =======================================================================
00199     //
00200     // Localization
00201     //
00202     // =======================================================================
00206         KFbxLocalizationManager & GetLocalizationManager() const;
00207 
00214         virtual const char * Localize( const char * pID, const char * pDefault = NULL ) const;
00215 
00216     // =======================================================================
00217     //
00218     // Shading Object
00219     //
00220     // =======================================================================
00221 
00225         bool AddShadingObject(KFbxObject* pShadingObject);
00226 
00230         bool RemoveShadingObject(KFbxObject* pShadingObject);
00231 
00233         int GetShadingObjectCount(void) const;
00234 
00239         KFbxObject* GetShadingObject(int pIndex) const;
00240 
00246         int GetShadingObjectCount(
00247             const KFbxImplementationFilter & pCriteria
00248         ) const;
00249 
00256         KFbxObject* GetShadingObject(
00257             int pIndex,
00258             const KFbxImplementationFilter & pCriteria
00259         ) const;
00260 
00262         //
00263         //  WARNING!
00264         //
00265         //  Anything beyond these lines may not be documented accurately and is
00266         //  subject to change without notice.
00267         //
00269         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00270 
00271         public:
00272                 // Clone
00273             virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00274 
00275         protected:
00276 
00277             // Constructor / Destructor
00278             KFbxLibrary(KFbxSdkManager& pManager, char const* pName);
00279 
00280             virtual void Destruct(bool pRecursive, bool pDependents);
00281             virtual void Construct(const KFbxLibrary* pFrom);
00282 
00283             mutable KFbxLocalizationManager * mLocalizationManager;
00284 
00285         #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00286     };
00287 
00288 
00289     template < class T > T* KFbxLibrary::InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse, KFbxObject* pOptContainer )
00290     {
00291         // first check all materials in the library.
00292         int i = 0;
00293         for( i = 0; i < GetMemberCount( FBX_TYPE(T) ); ++i )
00294         {
00295             T* lObject = GetMember( FBX_TYPE(T), i );
00296             if( pFilter.Match(lObject) )
00297                 return KFbxCast<T>(CloneAsset(lObject,pOptContainer));
00298         }
00299 
00300         if( pRecurse )
00301         {
00302             // then check all materials in each sub-library.
00303             for( i = 0; i < GetMemberCount( FBX_TYPE(KFbxLibrary) ); ++i )
00304             {
00305                 KFbxLibrary* lLibrary = GetMember( FBX_TYPE(KFbxLibrary), i );
00306                 T* lClonedObject = lLibrary->InstantiateMember( pFBX_TYPE, pFilter, pRecurse, pOptContainer );
00307                 if( lClonedObject )
00308                     return lClonedObject;
00309             }
00310         }
00311 
00312         return NULL;
00313     }
00314 
00315 
00320     class KFBX_DLL KFbxEventPopulateSystemLibrary : public KFbxEvent<KFbxEventPopulateSystemLibrary>
00321     {
00322       KFBXEVENT_DECLARE(KFbxEventPopulateSystemLibrary)
00323 
00324         public:         
00329 
00333             KFbxEventPopulateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00334 
00336        
00337             public:
00342 
00343                 inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00344             private:
00345                 KFbxLibrary*    mLibrary;
00347     };
00348 
00353     class KFBX_DLL KFbxEventUpdateSystemLibrary : public KFbxEvent<KFbxEventUpdateSystemLibrary>
00354     {
00355         KFBXEVENT_DECLARE(KFbxEventUpdateSystemLibrary)
00356         public:
00361 
00365             KFbxEventUpdateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00366 
00368 
00373 
00375             inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00376 
00378         private:
00379                 KFbxLibrary*    mLibrary;
00380     };
00381 
00392     class KFBX_DLL KFbxEventWriteLocalization : public KFbxEvent<KFbxEventWriteLocalization>
00393     {
00394         KFBXEVENT_DECLARE(KFbxEventWriteLocalization)
00395         public:
00396             KFbxEventWriteLocalization(KFbxLibrary *pAssetLibrary) { mAssetLibrary = pAssetLibrary; }
00397 
00398             inline KFbxLibrary* GetLibrary() const { return mAssetLibrary; }
00399 
00400         private:
00401             KFbxLibrary*    mAssetLibrary;
00402     };
00403 
00405     //
00406     //  WARNING!
00407     //
00408     //  Anything beyond these lines may not be documented accurately and is
00409     //  subject to change without notice.
00410     //
00412     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00413 
00414     // Some assets correspond 1:1 with files containing their actual data.
00415     class KFBX_DLL KFbxEventMapAssetFileToAssetObject : public KFbxEvent<KFbxEventMapAssetFileToAssetObject>
00416     {
00417         KFBXEVENT_DECLARE(KFbxEventMapAssetFileToAssetObject)
00418         public:
00419 
00420             // pFile - The asset file to query
00421             KFbxEventMapAssetFileToAssetObject(const char* pFile) :
00422                 mAsset(NULL),
00423                 mFilePath( pFile )
00424                 {}
00425 
00426             // listeners query this
00427             inline const char* GetFilePath() const { return mFilePath; }
00428 
00429             // listeners set this
00430             mutable KFbxObject* mAsset;
00431 
00432         private:
00433             KString mFilePath;
00434     };
00435 
00436     #endif //DOXYGEN_SHOULD_SKIP_THIS
00437 
00438 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00439 
00440 #endif // FBXFILESDK_KFBXPLUGINS_KFBXLIBRARY_H
00441