FBX SDK Reference Guide: kfbxlibrary.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_LIBRARY_H_
00005 #define _FBXSDK_LIBRARY_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 <kaydaradef.h>
00042 #ifndef KFBX_DLL
00043     #define KFBX_DLL K_DLLIMPORT
00044 #endif
00045 
00046 #include <fbxcore/fbxcollection/kfbxdocument.h>
00047 #include <kfbxplugins/kfbxobjectfilter.h>
00048 
00049 #include <fbxfilesdk_nsbegin.h>
00050 
00051 class KFbxWriterFbx6;
00052 class KFbxLocalizationManager;
00053 class KFbxCriteria;
00054 
00058 class KFBX_DLL KFbxLibrary : public KFbxDocument
00059 {
00060     KFBXOBJECT_DECLARE(KFbxLibrary,KFbxDocument);
00061 
00062     public:
00063 
00065         KFbxLibrary* GetParentLibrary(void) const;
00066 
00067         void SystemLibrary(bool pSystemLibrary);
00068         bool IsSystemLibrary() const;
00069 
00080         void LocalizationBaseNamePrefix(const char* pPrefix);
00081         KString LocalizationBaseNamePrefix() const;
00082 
00083         // =======================================================================
00084         //
00085         // Sub library
00086         //
00087         // =======================================================================
00088 
00090         bool AddSubLibrary(KFbxLibrary* pSubLibrary);
00091 
00093         bool RemoveSubLibrary(KFbxLibrary* pSubLibrary);
00094 
00096         int GetSubLibraryCount(void) const;
00097 
00099         KFbxLibrary* GetSubLibrary(int pIndex) const;
00100 
00109         int GetSubLibraryCount(
00110             const KFbxImplementationFilter & pCriteria
00111         ) const;
00112 
00120         KFbxLibrary* GetSubLibrary(
00121             int pIndex,
00122             const KFbxImplementationFilter & pCriteria
00123         ) const;
00124 
00125 
00126         KFbxObject* CloneAsset( KFbxObject* pToClone, KFbxObject* pOptionalDestinationContainer = NULL) const;
00127 
00128         //
00129         // Returns a criteria filter which can be used to ... filter ... objects
00130         // when iterating items in the library; only real 'assets' will be returned,
00131         // rather than FBX support objects.  This includes, at this time,
00132         // lights, environments, materials and textures (maps)
00133         //
00134         // This is typically used to IMPORT from a library.
00135         //
00136         static KFbxCriteria GetAssetCriteriaFilter();
00137 
00138         //
00139         // Returns a filter which should be used when cloning / exporting objects --
00140         // this filters out objects that should stay in the asset library.
00141         //
00142         // This is typically used to EXPORT from a library (or CLONE from a library,
00143         // although CloneAsset does all the nitty gritty for you)
00144         //
00145         static KFbxCriteria GetAssetDependentsFilter();
00146 
00170         bool ImportAssets(KFbxLibrary* pSrcLibrary);
00171         bool ImportAssets(KFbxLibrary* pSrcLibrary, const KFbxCriteria&);
00172 
00173 
00182         template < class T > T* InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse = true, KFbxObject* pOptContainer = NULL);
00183 
00184 
00185     // =======================================================================
00186     //
00187     // Localization
00188     //
00189     // =======================================================================
00193         KFbxLocalizationManager & GetLocalizationManager() const;
00194 
00201         virtual const char * Localize( const char * pID, const char * pDefault = NULL ) const;
00202 
00203     // =======================================================================
00204     //
00205     // Shading Node
00206     //
00207     // =======================================================================
00208 
00210         bool AddShadingObject(KFbxObject* pShadingObject);
00211 
00213         bool RemoveShadingObject(KFbxObject* pShadingObject);
00214 
00216         int GetShadingObjectCount(void) const;
00217 
00219         KFbxObject* GetShadingObject(int pIndex) const;
00220 
00228         int GetShadingObjectCount(
00229             const KFbxImplementationFilter & pCriteria
00230         ) const;
00231 
00239         KFbxObject* GetShadingObject(
00240             int pIndex,
00241             const KFbxImplementationFilter & pCriteria
00242         ) const;
00243 
00245         //
00246         //  WARNING!
00247         //
00248         //  Anything beyond these lines may not be documented accurately and is
00249         //  subject to change without notice.
00250         //
00252         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00253 
00254         public:
00255                 // Clone
00256             virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00257 
00258         protected:
00259 
00260             // Constructor / Destructor
00261             KFbxLibrary(KFbxSdkManager& pManager, char const* pName);
00262             ~KFbxLibrary();
00263             virtual void Destruct   (bool pRecursive, bool pDependents);
00264 
00265             virtual void Construct(const KFbxLibrary* pFrom);
00266 
00267             mutable KFbxLocalizationManager * mLocalizationManager;
00268 
00269             friend class KFbxWriterFbx6;
00270 
00271         #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00272     };
00273 
00274 
00275     template < class T > T* KFbxLibrary::InstantiateMember( T const* pFBX_TYPE, const KFbxObjectFilter& pFilter, bool pRecurse, KFbxObject* pOptContainer )
00276     {
00277         // first check all materials in the library.
00278         int i = 0;
00279         for( i = 0; i < GetMemberCount( FBX_TYPE(T) ); ++i )
00280         {
00281             T* lObject = GetMember( FBX_TYPE(T), i );
00282             if( pFilter.Match(lObject) )
00283                 return KFbxCast<T>(CloneAsset(lObject,pOptContainer));
00284         }
00285 
00286         if( pRecurse )
00287         {
00288             // then check all materials in each sub-library.
00289             for( i = 0; i < GetMemberCount( FBX_TYPE(KFbxLibrary) ); ++i )
00290             {
00291                 KFbxLibrary* lLibrary = GetMember( FBX_TYPE(KFbxLibrary), i );
00292                 T* lClonedObject = lLibrary->InstantiateMember( pFBX_TYPE, pFilter, pRecurse, pOptContainer );
00293                 if( lClonedObject )
00294                     return lClonedObject;
00295             }
00296         }
00297 
00298         return NULL;
00299     }
00300 
00301 
00306     class KFBX_DLL KFbxEventPopulateSystemLibrary : public KFbxEvent<KFbxEventPopulateSystemLibrary>
00307     {
00308       KFBXEVENT_DECLARE(KFbxEventPopulateSystemLibrary)
00309 
00310         public:         
00315 
00317             KFbxEventPopulateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00318 
00320        
00321             public:
00326 
00327                 inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00328             private:
00329                 KFbxLibrary*    mLibrary;
00331     };
00332 
00337     class KFBX_DLL KFbxEventUpdateSystemLibrary : public KFbxEvent<KFbxEventUpdateSystemLibrary>
00338     {
00339         KFBXEVENT_DECLARE(KFbxEventUpdateSystemLibrary)
00340         public:
00345 
00347             KFbxEventUpdateSystemLibrary(KFbxLibrary *pLibrary) { mLibrary = pLibrary; }
00348 
00350 
00355 
00357             inline KFbxLibrary* GetLibrary() const { return mLibrary; }
00358 
00360         private:
00361                 KFbxLibrary*    mLibrary;
00362     };
00363 
00374     class KFBX_DLL KFbxEventWriteLocalization : public KFbxEvent<KFbxEventWriteLocalization>
00375     {
00376         KFBXEVENT_DECLARE(KFbxEventWriteLocalization)
00377         public:
00378             KFbxEventWriteLocalization(KFbxLibrary *pAssetLibrary) { mAssetLibrary = pAssetLibrary; }
00379 
00380             inline KFbxLibrary* GetLibrary() const { return mAssetLibrary; }
00381 
00382         private:
00383             KFbxLibrary*    mAssetLibrary;
00384     };
00385 
00387     //
00388     //  WARNING!
00389     //
00390     //  Anything beyond these lines may not be documented accurately and is
00391     //  subject to change without notice.
00392     //
00394     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00395 
00396     // Some assets correspond 1:1 with files containing their actual data.
00397     class KFBX_DLL KFbxEventMapAssetFileToAssetObject : public KFbxEvent<KFbxEventMapAssetFileToAssetObject>
00398     {
00399         KFBXEVENT_DECLARE(KFbxEventMapAssetFileToAssetObject)
00400         public:
00401 
00402             // pFile - The asset file to query
00403             KFbxEventMapAssetFileToAssetObject(const char* pFile) :
00404                 mFilePath( pFile ), 
00405                 mAsset(NULL)
00406                 {}
00407 
00408             // listeners query this
00409             inline const char* GetFilePath() const { return mFilePath; }
00410 
00411             // listeners set this
00412             mutable KFbxObject* mAsset;
00413 
00414         private:
00415             KString mFilePath;
00416     };
00417 
00418     #endif //DOXYGEN_SHOULD_SKIP_THIS
00419 
00420 #include <fbxfilesdk_nsend.h>
00421 
00422 #endif //_FBXSDK_LIBRARY_H_