kfbxtypes.h

Go to the documentation of this file.
00001 
00004 #ifndef _KFbxTypes_h
00005 #define _KFbxTypes_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 #ifndef MB_FBXSDK
00048 #include <kbaselib_nsuse.h>
00049 #endif
00050 #include <kbaselib_forward.h>
00051 #include <klib/kdebug.h>
00052 #include <klib/kstring.h>
00053 
00054 #include <kfbxplugins/kfbxsymbol.h>
00055 #include <kfbxplugins/kfbxdatastream.h>
00056 #include <kfbxplugins/kfbxcolor.h>
00057 
00058 #include <fbxfilesdk_nsbegin.h>
00059 
00060     class   KFbxSdkManager;
00061     class   KFbxTypeInfo_internal;
00062 
00063     // Type definitions
00064     enum EFbxType {
00065         eUNIDENTIFIED,
00066         eBOOL1,
00067         eINTEGER1,
00068         eFLOAT1,
00069         eDOUBLE1,
00070         eDOUBLE3,
00071         eDOUBLE4,
00072         eDOUBLE44,
00073         eENUM,
00074         eSTRING,
00075         eTIME,
00076         eREFERENCE,  // used as a port entry to reference object or properties
00077         eDATASTREAM,  // used as a port entry to reference object or properties
00078         eMAX_TYPES
00079     };
00080 
00081     // Base Type for vectors
00082     template<class T> class fbxVectorTemplate3 {
00083         public:
00084             inline fbxVectorTemplate3()                          { *this = 0;  }
00085             inline fbxVectorTemplate3(T pData0,T pData1,T pData2) { mData[0] = pData0; mData[1] = pData1; mData[2] = pData2;  }
00086             inline ~fbxVectorTemplate3() {}
00087         public:
00088             inline T &operator[](int pIndex) { return mData[pIndex]; }
00089             inline T const&operator[](int pIndex) const { return mData[pIndex]; }
00090             inline fbxVectorTemplate3<T> &operator=(int pValue) { mData[0] = pValue; mData[1] = pValue; mData[2] = pValue; return *this; }
00091     inline bool operator==(fbxVectorTemplate3<T> const & pRHS) const { return ((mData[0] == pRHS.mData[0]) && (mData[1] == pRHS.mData[1]) && (mData[2] == pRHS.mData[2])); }
00092 
00093         private:
00094             T mData[3];
00095     };
00096 
00097     template<class T> class fbxVectorTemplate4 {
00098         public:
00099             inline fbxVectorTemplate4()                                     { *this = 0; }
00100             inline fbxVectorTemplate4(T pData0,T pData1,T pData2,T pData3)  { mData[0] = pData0; mData[1] = pData1; mData[2] = pData2; mData[3] = pData3;   }
00101             inline ~fbxVectorTemplate4() {}
00102         public:
00103             inline T &operator[](int pIndex) { return mData[pIndex]; }
00104             inline T const&operator[](int pIndex) const { return mData[pIndex]; }
00105             inline fbxVectorTemplate4<T> &operator=(int pValue) { mData[0] = pValue; mData[1] = pValue; mData[2] = pValue; mData[3] = pValue; return *this; }
00106     inline bool operator==(fbxVectorTemplate4<T> const & pRHS) const { return ((mData[0] == pRHS.mData[0]) && (mData[1] == pRHS.mData[1]) && (mData[2] == pRHS.mData[2]) && (mData[3] == pRHS.mData[3])); }
00107 
00108         private:
00109             T mData[4];
00110     };
00111 
00112     // Correcponding C Types
00113     typedef bool                                fbxBool1;
00114     typedef int                                 fbxInteger1;
00115     typedef float                               fbxFloat1;
00116     typedef double                              fbxDouble1;
00117     typedef fbxVectorTemplate3<double>          fbxDouble3;
00118     typedef fbxVectorTemplate4<double>          fbxDouble4;
00119     typedef fbxVectorTemplate4<fbxDouble4>      fbxDouble44;
00120     typedef int                                 fbxEnum;
00121     typedef KString                             fbxString;
00122     typedef KTime                               fbxTime;
00123     class                                       fbxReference {}; // void type for references
00124     typedef KFbxDataStream                      fbxDataStream;
00125 
00126     // Type memory footprint
00127     const size_t FbxTypeSizeOf[eMAX_TYPES] = {
00128         0,
00129         sizeof(fbxBool1),
00130         sizeof(fbxInteger1),
00131         sizeof(fbxFloat1),
00132         sizeof(fbxDouble1),
00133         sizeof(fbxDouble3),
00134         sizeof(fbxDouble4),
00135         sizeof(fbxDouble44),
00136         sizeof(fbxEnum),
00137         sizeof(fbxString),
00138         sizeof(fbxTime),
00139         sizeof(fbxReference),
00140         sizeof(fbxDataStream)
00141     };
00142 
00143     // Type management for properties
00144     template <class T> inline EFbxType FbxTypeOf( T const &pItem ) { K_ASSERT_MSG_NOW("Unknown type" );  return eUNIDENTIFIED; }
00145 
00146     inline EFbxType FbxTypeOf( fbxBool1 const &pItem )      { return eBOOL1;    }
00147     inline EFbxType FbxTypeOf( fbxInteger1 const &pItem )   { return eINTEGER1; }
00148     inline EFbxType FbxTypeOf( fbxFloat1 const &pItem )     { return eFLOAT1;   }
00149     inline EFbxType FbxTypeOf( fbxDouble1 const &pItem )        { return eDOUBLE1;  }
00150     inline EFbxType FbxTypeOf( fbxDouble3 const &pItem )        { return eDOUBLE3;  }
00151     inline EFbxType FbxTypeOf( fbxDouble4 const &pItem )        { return eDOUBLE4;  }
00152     inline EFbxType FbxTypeOf( fbxDouble44 const &pItem )   { return eDOUBLE44; }
00153 //  inline EFbxType FbxTypeOf( fbxEnum const &pItem )       { return eENUM; }
00154     inline EFbxType FbxTypeOf( fbxString const &pItem )     { return eSTRING;   }
00155     inline EFbxType FbxTypeOf( fbxTime  const &pItem )      { return eTIME;      }
00156     inline EFbxType FbxTypeOf( fbxReference const &pItem )  { return eREFERENCE; }
00157     inline EFbxType FbxTypeOf( fbxDataStream const &pItem ) { return eDATASTREAM; }
00158     // Additional types
00159     inline EFbxType FbxTypeOf( KFbxColor    const &pItem )  { return eDOUBLE4; }
00160 
00161     // internal type management
00162     template< class T1,class T2 > inline bool internalfbxCopy2( T1 &pDst,T2 const &pSrc ) { pDst[0] = (T1)pSrc[0]; pDst[1] = (T1)pSrc[1]; return true; }
00163     template< class T1,class T2 > inline bool internalfbxCopy3( T1 &pDst,T2 const &pSrc ) { pDst[0] = (T1)pSrc[0]; pDst[1] = (T1)pSrc[1]; pDst[2] = (T1)pSrc[2]; return true; }
00164     template< class T1,class T2 > inline bool internalfbxCopy4( T1 &pDst,T2 const &pSrc ) { pDst[0] = (T1)pSrc[0]; pDst[1] = (T1)pSrc[1]; pDst[2] = (T1)pSrc[2]; pDst[3] = (T1)pSrc[3]; return true; }
00165 
00166     // Copy types and conversions
00167     template< class T1,class T2 > inline bool fbxCopy ( T1 &pDst,T2 const &pSrc ) { K_ASSERT_MSG_NOW("Incompatible type assigment" ); return false; }
00168 
00169     inline bool fbxCopy( fbxBool1 &pDst,fbxBool1 const &pSrc )          { pDst=pSrc; return true; }
00170     inline bool fbxCopy( fbxInteger1 &pDst,fbxInteger1 const &pSrc )    { pDst=pSrc; return true; }
00171     inline bool fbxCopy( fbxFloat1 &pDst,fbxFloat1 const &pSrc )        { pDst=pSrc; return true; }
00172     inline bool fbxCopy( fbxDouble1 &pDst,fbxDouble1 const &pSrc )      { pDst=pSrc; return true; }
00173     inline bool fbxCopy( fbxDouble3 &pDst,fbxDouble3 const &pSrc )      { pDst=pSrc; return true; }
00174     inline bool fbxCopy( fbxDouble4 &pDst,fbxDouble4 const &pSrc )      { pDst=pSrc; return true; }
00175     inline bool fbxCopy( fbxDouble44 &pDst,fbxDouble44 const &pSrc )    { pDst=pSrc; return true; }
00176 //  inline bool fbxCopy( fbxEnum &pDst,fbxEnum const &pSrc )            { pDst=pSrc; return true; }
00177     inline bool fbxCopy( fbxString &pDst,fbxString const &pSrc )        { pDst=pSrc; return true; }
00178     inline bool fbxCopy( fbxTime &pDst,fbxTime const &pSrc )            { pDst=pSrc; return true; }
00179     inline bool fbxCopy( fbxReference &pDst,fbxReference const &pSrc )  { pDst=pSrc; return true; }
00180     inline bool fbxCopy( fbxDataStream &pDst,fbxDataStream const &pSrc ){ pDst=pSrc; return true; }
00181 
00182     template< class T > inline bool fbxCopy( T &pDst,void const *pSrc,EFbxType pSrcType)
00183     {
00184         switch (pSrcType) {
00185             case eBOOL1:    return fbxCopy( pDst,*(fbxBool1 *)pSrc );
00186             case eINTEGER1: return fbxCopy( pDst,*(fbxInteger1 *)pSrc );
00187             case eFLOAT1:   return fbxCopy( pDst,*(fbxFloat1 *)pSrc );
00188             case eDOUBLE1:  return fbxCopy( pDst,*(fbxDouble1 *)pSrc );
00189             case eDOUBLE3:  return fbxCopy( pDst,*(fbxDouble3 *)pSrc );
00190             case eDOUBLE4:  return fbxCopy( pDst,*(fbxDouble4 *)pSrc );
00191             case eDOUBLE44: return fbxCopy( pDst,*(fbxDouble44 *)pSrc );
00192             case eENUM:     return fbxCopy( pDst,*(fbxEnum *)pSrc );
00193             case eSTRING:   return fbxCopy( pDst,*(fbxString *)pSrc );
00194             case eTIME:     return fbxCopy( pDst,*(fbxTime *)pSrc );
00195             case eREFERENCE:        
00196                 K_ASSERT_MSG_NOW("Trying to set value on a void Reference type" );
00197             break;
00198             case eDATASTREAM:   return fbxCopy( pDst,*(fbxDataStream *)pSrc );
00199             default:
00200                 K_ASSERT_MSG_NOW("Trying to assign an unknown type" );
00201         }
00202         return false;
00203     }
00204 
00205     template< class T > inline bool fbxCopy( void *pDst,EFbxType pDstType,T const &pSrc)
00206     {
00207         switch (pDstType) {
00208             case eBOOL1:    return fbxCopy( *(fbxBool1 *)pDst,pSrc    );
00209             case eINTEGER1: return fbxCopy( *(fbxInteger1 *)pDst,pSrc );
00210             case eFLOAT1:   return fbxCopy( *(fbxFloat1 *)pDst,pSrc   );
00211             case eDOUBLE1:  return fbxCopy( *(fbxDouble1 *)pDst,pSrc  );
00212             case eDOUBLE3:  return fbxCopy( *(fbxDouble3 *)pDst,pSrc  );
00213             case eDOUBLE4:  return fbxCopy( *(fbxDouble4 *)pDst,pSrc  );
00214             case eDOUBLE44: return fbxCopy( *(fbxDouble44 *)pDst,pSrc );
00215             case eENUM:     return fbxCopy( *(fbxEnum *)pDst,pSrc     );
00216             case eSTRING:   return fbxCopy( *(fbxString *)pDst,pSrc   );
00217             case eTIME:     return fbxCopy( *(fbxTime *)pDst,pSrc   );
00218             case eREFERENCE:        
00219                 K_ASSERT_MSG_NOW("Trying to set value on a void Reference type" );
00220             break;
00221             case eDATASTREAM:   return fbxCopy( *(fbxDataStream *)pDst,pSrc   );
00222             default:
00223                 K_ASSERT_MSG_NOW("Trying to assign an unknown type" );
00224         }
00225         return false;
00226     }
00227 
00228     inline bool fbxCopy( void *pDst,EFbxType pDstType,void const *pSrc,EFbxType pSrcType)
00229     {
00230         switch (pDstType) {
00231             case eBOOL1:    return fbxCopy( pDst,pDstType,*(fbxBool1 *)pSrc );
00232             case eINTEGER1: return fbxCopy( pDst,pDstType,*(fbxInteger1 *)pSrc );
00233             case eFLOAT1:   return fbxCopy( pDst,pDstType,*(fbxFloat1 *)pSrc );
00234             case eDOUBLE1:  return fbxCopy( pDst,pDstType,*(fbxDouble1 *)pSrc );
00235             case eDOUBLE3:  return fbxCopy( pDst,pDstType,*(fbxDouble3 *)pSrc );
00236             case eDOUBLE4:  return fbxCopy( pDst,pDstType,*(fbxDouble4 *)pSrc );
00237             case eDOUBLE44: return fbxCopy( pDst,pDstType,*(fbxDouble44 *)pSrc );
00238             case eENUM:     return fbxCopy( pDst,pDstType,*(fbxEnum *)pSrc );
00239             case eSTRING:   return fbxCopy( pDst,pDstType,*(fbxString *)pSrc);
00240             case eTIME:     return fbxCopy( pDst,pDstType,*(fbxTime*)pSrc);
00241             case eREFERENCE:        
00242                 K_ASSERT_MSG_NOW("Trying to set value on a void Reference type" );
00243             break;
00244             case eDATASTREAM:   return fbxCopy( pDst,pDstType,*(fbxDataStream*)pSrc);
00245             default:
00246                 K_ASSERT_MSG_NOW("Trying to assign an unknown type" );
00247         }
00248         return false;
00249     }
00250 
00251     class KFBX_DLL KFbxDataType {
00252         public:
00253             KFbxDataType();
00254             KFbxDataType( KFbxDataType const &pDataType );
00255             ~KFbxDataType();
00256         private:
00257             KFbxDataType(char *pName,EFbxType pType);
00258         public:
00259             inline KFbxDataType& operator = (const KFbxDataType &pDataType) { mData=pDataType.mData; return *this; }
00260             inline bool operator == (const KFbxDataType& pDataType) const   { return mData==pDataType.mData;    }
00261             inline bool operator != (const KFbxDataType& pDataType) const   { return mData!=pDataType.mData;    }
00262 
00263         public:
00264             inline bool     Valid() const { return mData ? true : false; } 
00265             EFbxType        GetType() const;
00266             char*           GetName() const;
00267             inline bool     Is(const KFbxDataType& pDataType) const { return mData==pDataType.mData; }
00268             
00269         private:
00270             KFbxTypeInfo_internal   *mData;
00271 
00272         friend class KFbxSdkManager;
00273     };
00274 
00275     // Default Basic Types
00276     extern KFbxDataType DTNone;         
00277     extern KFbxDataType DTBool;         
00278     extern KFbxDataType DTInteger;      
00279     extern KFbxDataType DTFloat;
00280     extern KFbxDataType DTDouble;
00281     extern KFbxDataType DTDouble3;
00282     extern KFbxDataType DTDouble4;
00283     extern KFbxDataType DTDouble44;
00284     extern KFbxDataType DTEnum;
00285     extern KFbxDataType DTStringList;   // ?
00286     extern KFbxDataType DTString;
00287     extern KFbxDataType DTCharPtr;      // ?
00288     extern KFbxDataType DTTime;         
00289     extern KFbxDataType DTReference;
00290     extern KFbxDataType DTDataStream;
00291 
00292     // MB Specific datatypes
00293     extern KFbxDataType DTAction;
00294     extern KFbxDataType DTEvent;
00295 
00296     // Specialised reference Properties
00297     extern KFbxDataType DTReferenceObject;
00298     extern KFbxDataType DTReferenceProperty;
00299 
00300     // Extended sub types 
00301     extern KFbxDataType DTColor3;
00302     extern KFbxDataType DTColor4;
00303 
00304     // Support for older datatypes
00305     extern KFbxDataType DTReal; 
00306     extern KFbxDataType DTVector3D; 
00307     extern KFbxDataType DTVector4D; 
00308 
00309     // Tranforms Types
00310     extern KFbxDataType DTTranslation;      
00311     extern KFbxDataType DTRotation;         
00312     extern KFbxDataType DTScaling;          
00313     extern KFbxDataType DTQuaternion;       
00314 
00315     extern KFbxDataType DTLocalTranslation; 
00316     extern KFbxDataType DTLocalRotation;    
00317     extern KFbxDataType DTLocalScaling;     
00318     extern KFbxDataType DTLocalQuaternion;  
00319 
00320     extern KFbxDataType DTTransformMatrix;  
00321     extern KFbxDataType DTTranslationMatrix;    
00322     extern KFbxDataType DTRotationMatrix;   
00323     extern KFbxDataType DTScalingMatrix;        
00324 
00325 // Material-related types
00326 extern KFbxDataType DTMaterialEmissive;
00327 extern KFbxDataType DTMaterialEmissiveFactor;
00328 extern KFbxDataType DTMaterialAmbient;
00329 extern KFbxDataType DTMaterialAmbientFactor;
00330 extern KFbxDataType DTMaterialDiffuse;
00331 extern KFbxDataType DTMaterialDiffuseFactor;
00332 extern KFbxDataType DTMaterialBump;
00333 extern KFbxDataType DTMaterialNormalMap;
00334 extern KFbxDataType DTMaterialTransparentColor;
00335 extern KFbxDataType DTMaterialTransparencyFactor;
00336 extern KFbxDataType DTMaterialSpecular;
00337 extern KFbxDataType DTMaterialSpecularFactor;
00338 extern KFbxDataType DTMaterialShininess;
00339 extern KFbxDataType DTMaterialReflection;
00340 extern KFbxDataType DTMaterialReflectionFactor;
00341 
00342     // Motipn Builder Specialised Types
00343     extern KFbxDataType DTIntensity;            
00344     extern KFbxDataType DTConeAngle;            
00345     extern KFbxDataType DTFog;              
00346     extern KFbxDataType DTShape;        
00347     extern KFbxDataType DTFieldOfView;      
00348     extern KFbxDataType DTFieldOfViewX;     
00349     extern KFbxDataType DTFieldOfViewY;     
00350     extern KFbxDataType DTOpticalCenterX;   
00351     extern KFbxDataType DTOpticalCenterY;   
00352 
00353     extern KFbxDataType DTRoll;             
00354     extern KFbxDataType DTCameraIndex;      
00355     extern KFbxDataType DTTimeWarp;         
00356     extern KFbxDataType DTVisibility;       
00357 
00358     extern KFbxDataType DTTranslationUV;        
00359     extern KFbxDataType DTScalingUV;            
00360     extern KFbxDataType DTHSB;              
00361 
00362     extern KFbxDataType DTOrientation;      
00363     extern KFbxDataType DTLookAt;           
00364 
00365     extern KFbxDataType DTOcclusion;
00366     extern KFbxDataType DTWeight;
00367 
00368     extern KFbxDataType DTIKReachTranslation;
00369     extern KFbxDataType DTIKReachRotation;  
00370 
00371     KFbxDataType const & GetFbxDataType(EFbxType pType);
00372 
00373     // Internal use
00374     bool                KFbxTypesInit   (KFbxSdkManager *pManager);
00375     void                KFbxTypesRelease(KFbxSdkManager *pManager);
00376 
00377     char*               FbxDataTypeToFormatPropertyType( KFbxDataType const &pDataType );
00378     KFbxDataType const &FormatPropertyTypeToFbxDataType( char *pDataTypeName );
00379 
00380 
00381 
00382 #include <fbxfilesdk_nsend.h>
00383 
00384 #endif // _KFbxTypes_h
00385 
00386