kfbxobject.h

Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_OBJECT_H_
00005 #define _FBXSDK_OBJECT_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2004 - 2007 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 
00042 #include <kaydaradef.h>
00043 #ifndef KFBX_DLL 
00044     #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046 
00047 #include <kaydara.h>
00048 
00049 #include <klib/kstring.h>
00050 #include <klib/kstringlist.h>
00051 #include <klib/kname.h>
00052 #include <klib/karrayul.h>
00053 
00054 #include <kfbxplugins/kfbxplug.h>
00055 #include <kfbxplugins/kfbxproperty.h>
00056 
00057 #ifndef MB_FBXSDK
00058 #include <kbaselib_nsuse.h>
00059 #endif
00060 #include <kbaselib_forward.h>
00061 
00062 #include <fbxfilesdk_nsbegin.h>
00063 
00064     class KFbxSdkManager;
00065     class KFbxScene;
00066     class KFbxObject_internal;
00067     class KFbxProperty_internal;
00068     class KFbxTakeNodeContainer;
00069     class KFbxTakeNode;
00070 
00071     #define KFBXOBJECT_DECLARE(Class)   KFBXPLUG_DECLARE(Class) 
00072     #define KFBXOBJECT_IMPLEMENT(Class) KFBXPLUG_IMPLEMENT(Class) 
00073 
00077     class KFBX_DLL KFbxObject : public KFbxPlug
00078     {
00079         KFBXOBJECT_DECLARE(KFbxObject);
00080 
00081 
00082         public:
00087 
00091     void SetName(char const* pName, bool wantPrefix=false);
00092 
00096     char const* GetName() const;
00097 
00101             KString GetNameWithoutNameSpacePrefix() const;
00102 
00106             KString GetNameWithNameSpacePrefix() const;
00107 
00111             void SetInitialName(char const* pName);
00112 
00116     char const* GetInitialName() const;
00117 
00118 
00122             KString GetNameSpaceOnly( ) { return mName.GetNameSpace();}
00123             
00127             void SetNameSpace(KString pNameSpace);
00129 
00136     int GetPropertyCount() const;
00137 
00145     KFbxProperty    GetProperty(int pIndex) const;
00146 
00151     KFbxProperty FindProperty(const char* pName, bool pCaseSensitive = true) const;
00152     KFbxProperty FindProperty(const char* pName, KFbxDataType const &pDataType, bool pCaseSensitive = true) const;
00153 
00155 
00160             // Properties
00161             inline int              GetSrcPropertyCount     ()                                      { return GetFbxSrcCount(KFbxProperty::ClassId); }
00162             inline KFbxProperty     GetSrcProperty          (int pIndex=0)                          { return *((KFbxProperty *)GetFbxSrc(pIndex,KFbxProperty::ClassId)); }
00163             inline KFbxProperty     FindSrcProperty         (const char *pName,int pStartIndex=0)   { return *((KFbxProperty *)FindFbxSrc(pName,KFbxProperty::ClassId,pStartIndex)); }
00164             inline bool             ConnectSrcProperty      (KFbxProperty const & pProperty)        { return ConnectFbxSrc((KFbxPlug *)&pProperty);     }
00165             inline bool             IsConnectedSrcProperty  (KFbxProperty const & pProperty)        { return IsConnectedFbxSrc((KFbxPlug *)&pProperty); }
00166             inline bool             DisconnectSrcProperty   (KFbxProperty const & pProperty)        { return DisconnectFbxSrc((KFbxPlug *)&pProperty);  }
00167 
00168             inline int              GetDstPropertyCount     ()                                      { return GetFbxDstCount(KFbxProperty::ClassId); }
00169             inline KFbxProperty     GetDstProperty          (int pIndex=0)                          { return *((KFbxProperty *)GetFbxDst(pIndex,KFbxProperty::ClassId)); }
00170             inline KFbxProperty     FindDstProperty         (const char *pName,int pStartIndex=0)   { return *((KFbxProperty *)FindFbxDst(pName,KFbxProperty::ClassId,pStartIndex)); }
00171             inline bool             ConnectDstProperty      (KFbxProperty const & pProperty)        { return ConnectFbxDst((KFbxPlug *)&pProperty);     }
00172             inline bool             IsConnectedDstProperty  (KFbxProperty const & pProperty)        { return IsConnectedFbxDst((KFbxPlug *)&pProperty); }
00173             inline bool             DisconnectDstProperty   (KFbxProperty const & pProperty)        { return DisconnectFbxDst((KFbxPlug *)&pProperty);  }
00175 
00176         void SetUserDataPtr(void* pUserData);
00177         void* GetUserDataPtr();
00178        
00183         KFbxScene* GetScene();
00184 
00189         const KFbxScene* GetScene() const;
00190 
00192     //
00193     //  WARNING!
00194     //
00195     //  Anything beyond these lines may not be documented accurately and is 
00196     //  subject to change without notice.
00197     //
00199 
00200     #ifndef DOXYGEN_SHOULD_SKIP_THIS
00201 
00205         KArrayTemplate<KString*> GetNameSpaceArray( char identifier ) { return mName.GetNameSpaceArray(identifier);}
00206         
00210         KString GetNameOnly() const;
00211 
00212         bool IsModel() { return mIsModel; }
00213         void SetIsModel(bool state) { mIsModel = state; }
00214 
00215     public:
00216 
00217         typedef enum 
00218         {
00219             eNODE                   = 0x00000001,
00220             eTEXTURE                = 0x00000002,
00221             eMATERIAL               = 0x00000003,
00222             eGOBO                   = 0x00000004,
00223             eMEDIA                  = 0x00000005,
00224             eACTOR                  = 0x00000006,
00225             eMARKER_SET             = 0x00000007,
00226             eCHARACTER              = 0x00000008,
00227             eCHARACTER_POSE         = 0x00000009,
00228             eGENERIC_NODE           = 0x0000000a,
00229             ePOSE                   = 0x0000000b,
00230             eCONTROLSET_PLUG        = 0x0000000c,
00231             eCONSTRAINT             = 0x0000000d,
00232             eNODEATTRIBUTE          = 0x0000000e,
00233             eGEOMETRY_WEIGHTED_MAP  = 0x00000010,
00234             eSCENE                  = 0x00000011,
00235             eDEFORMER               = 0x00000012,
00236             eSUBDEFORMER            = 0x00000013,
00237             eGLOBAL_SETTING         = 0x00000014,
00238             eCACHE                  = 0x00000015,
00239         } ENameSpace;
00240 
00241         virtual ENameSpace GetNameSpace() const {return ENameSpace(0); }
00242         KString GetNameSpacePrefix() const;
00243         static char const* GetNamePrefix() { return 0; }
00244 
00245         static KString GetDefaultNameSpacePrefix(ENameSpace pNameSpace);
00246         static KString RemovePrefix(char* pName);
00247         static KString StripPrefix(KString lName);
00248         static KString StripPrefix(char* pName);
00249 
00250         // internal property management
00251         protected:
00252             void            RegisterProperty(KFbxProperty* pProperty);
00253             void            UnregisterProperty(KFbxProperty* pProperty);
00254             KFbxProperty*   GetProperty(KProperty* pKProperty);
00255             virtual void    PropertyDefaultValueChanged(KFbxProperty* pProperty);
00256         public:
00257             void            PublishProperties(); 
00258 
00259         // Connection management
00260         typedef enum 
00261         {
00262             eSURFACE_CLONE,
00263             eREFERENCE_CLONE,
00264             eDEEP_CLONE
00265         } ECloneType;
00266 
00267         // Clone
00268         virtual KFbxObject* Clone(KFbxObject::ECloneType pCloneType = eDEEP_CLONE) const { return 0; }
00269 
00270 
00271 
00272     protected:
00273         KFbxObject(KFbxSdkManager& pManager, char const* pName);
00274         virtual ~KFbxObject();
00275 
00276         virtual void Construct();
00277         virtual void Destruct(bool pRecursive, bool pDependents);
00278 
00279     public:
00280         virtual KFbxSdkManager* GetFbxSdkManager();
00281         virtual KObject*        GetFbxObject_internal();
00282         virtual KObject const*  GetFbxObject_internal() const;
00283         virtual KPlug*          GetInternalPlug(bool pCreateOnDemand=false);
00284         virtual KPlug const*    GetInternalPlug(bool pCreateOnDemand=false) const;
00285         virtual kFbxClassId  GetRuntimeClassId() const;
00286 
00287     protected:
00288         virtual KFbxTakeNodeContainer* GetTakeNodeContainer();
00289 
00290     protected:
00291         KFbxObject& operator=(KFbxObject const& pObject);
00292         
00293         virtual bool            SetRuntimeClassId(kFbxClassId pClassId);
00294         virtual                 bool FbxPlugNotify(KFbxPlugEvent const &pEvent);
00295 
00296         virtual KString         GetTypeName() const;
00297         virtual KStringList     GetTypeFlags() const;
00298 
00299         virtual void            PropertyAdded(KFbxProperty* pProperty);
00300         virtual void            PropertyRemoved(KFbxProperty* pProperty);   
00301 
00302         // Animation Management
00303         virtual void            AddChannels(KFbxTakeNode *pTakeNode);
00304         virtual void            UpdateChannelFromProperties(KFbxTakeNode *pTakeNode);
00305         
00306         virtual void SetScene(KFbxScene* pScene);
00307 
00308         KFbxObject_internal*                mInternal;
00309         KName                               mName;
00310         KArrayTemplate<KFbxProperty*>       mProperties;
00311         void*                               mUserData;
00312         KFbxSdkManager*                     mManager;
00313         kFbxClassId                     mRuntimeClassId;
00314 
00315         bool                mIsModel; 
00316         // normally stays at false unless while we
00317         // are renaming the objects (on import) we detect that this node is actually
00318         // a Model node.
00319 
00320         // friend classes for sdk access
00321         friend class KFbxReaderFbx;
00322         friend class KFbxWriterFbx6;
00323         friend class KFbxScene;
00324         friend class KFbxObject_internal;
00325         friend class KFbxProperty;
00326 
00327     #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00328 
00329     };
00330 
00331     typedef KFbxObject* HKFbxObject;
00332 
00333     // template access functions SRC
00334     template < class T > inline int KFbxGetSrcCount(KFbxObject const *pObject, T const* VC6Dummy = 0)                               { return pObject ? pObject->GetSrcObjectCount(T::ClassId) : 0; }
00335     template < class T > inline int KFbxGetSrcCount(KFbxObject const *pObject,kFbxClassId pClassId, T const* VC6Dummy = 0)      { return pObject ? pObject->GetSrcObjectCount(pClassId) : 0;     }
00336     template < class T > inline T* KFbxGetSrc(KFbxObject const *pObject,int pIndex=0)                                               { return pObject ? (T *) pObject->GetSrcObject(T::ClassId,pIndex) : 0; }
00337     template < class T > inline T* KFbxGetSrc(KFbxObject const *pObject,int pIndex,kFbxClassId pClassId)                        { return pObject ? (T *) pObject->GetSrcObject(pClassId,pIndex) : 0;    }
00338     template < class T > inline T* KFbxFindSrc(KFbxObject const *pObject,char const *pName,int pIndex=0)                            { return pObject ? (T *) pObject->FindSrcObject(T::ClassId,pName,pIndex) : 0;   }
00339     template < class T > inline T* KFbxFindSrc(KFbxObject const *pObject,char const *pName,kFbxClassId pClassId,int pIndex=0)   { return pObject ? (T *) pObject->FindSrcObject(pClassId,pName,pIndex) : 0; }
00340     inline bool KFbxConnectSrc(KFbxObject *pDstObject,KFbxObject *pSrcObject)                                               { return (pSrcObject && pDstObject) ? pDstObject->ConnectSrcObject(pSrcObject) : 0; }
00341     template < class T > inline bool KFbxDisconnectAllSrc(KFbxObject *pObject,T *VC6Dummy=0)                                { return pObject->DisconnectAllSrcObject(T::ClassId);   }
00342 
00343     // template access functions DST
00344     template < class T > inline int KFbxGetDstCount(KFbxObject const *pObject, T const* VC6Dummy = 0)                               { return pObject ? pObject->GetDstObjectCount(T::ClassId) : 0; }
00345     template < class T > inline int KFbxGetDstCount(KFbxObject const *pObject,kFbxClassId pClassId, T const* VC6Dummy = 0)      { return pObject ? pObject->GetDstObjectCount(pClassId) : 0;     }
00346     template < class T > inline T* KFbxGetDst(KFbxObject const *pObject,int pIndex=0)                                               { return pObject ? (T *) pObject->GetDstObject(T::ClassId,pIndex) : 0; }
00347     template < class T > inline T* KFbxGetDst(KFbxObject const *pObject,int pIndex,kFbxClassId pClassId)                        { return pObject ? (T *) pObject->GetDstObject(pClassId,pIndex) : 0;    }
00348     template < class T > inline T* KFbxFindDst(KFbxObject const *pObject,char const *pName,int pIndex=0)                            { return pObject ? (T *) pObject->FindDstObject(T::ClassId,pName,pIndex) : 0;   }
00349     template < class T > inline T* KFbxFindDst(KFbxObject const *pObject,char const *pName,kFbxClassId pClassId,int pIndex=0)   { return pObject ? (T *) pObject->FindDstObject(pClassId,pName,pIndex) : 0; }
00350     inline bool KFbxConnectDst(KFbxObject *pSrcObject,KFbxObject *pDstObject)                                               { return (pSrcObject && pDstObject) ? pDstObject->ConnectSrcObject(pSrcObject) : 0; }
00351     template < class T > inline bool KFbxDisconnectAllDst(KFbxObject *pObject,T *VC6Dummy=0)                                { return pObject->DisconnectAllDstObject(T::ClassId);   }
00352 
00353 #include <fbxfilesdk_nsend.h>
00354 
00355 #endif // #ifndef _FBXSDK_OBJECT_H_
00356 
00357