- Main Page
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# fbxlayer.h

Go to the documentation of this file.

    00001 /****************************************************************************************
    00002
    00003    Copyright (C) 2012 Autodesk, Inc.
    00004    All rights reserved.
    00005
    00006    Use of this software is subject to the terms of the Autodesk license agreement
    00007    provided at the time of installation or download, or which otherwise accompanies
    00008    this software in either electronic or hard copy form.
    00009
    00010 ****************************************************************************************/
    00011
    00013 #ifndef _FBXSDK_SCENE_GEOMETRY_LAYER_H_
    00014 #define _FBXSDK_SCENE_GEOMETRY_LAYER_H_
    00015
    00016 #include <fbxsdk/fbxsdk_def.h>
    00017
    00018 #include <fbxsdk/core/base/fbxstring.h>
    00019 #include <fbxsdk/core/base/fbxarray.h>
    00020 #include <fbxsdk/core/fbxdatatypes.h>
    00021 #include <fbxsdk/core/fbxstream.h>
    00022 #include <fbxsdk/core/fbxpropertytypes.h>
    00023
    00024 #include <fbxsdk/core/math/fbxvector2.h>
    00025 #include <fbxsdk/core/math/fbxvector4.h>
    00026
    00027 #include <fbxsdk/scene/shading/fbxsurfacematerial.h>
    00028 #include <fbxsdk/scene/shading/fbxtexture.h>
    00029
    00030 #include <fbxsdk/fbxsdk_nsbegin.h>
    00031
    00032 class FbxTexture;
    00033 class FbxSurfaceMaterial;
    00034 class FbxManager;
    00035 class FbxGeometryBase;
    00036 class FbxLayer;
    00037 class FbxLayerContainer;
    00038 class FbxMesh;
    00039 class FbxNode;
    00040 class FbxLayerElementArray;
    00041
    00052 class FBXSDK_DLL FbxLayerElement
    00053 {
    00054 public:
    00089     enum EType
    00090     {
    00091         eUnknown,
    00092
    00093         //Non-Texture layer element types
    00094         //Note: Make sure to update static index below if you change this enum!
    00095         eNormal,
    00096         eBiNormal,
    00097         eTangent,
    00098         eMaterial,
    00099         ePolygonGroup,
    00100         eUV,
    00101         eVertexColor,
    00102         eSmoothing,
    00103         eVertexCrease,
    00104         eEdgeCrease,
    00105         eHole,
    00106         eUserData,
    00107         eVisibility,
    00108
    00109         //Texture layer element types
    00110         //Note: Make sure to update static index below if you change this enum!
    00111         eTextureDiffuse,
    00112         eTextureDiffuseFactor,
    00113         eTextureEmissive,
    00114         eTextureEmissiveFactor,
    00115         eTextureAmbient,
    00116         eTextureAmbientFactor,
    00117         eTextureSpecular,
    00118         eTextureSpecularFactor,
    00119         eTextureShininess,
    00120         eTextureNormalMap,
    00121         eTextureBump,
    00122         eTextureTransparency,
    00123         eTextureTransparencyFactor,
    00124         eTextureReflection,
    00125         eTextureReflectionFactor,
    00126         eTextureDisplacement,
    00127         eTextureDisplacementVector,
    00128
    00129         eTypeCount
    00130     };
    00131
    00132     const static int sTypeTextureStartIndex = int(eTextureDiffuse);
    00133     const static int sTypeTextureEndIndex = int(eTypeCount) - 1;
    00134     const static int sTypeTextureCount = sTypeTextureEndIndex - sTypeTextureStartIndex + 1;
    00135     const static int sTypeNonTextureStartIndex = int(eNormal);
    00136     const static int sTypeNonTextureEndIndex = int(eVisibility);
    00137     const static int sTypeNonTextureCount = sTypeNonTextureEndIndex - sTypeNonTextureStartIndex + 1;
    00138     static const char* const sTextureNames[];
    00139     static const char* const sTextureUVNames[];
    00140     static const char* const sNonTextureNames[];
    00141     static const FbxDataType sTextureDataTypes[];
    00142     static const char* const sTextureChannelNames[];
    00143
    00154     enum EMappingMode
    00155     {
    00156         eNone,
    00157         eByControlPoint,
    00158         eByPolygonVertex,
    00159         eByPolygon,
    00160         eByEdge,
    00161         eAllSame
    00162     };
    00163
    00177     enum EReferenceMode
    00178     {
    00179         eDirect,
    00180         eIndex,
    00181         eIndexToDirect
    00182     };
    00183
    00184
    00188     void SetMappingMode(EMappingMode pMappingMode) { mMappingMode = pMappingMode; }
    00189
    00193     void SetReferenceMode(EReferenceMode pReferenceMode) { mReferenceMode = pReferenceMode; }
    00194
    00198     EMappingMode GetMappingMode() const { return mMappingMode; }
    00199
    00203     EReferenceMode GetReferenceMode() const { return mReferenceMode; }
    00204
    00208     void SetName(const char* pName) { mName = FbxString(pName); }
    00209
    00213     const char* GetName() const { return ((FbxLayerElement*)this)->mName.Buffer(); }
    00214
    00219     bool operator==(const FbxLayerElement& pOther) const
    00220     {
    00221         return (mName == pOther.mName) &&
    00222                (mMappingMode == pOther.mMappingMode) &&
    00223                (mReferenceMode == pOther.mReferenceMode);
    00224     }
    00225
    00230     FbxLayerElement& operator=( FbxLayerElement const& pOther )
    00231     {
    00232         mMappingMode = pOther.mMappingMode;
    00233         mReferenceMode = pOther.mReferenceMode;
    00234         // name, type and owner should not be copied because they are
    00235         // initialized when this object is created
    00236         return *this;
    00237     }
    00238
    00240     void Destroy();
    00241
    00243     virtual bool Clear()
    00244     {
    00245         return true;
    00246     }
    00247
    00249 //
    00250 //  WARNING!
    00251 //
    00252 //  Anything beyond these lines may not be documented accurately and is
    00253 //  subject to change without notice.
    00254 //
    00256
    00257 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00258     void SetType(const FbxDataType* pType) { mType = pType; }
    00259     const FbxLayerContainer* GetOwner() const { return mOwner; }
    00260
    00261 protected:
    00262     FbxLayerElement()
    00263         : mMappingMode(eNone)
    00264         , mReferenceMode(eDirect)
    00265         , mName("")
    00266         , mOwner(NULL)
    00267     {
    00268     }
    00269
    00270     virtual ~FbxLayerElement()
    00271     {
    00272     }
    00273
    00274     EMappingMode mMappingMode;
    00275     EReferenceMode mReferenceMode;
    00276
    00277     FbxString mName;
    00278     const FbxDataType* mType;
    00279     FbxLayerContainer* mOwner;
    00280
    00281     void Destruct() { FbxDelete(this); }
    00282     virtual void SetOwner(FbxLayerContainer* pOwner);
    00283
    00284     FBXSDK_FRIEND_NEW();
    00285     friend class FbxLayerContainer;
    00286
    00287 public:
    00292     virtual int MemorySize() const { return 0; }
    00293
    00298
    00304     virtual bool ContentWriteTo(FbxStream& pStream) const;
    00305
    00311     virtual bool ContentReadFrom(const FbxStream& pStream);
    00313
    00314 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00315 };
    00316
    00322 class FBXSDK_DLL LockAccessStatus
    00323 {
    00324 public:
    00337     enum ELockAccessStatus
    00338     {
    00339         eSuccess,
    00340         eUnsupportedDTConversion,
    00341         eCorruptedCopyback,
    00342         eBadValue,
    00343         eLockMismatch,
    00344         eNoWriteLock,
    00345         eNoReadLock,
    00346         eNotOwner,
    00347         eDirectLockExist
    00348     };
    00349 };
    00350
    00351 //Special conversion types, we do not want them to resolve to undefined.
    00352 typedef FbxHandle* FbxRefPtr;
    00353 typedef FbxLayerElementArray* FbxLayerElementArrayPtr;
    00354 typedef FbxSurfaceMaterial* FbxSurfaceMaterialPtr;
    00355 typedef FbxTexture* FbxTexturePtr;
    00356
    00357 inline EFbxType FbxTypeOf(const FbxRefPtr&){ return eFbxReference; }
    00358 inline EFbxType FbxTypeOf(const FbxLayerElementArrayPtr&){ return eFbxReference; }
    00359 inline EFbxType FbxTypeOf(const FbxSurfaceMaterialPtr&){ return eFbxReference; }
    00360 inline EFbxType FbxTypeOf(const FbxTexturePtr&){ return eFbxReference; }
    00361
    00367 class FBXSDK_DLL FbxLayerElementArray
    00368 {
    00369 public:
    00374
    00378     FbxLayerElementArray(EFbxType pDataType);
    00379
    00381     virtual ~FbxLayerElementArray();
    00382
    00384
    00389
    00391     inline                                void ClearStatus()     { mStatus = LockAccessStatus::eSuccess; }
    00392
    00394     inline LockAccessStatus::ELockAccessStatus GetStatus() const { return mStatus; }
    00396
    00401
    00405     inline bool IsWriteLocked() const { return mWriteLock; };
    00406
    00410     inline int  GetReadLockCount() const { return mReadLockCount; }
    00412
    00416     bool    IsInUse() const;
    00417
    00421     int     ReadLock() const;
    00422
    00426     int     ReadUnlock() const;
    00427
    00432     bool    WriteLock() const;
    00433
    00436     void    WriteUnlock() const;
    00437
    00442     bool    ReadWriteLock() const;
    00443
    00446     void    ReadWriteUnlock() const;
    00447
    00448
    00454     enum ELockMode
    00455     {
    00456         eReadLock = 1,
    00457         eWriteLock = 2,
    00458         eReadWriteLock = 3
    00459     };
    00460
    00473     virtual void*   GetLocked(ELockMode pLockMode, EFbxType pDataType);
    00474
    00486     void*   GetLocked(ELockMode pLockMode=eReadWriteLock) { return GetLocked(pLockMode, mDataType); }
    00487
    00499     template <class T> inline T* GetLocked(T*, ELockMode pLockMode=eReadWriteLock) {T v; return (T*)GetLocked(pLockMode, FbxTypeOf(v)); }
    00500
    00511     virtual void   Release(void** pDataPtr, EFbxType pDataType);
    00512
    00522     void   Release(void** pDataPtr) { Release(pDataPtr, mDataType); }
    00523
    00534     template <class T> inline void Release(T** pDataPtr, T* dummy) { Release((void**)pDataPtr, FbxTypeOf(*dummy)); }
    00535
    00538     virtual size_t GetStride() const;
    00539
    00544
    00546     int     GetCount() const;
    00547
    00551     void    SetCount(int pCount);
    00552
    00554     void    Clear();
    00555
    00559     void    Resize(int pItemCount);
    00560
    00564     void    AddMultiple(int pItemCount);
    00565
    00571     int     Add(void const* pItem, EFbxType pValueType);
    00572
    00580     int     InsertAt(int pIndex, void const* pItem, EFbxType pValueType);
    00581
    00588     void    SetAt(int pIndex, void const* pItem, EFbxType pValueType);
    00589
    00595     void    SetLast(void const* pItem, EFbxType pValueType);
    00596
    00603     void    RemoveAt(int pIndex, void** pItem, EFbxType pValueType);
    00604
    00610     void    RemoveLast(void** pItem, EFbxType pValueType);
    00611
    00617     bool    RemoveIt(void** pItem, EFbxType pValueType);
    00618
    00626     bool    GetAt(int pIndex, void** pItem, EFbxType pValueType) const;
    00627
    00633     bool    GetFirst(void** pItem, EFbxType pValueType) const;
    00634
    00640     bool    GetLast(void** pItem, EFbxType pValueType) const;
    00641
    00648     int     Find(void const* pItem, EFbxType pValueType) const;
    00649
    00657     int     FindAfter(int pAfterIndex, void const* pItem, EFbxType pValueType) const;
    00658
    00666     int     FindBefore(int pBeforeIndex, void const* pItem, EFbxType pValueType) const;
    00667
    00672     bool    IsEqual(const FbxLayerElementArray& pArray) const;
    00673
    00678     template <class T> inline int  Add(T const& pItem)                               { return Add((void const*)&pItem, FbxTypeOf(pItem)); }
    00679
    00686     template <class T> inline int  InsertAt(int pIndex, T const& pItem)              { return InsertAt(pIndex, (void const*)&pItem, FbxTypeOf(pItem)); }
    00687
    00693     template <class T> inline void SetAt(int pIndex, T const& pItem)                 { SetAt(pIndex, (void const*)&pItem, FbxTypeOf(pItem)); }
    00694
    00699     template <class T> inline void SetLast(T const& pItem)                           { SetLast((void const*)&pItem, FbxTypeOf(pItem)); }
    00700
    00706     template <class T> inline void RemoveAt(int pIndex, T* pItem)                    { RemoveAt(pIndex, (void**)&pItem, FbxTypeOf(*pItem)); }
    00707
    00712     template <class T> inline void RemoveLast(T* pItem)                              { RemoveLast((void**)&pItem, FbxTypeOf(*pItem)); }
    00713
    00718     template <class T> inline bool RemoveIt(T* pItem)                                { return RemoveIt((void**)&pItem, FbxTypeOf(*pItem)); }
    00719
    00726     template <class T> inline bool GetAt(int pIndex, T* pItem) const                 { return GetAt(pIndex, (void**)&pItem, FbxTypeOf(*pItem)); }
    00727
    00732     template <class T> inline bool GetFirst(T* pItem) const                          { return GetFirst((void**)&pItem, FbxTypeOf(*pItem)); }
    00733
    00738     template <class T> inline bool GetLast(T* pItem) const                           { return GetLast((void**)&pItem, FbxTypeOf(*pItem)); }
    00739
    00745     template <class T> inline int Find(T const& pItem) const                         { return Find((void const*)&pItem, FbxTypeOf(pItem)); }
    00746
    00753     template <class T> inline int FindAfter(int pAfterIndex, T const& pItem) const   { return FindAfter(pAfterIndex, (void const*)&pItem, FbxTypeOf(pItem)); }
    00754
    00761     template <class T> inline int FindBefore(int pBeforeIndex, T const& pItem) const { return FindBefore(pBeforeIndex, (void const*)&pItem, FbxTypeOf(pItem)); }
    00762
    00763
    00767     template<typename T> inline void CopyTo(FbxArray<T>& pDst)
    00768     {
    00769         T src;
    00770         T* srcPtr = &src;
    00771
    00772         pDst.Clear();
    00773         if (mDataType != FbxTypeOf(src))
    00774         {
    00775             SetStatus(LockAccessStatus::eUnsupportedDTConversion);
    00776             return;
    00777         }
    00778
    00779         pDst.SetCount(GetCount());
    00780         for (int i = 0; i < GetCount(); i++)
    00781         {
    00782             if (GetAt(i, (void**)&srcPtr, mDataType))
    00783             {
    00784                 pDst.SetAt(i, src);
    00785             }
    00786         }
    00787         SetStatus(LockAccessStatus::eSuccess);
    00788     }
    00790
    00791 protected:
    00792     void*   GetDataPtr();
    00793     void*   GetReference(int pIndex, EFbxType pValueType);
    00794     void    GetReferenceTo(int pIndex, void** pRef, EFbxType pValueType);
    00795
    00796     inline void SetStatus(LockAccessStatus::ELockAccessStatus pVal) const
    00797     {
    00798         const_cast<FbxLayerElementArray*>(this)->mStatus = pVal;
    00799     }
    00800
    00801             void   SetImplementation(void* pImplementation);
    00802     inline  void*  GetImplementation() { return mImplementation; }
    00803     virtual void   ConvertDataType(EFbxType pDataType, void** pDataPtr, size_t* pStride);
    00804
    00805     EFbxType mDataType;
    00806
    00807 private:
    00808     LockAccessStatus::ELockAccessStatus mStatus;
    00809
    00810     int           mReadLockCount;
    00811     bool          mWriteLock;
    00812     void*         mImplementation;
    00813     size_t        mStride;
    00814     int           mDirectLockOn;
    00815     bool          mDirectAccessOn;
    00816
    00817     FbxArray<void*> mConvertedData;
    00818
    00819 };
    00820
    00824 template <typename T>
    00825 struct FbxLayerElementArrayReadLock
    00826 {
    00830     FbxLayerElementArrayReadLock(FbxLayerElementArray& pArray) : mArray(pArray)
    00831     {
    00832         mLockedData = mArray.GetLocked((T*)NULL, FbxLayerElementArray::eReadLock);
    00833     }
    00834
    00838     ~FbxLayerElementArrayReadLock()
    00839     {
    00840         if( mLockedData )
    00841         {
    00842             mArray.Release((void **) &mLockedData);
    00843         }
    00844     }
    00845
    00849     const T* GetData() const
    00850     {
    00851         return mLockedData;
    00852     }
    00853
    00854 private:
    00855     FbxLayerElementArray&  mArray;
    00856     T* mLockedData;
    00857 };
    00858
    00859 class FbxLayerElementUserData;
    00860
    00865 template <class T> class FbxLayerElementArrayTemplate : public FbxLayerElementArray
    00866 {
    00867 public:
    00868
    00872     FbxLayerElementArrayTemplate(EFbxType pDataType) :
    00873         FbxLayerElementArray(pDataType)
    00874         {
    00875         }
    00876
    00881     inline int  Add( T const &pItem )                       { return FbxLayerElementArray::Add(pItem); }
    00882
    00888     inline int  InsertAt(int pIndex, T const &pItem)        { return FbxLayerElementArray::InsertAt(pIndex, pItem); }
    00889
    00894     inline void SetAt(int pIndex, T const &pItem)           { FbxLayerElementArray::SetAt(pIndex, pItem); }
    00895
    00899     inline void SetLast( T const &pItem)                    { FbxLayerElementArray::SetLast(pItem); }
    00900
    00905     inline T RemoveAt(int pIndex)                           { T lValue; FbxLayerElementArray::RemoveAt(pIndex, &lValue); return lValue; }
    00906
    00910     inline T RemoveLast()                                   { T lValue; FbxLayerElementArray::RemoveLast(&lValue); return lValue; }
    00911
    00916     inline bool RemoveIt(T const &pItem)                    { return FbxLayerElementArray::RemoveIt(&pItem); }
    00917
    00923     inline T  GetAt(int pIndex) const                       { T lValue; FbxLayerElementArray::GetAt(pIndex, &lValue); return lValue; }
    00924
    00928     inline T  GetFirst() const                              { T lValue; FbxLayerElementArray::GetFirst(&lValue); return lValue; }
    00929
    00933     inline T  GetLast() const                               { T lValue; FbxLayerElementArray::GetLast(&lValue); return lValue; }
    00934
    00940     inline int Find(T const &pItem)                         { return FbxLayerElementArray::Find(pItem); }
    00941
    00948     inline int FindAfter(int pAfterIndex, T const &pItem)   { return FbxLayerElementArray::FindAfter(pAfterIndex, pItem); }
    00949
    00956     inline int FindBefore(int pBeforeIndex, T const &pItem) { return FbxLayerElementArray::FindBefore(pBeforeIndex, pItem); }
    00957
    00963     T  operator[](int pIndex) const                         { T lValue; FbxLayerElementArray::GetAt(pIndex, &lValue); return lValue; }
    00964
    00968     FbxLayerElementArray& operator=(const FbxArray<T>& pArrayTemplate)
    00969     {
    00970         SetStatus(LockAccessStatus::eNoWriteLock);
    00971         if (WriteLock())
    00972         {
    00973             SetCount(pArrayTemplate.GetCount());
    00974             for (int i = 0; i < pArrayTemplate.GetCount(); i++)
    00975                 SetAt(i, pArrayTemplate.GetAt(i));
    00976             WriteUnlock();
    00977             SetStatus(LockAccessStatus::eSuccess);
    00978         }
    00979         return *this;
    00980     }
    00981
    00985     FbxLayerElementArrayTemplate<T>& operator=(const FbxLayerElementArrayTemplate<T>& pArrayTemplate)
    00986     {
    00987         if ( this != &pArrayTemplate )
    00988         {
    00989             SetStatus(LockAccessStatus::eNoWriteLock);
    00990             if (WriteLock())
    00991             {
    00992                 SetCount(pArrayTemplate.GetCount());
    00993                 for (int i = 0; i < pArrayTemplate.GetCount(); i++)
    00994                     SetAt(i, pArrayTemplate.GetAt(i));
    00995                 WriteUnlock();
    00996                 SetStatus(LockAccessStatus::eSuccess);
    00997             }
    00998         }
    00999         return *this;
    01000     }
    01001
    01002 private:
    01003     // This one is not the best thing to do, but at least I don't get deprecated calls inside this file.
    01004     // Note that FbxLayerElementUserData is kind of a weird class in the first place anyway. So either
    01005     // we clean it up, or we live with this piece of code ;-)
    01006     friend class FbxLayerElementUserData;
    01007     T& AsReference(int pIndex)      { T* v = (T*)FbxLayerElementArray::GetReference(pIndex, mDataType); return (v)?*v:dummy;}
    01008
    01009     T dummy;
    01010 };
    01011
    01012
    01020 extern int RemapIndexArrayTo(FbxLayerElement* pLayerEl,
    01021                              FbxLayerElement::EMappingMode pNewMapping,
    01022                              FbxLayerElementArrayTemplate<int>* pIndexArray);
    01023
    01024
    01029 template <class Type> class FbxLayerElementTemplate : public FbxLayerElement
    01030 {
    01031 public:
    01032
    01037     FbxLayerElementArrayTemplate<Type>& GetDirectArray() const
    01038     {
    01039         FBX_ASSERT(mReferenceMode == FbxLayerElement::eDirect || mReferenceMode == FbxLayerElement::eIndexToDirect);
    01040         return *mDirectArray;
    01041     }
    01042
    01047     FbxLayerElementArrayTemplate<Type>& GetDirectArray()
    01048     {
    01049         FBX_ASSERT(mReferenceMode == FbxLayerElement::eDirect || mReferenceMode == FbxLayerElement::eIndexToDirect);
    01050         return *mDirectArray;
    01051     }
    01052
    01057     FbxLayerElementArrayTemplate<int>& GetIndexArray() const
    01058     {
    01059         FBX_ASSERT(mReferenceMode == FbxLayerElement::eIndex || mReferenceMode == FbxLayerElement::eIndexToDirect);
    01060         return *mIndexArray;
    01061     }
    01062
    01067     FbxLayerElementArrayTemplate<int>& GetIndexArray()
    01068     {
    01069         FBX_ASSERT(mReferenceMode == FbxLayerElement::eIndex || mReferenceMode == FbxLayerElement::eIndexToDirect);
    01070         return *mIndexArray;
    01071     }
    01072
    01077     bool Clear()
    01078     {
    01079         bool ret = true;
    01080         mDirectArray->Clear();
    01081         ret = (mDirectArray->GetStatus() == LockAccessStatus::eSuccess);
    01082
    01083         mIndexArray->Clear();
    01084         ret |= (mIndexArray->GetStatus() == LockAccessStatus::eSuccess);
    01085
    01086         return ret;
    01087     }
    01088
    01089 public:
    01090
    01095     bool operator==(const FbxLayerElementTemplate& pOther) const
    01096     {
    01097         bool ret = true;
    01098
    01099         if (pOther.GetReferenceMode() == FbxLayerElement::eDirect ||
    01100             pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
    01101         {
    01102             const FbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
    01103             if( directArray.GetCount() != mDirectArray->GetCount() ||
    01104                 !directArray.ReadLock() || !mDirectArray->ReadLock() )
    01105             {
    01106                 ret = false;
    01107             }
    01108
    01109             if( ret && !mDirectArray->IsEqual(directArray) )
    01110                 ret = false;
    01111
    01112             directArray.ReadUnlock();
    01113             mDirectArray->ReadUnlock();
    01114         }
    01115
    01116         if (ret)
    01117         {
    01118             if (pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
    01119                 pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect)
    01120             {
    01121                 const FbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
    01122                 if( indexArray.GetCount() != mIndexArray->GetCount() ||
    01123                     !indexArray.ReadLock() || !mIndexArray->ReadLock() )
    01124                 {
    01125                     ret = false;
    01126                 }
    01127
    01128                 if( ret && !mIndexArray->IsEqual(indexArray) )
    01129                     ret = false;
    01130
    01131                 indexArray.ReadUnlock();
    01132                 mIndexArray->ReadUnlock();
    01133             }
    01134         }
    01135
    01136         if (ret == false)
    01137             return false;
    01138
    01139         return FbxLayerElement::operator==(pOther);
    01140     }
    01141
    01145     FbxLayerElementTemplate& operator=( FbxLayerElementTemplate const& pOther )
    01146     {
    01147         FBX_ASSERT(mDirectArray != NULL);
    01148         FBX_ASSERT(mIndexArray != NULL);
    01149
    01150         if (pOther.GetReferenceMode() == FbxLayerElement::eDirect ||
    01151             pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
    01152         {
    01153             const FbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
    01154             *mDirectArray = directArray;
    01155         }
    01156
    01157         if (pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
    01158             pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect)
    01159         {
    01160             const FbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
    01161             *mIndexArray = indexArray;
    01162         }
    01163
    01164         FbxLayerElement* myself = (FbxLayerElement*)this;
    01165         FbxLayerElement* myOther = (FbxLayerElement*)&pOther;
    01166         *myself = *myOther;
    01167         return *this;
    01168     }
    01169
    01177     int RemapIndexTo(FbxLayerElement::EMappingMode pNewMapping)
    01178     {
    01179         return RemapIndexArrayTo(this, pNewMapping, mIndexArray);
    01180     }
    01181
    01183 //
    01184 //  WARNING!
    01185 //
    01186 //  Anything beyond these lines may not be documented accurately and is
    01187 //  subject to change without notice.
    01188 //
    01190
    01191 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    01192 protected:
    01193     FbxLayerElementTemplate()
    01194     {
    01195         mDirectArray = NULL;
    01196         mIndexArray = NULL;
    01197     }
    01198
    01199     ~FbxLayerElementTemplate()
    01200     {
    01201         FbxDelete(mDirectArray);
    01202         FbxDelete(mIndexArray);
    01203     }
    01204
    01205     virtual void AllocateArrays()
    01206     {
    01207         mDirectArray = FbxNew< FbxLayerElementArrayTemplate<Type> >(mType->GetType());
    01208         mIndexArray = FbxNew< FbxLayerElementArrayTemplate<int> >(FbxIntDT.GetType());
    01209     }
    01210
    01211 public:
    01212     virtual int MemorySize() const
    01213     {
    01214         int size = FbxLayerElement::MemorySize();
    01215         size += (mDirectArray->GetCount()*sizeof(Type));
    01216         size += (mIndexArray->GetCount()*sizeof(int));
    01217         return size;
    01218     }
    01219
    01224     virtual bool ContentWriteTo(FbxStream& pStream) const
    01225     {
    01226         void* a;
    01227         int s,v;
    01228         int count = 0;
    01229
    01230         // direct array
    01231         count = mDirectArray->GetCount();
    01232         s = pStream.Write(&count, sizeof(int));
    01233         if (s != sizeof(int)) return false;
    01234         if (count > 0)
    01235         {
    01236             a = mDirectArray->GetLocked();
    01237             FBX_ASSERT(a != NULL);
    01238             v = count*sizeof(Type);
    01239             s = pStream.Write(a, v);
    01240             mDirectArray->Release(&a);
    01241             if (s != v) return false;
    01242         }
    01243
    01244         // index array
    01245         count = mIndexArray->GetCount();
    01246         s = pStream.Write(&count, sizeof(int));
    01247         if (s != sizeof(int)) return false;
    01248         if (count > 0)
    01249         {
    01250             a = mIndexArray->GetLocked();
    01251             FBX_ASSERT(a != NULL);
    01252             v = count*sizeof(int);
    01253             s = pStream.Write(a, v);
    01254             mIndexArray->Release(&a);
    01255             if (s != v) return false;
    01256         }
    01257
    01258         return FbxLayerElement::ContentWriteTo(pStream);
    01259     }
    01260
    01261     virtual bool ContentReadFrom(const FbxStream& pStream)
    01262     {
    01263         void* a;
    01264         int s,v;
    01265         int count = 0;
    01266
    01267         // direct array
    01268         s = pStream.Read(&count, sizeof(int));
    01269         if (s != sizeof(int)) return false;
    01270         mDirectArray->Resize(count);
    01271         if (count > 0)
    01272         {
    01273             a = mDirectArray->GetLocked();
    01274             FBX_ASSERT(a != NULL);
    01275             v = count*sizeof(Type);
    01276             s = pStream.Read(a, v);
    01277             mDirectArray->Release(&a);
    01278             if (s != v) return false;
    01279         }
    01280
    01281         // index array
    01282         s = pStream.Read(&count, sizeof(int));
    01283         if (s != sizeof(int)) return false;
    01284         mIndexArray->Resize(count);
    01285         if (count > 0)
    01286         {
    01287             a = mIndexArray->GetLocked();
    01288             FBX_ASSERT(a != NULL);
    01289             v = count*sizeof(int);
    01290             s = pStream.Read(a, v);
    01291             mIndexArray->Release(&a);
    01292             if (s != v) return false;
    01293         }
    01294         return FbxLayerElement::ContentReadFrom(pStream);
    01295     }
    01297
    01298     typedef Type ArrayElementType;
    01299     typedef FbxLayerElementArrayTemplate<Type> DirectArrayType;
    01300     typedef FbxLayerElementArrayTemplate<int> IndexArrayType;
    01301
    01302     FbxLayerElementArrayTemplate<Type>* mDirectArray;
    01303     FbxLayerElementArrayTemplate<int>*  mIndexArray;
    01304 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    01305 };
    01306
    01307 #define FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(classDesc) \
    01308     FBXSDK_FRIEND_NEW();        \
    01309     static Fbx##classDesc* Create(FbxLayerContainer* pOwner, char const *pName);
    01310
    01316 class FBXSDK_DLL FbxLayerElementNormal : public FbxLayerElementTemplate<FbxVector4>
    01317 {
    01318 public:
    01319
    01323     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementNormal);
    01324
    01325 protected:
    01326     FbxLayerElementNormal();
    01327     ~FbxLayerElementNormal();
    01328 };
    01329
    01333 class FBXSDK_DLL FbxLayerElementBinormal : public FbxLayerElementTemplate<FbxVector4>
    01334 {
    01335 public:
    01336
    01340     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementBinormal);
    01341
    01342 protected:
    01343     FbxLayerElementBinormal();
    01344     ~FbxLayerElementBinormal();
    01345 };
    01346
    01350 class FBXSDK_DLL FbxLayerElementTangent : public FbxLayerElementTemplate<FbxVector4>
    01351 {
    01352 public:
    01353
    01357     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementTangent);
    01358
    01359 protected:
    01360     FbxLayerElementTangent();
    01361     ~FbxLayerElementTangent();
    01362 };
    01363
    01407 class FBXSDK_DLL FbxLayerElementMaterial : public FbxLayerElementTemplate<FbxSurfaceMaterial*>
    01408 {
    01409 public:
    01410     typedef FbxLayerElementTemplate<FbxSurfaceMaterial*> ParentClass;
    01411
    01415     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementMaterial);
    01416
    01422     class LayerElementArrayProxy : public FbxLayerElementArrayTemplate<FbxSurfaceMaterial*>
    01423     {
    01424     public:
    01425         typedef FbxLayerElementArrayTemplate<FbxSurfaceMaterial*> ParentClass;
    01426
    01427         LayerElementArrayProxy(EFbxType pType);
    01428         void SetContainer( FbxLayerContainer* pContainer, int pInstance = 0);
    01429     };
    01430
    01432 //
    01433 //  WARNING!
    01434 //
    01435 //  Anything beyond these lines may not be documented accurately and is
    01436 //  subject to change without notice.
    01437 //
    01439 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    01440
    01441     virtual void AllocateArrays();
    01442     virtual void SetOwner( FbxLayerContainer* pOwner, int pInstance = 0);
    01443     virtual void SetInstance( int pInstance ) { SetOwner( mOwner, pInstance ); }
    01444
    01445 protected:
    01446     FbxLayerElementMaterial();
    01447     ~FbxLayerElementMaterial();
    01448
    01449 private:
    01450     FbxLayerElementArrayTemplate<FbxSurfaceMaterial*>& GetDirectArray() const
    01451     {
    01452         return ParentClass::GetDirectArray();
    01453     }
    01454
    01455     FbxLayerElementArrayTemplate<FbxSurfaceMaterial*>& GetDirectArray()
    01456     {
    01457         return ParentClass::GetDirectArray();
    01458     }
    01459
    01460     friend class FbxLayerContainer;
    01461
    01462 #endif //DOXYGEN_SHOULD_SKIP_THIS
    01463 };
    01464
    01470 class FBXSDK_DLL FbxLayerElementPolygonGroup : public FbxLayerElementTemplate<int>
    01471 {
    01472 public:
    01473
    01477     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementPolygonGroup);
    01478
    01479 protected:
    01480     FbxLayerElementPolygonGroup();
    01481     ~FbxLayerElementPolygonGroup();
    01482 };
    01483
    01498 class FBXSDK_DLL FbxLayerElementUV : public FbxLayerElementTemplate<FbxVector2>
    01499 {
    01500 public:
    01504     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementUV);
    01505
    01506 protected:
    01507     FbxLayerElementUV();
    01508     ~FbxLayerElementUV();
    01509 };
    01510
    01514 class FBXSDK_DLL FbxLayerElementVertexColor : public FbxLayerElementTemplate<FbxColor>
    01515 {
    01516 public:
    01517
    01521     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementVertexColor);
    01522
    01523 protected:
    01524     FbxLayerElementVertexColor();
    01525     ~FbxLayerElementVertexColor();
    01526 };
    01527
    01528 template <class T> inline FbxLayerElementArrayTemplate<T>&       FbxGetDirectArray(FbxLayerElementUserData       *pLayerElement, int pIndex, bool* pStatus = NULL);
    01529 template <class T> inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, int pIndex, bool* pStatus = NULL);
    01530 template <class T> inline FbxLayerElementArrayTemplate<T>&       FbxGetDirectArray(FbxLayerElementUserData       *pLayerElement, const char* pName, bool* pStatus = NULL );
    01531 template <class T> inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, const char* pName, bool* pStatus = NULL );
    01532
    01538 class FBXSDK_DLL FbxLayerElementUserData : public FbxLayerElementTemplate<void*>
    01539 {
    01540 public:
    01541     FBXSDK_FRIEND_NEW();
    01542
    01552     static FbxLayerElementUserData* Create(FbxLayerContainer* pOwner, char const *pName, int pId, FbxArray<FbxDataType>& pDataTypes, FbxArray<const char*>& pDataNames);
    01553
    01559     static FbxLayerElementUserData* Create(FbxLayerContainer* pOwner, FbxLayerElementUserData const& pOther );
    01560
    01566     FbxLayerElementArrayTemplate<void*>* GetDirectArrayVoid( int pIndex, bool* pStatus = NULL)
    01567     {
    01568         if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
    01569         {
    01570             if (pStatus) *pStatus = true;
    01571             return (FbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
    01572         }
    01573         else
    01574         {
    01575             if( pStatus ) *pStatus = false;
    01576             FBX_ASSERT_NOW("Index out of bounds");
    01577             return (FbxLayerElementArrayTemplate<void*>*)NULL;
    01578         }
    01579     }
    01580
    01586     FbxLayerElementArrayTemplate<void*> const* GetDirectArrayVoid( int pIndex, bool* pStatus = NULL) const
    01587     {
    01588         if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
    01589         {
    01590             if (pStatus) *pStatus = true;
    01591             return (FbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
    01592         }
    01593         else
    01594         {
    01595             if( pStatus ) *pStatus = false;
    01596             FBX_ASSERT_NOW("Index out of bounds");
    01597             return (FbxLayerElementArrayTemplate<void*> const*)NULL;
    01598         }
    01599     }
    01600
    01601
    01607     FbxLayerElementArrayTemplate<void *>* GetDirectArrayVoid ( const char* pName, bool* pStatus = NULL )
    01608     {
    01609         FbxString lName( pName );
    01610         for( int i = 0; i < mDataNames.GetCount(); ++i )
    01611         {
    01612             if( *mDataNames[i] == lName )
    01613                 return GetDirectArrayVoid(i, pStatus);
    01614         }
    01615
    01616         if (pStatus) *pStatus = false;
    01617         return (FbxLayerElementArrayTemplate<void *>*)NULL;
    01618     }
    01619
    01625     FbxLayerElementArrayTemplate<void *> const* GetDirectArrayVoid ( const char* pName, bool* pStatus = NULL ) const
    01626     {
    01627         FbxString lName( pName );
    01628         for( int i = 0; i < mDataNames.GetCount(); ++i )
    01629         {
    01630             if( *mDataNames[i] == lName )
    01631                 return GetDirectArrayVoid(i, pStatus);
    01632         }
    01633
    01634         if (pStatus) *pStatus = false;
    01635         return (FbxLayerElementArrayTemplate<void *> const*)NULL;
    01636     }
    01637
    01642     FbxDataType GetDataType( int pIndex ) const
    01643     {
    01644         if( pIndex < 0 || pIndex >= mDataTypes.GetCount() )
    01645             return FbxUndefinedDT;
    01646
    01647         return mDataTypes[pIndex];
    01648     }
    01649
    01654     FbxDataType GetDataType( const char* pName ) const
    01655     {
    01656         FbxString lName( pName );
    01657
    01658         for( int i = 0; i < mDataNames.GetCount(); ++i )
    01659         {
    01660             if( *mDataNames[i] == lName )
    01661                 return mDataTypes[i];
    01662         }
    01663
    01664         return FbxUndefinedDT;
    01665     }
    01666
    01671     const char* GetDataName( int pIndex ) const
    01672     {
    01673         if( pIndex >= 0 && pIndex < mDataNames.GetCount() )
    01674             return mDataNames[pIndex]->Buffer();
    01675
    01676         return NULL;
    01677     }
    01678
    01682     void ResizeAllDirectArrays( int pSize )
    01683     {
    01684         for( int i = 0; i < GetDirectArray().GetCount(); ++i )
    01685         {
    01686             switch( mDataTypes[i].GetType() )
    01687             {
    01688                 case eFbxBool:  FbxGetDirectArray<bool>(this,i).Resize( pSize )  ; break;
    01689                 case eFbxInt:   FbxGetDirectArray<int>(this,i).Resize( pSize )   ;  break;
    01690                 case eFbxFloat: FbxGetDirectArray<float>(this,i).Resize( pSize ) ;  break;
    01691                 case eFbxDouble:    FbxGetDirectArray<double>(this,i).Resize( pSize );  break;
    01692                 //case eFbxDouble3: GetDirectArray< FbxDouble3 >(i).Resize( pSize );    break;
    01693                 //case eFbxDouble4: GetDirectArray< FbxDouble4 >(i).Resize( pSize );    break;
    01694                 //case eFbxDouble4x4:   GetDirectArray< FbxDouble4x4>(i).Resize( pSize );   break;
    01695                 default:
    01696                     FBX_ASSERT_NOW("unknown type" ); break;
    01697             }
    01698         }
    01699     }
    01700
    01704     void RemoveFromAllDirectArrays( int pIndex )
    01705     {
    01706         for( int i = 0; i < GetDirectArray().GetCount(); ++i )
    01707         {
    01708             switch( mDataTypes[i].GetType() )
    01709             {
    01710                 case eFbxBool:  FbxGetDirectArray<bool>(this,i).RemoveAt( pIndex )  ; break;
    01711                 case eFbxInt:   FbxGetDirectArray<int>(this,i).RemoveAt( pIndex )   ; break;
    01712                 case eFbxFloat: FbxGetDirectArray<float>(this,i).RemoveAt( pIndex ) ; break;
    01713                 case eFbxDouble:    FbxGetDirectArray<double>(this,i).RemoveAt( pIndex ); break;
    01714                 //case eFbxDouble3: GetDirectArray< FbxDouble3 >(i).RemoveAt( pIndex ); break;
    01715                 //case eFbxDouble4: GetDirectArray< FbxDouble4 >(i).RemoveAt( pIndex ); break;
    01716                 //case eFbxDouble4x4:   GetDirectArray< FbxDouble4x4>(i).RemoveAt( pIndex );    break;
    01717                 default:
    01718                     FBX_ASSERT_NOW("unknown type" ); break;
    01719             }
    01720         }
    01721     }
    01722
    01727     int GetArrayCount( int pIndex ) const
    01728     {
    01729         if( pIndex >= 0 && pIndex < GetDirectArray().GetCount() )
    01730         {
    01731             switch( mDataTypes[pIndex].GetType() )
    01732             {
    01733                 case eFbxBool:  return FbxGetDirectArray<bool>(this,pIndex).GetCount();
    01734                 case eFbxInt:   return FbxGetDirectArray<int>(this,pIndex).GetCount();
    01735                 case eFbxFloat: return FbxGetDirectArray<float>(this,pIndex).GetCount();
    01736                 case eFbxDouble:    return FbxGetDirectArray<double>(this,pIndex).GetCount();
    01737                 //case eFbxDouble3: return GetDirectArray< FbxDouble3 >(pIndex).GetCount();
    01738                 //case eFbxDouble4: return GetDirectArray< FbxDouble4 >(pIndex).GetCount();
    01739                 //case eFbxDouble4x4:   return GetDirectArray< FbxDouble4x4>(pIndex).GetCount();
    01740                 default:
    01741                     FBX_ASSERT_NOW("Unknown type" ); break;
    01742             }
    01743         }
    01744
    01745         return -1;
    01746     }
    01747
    01751     int GetId() const { return mId; }
    01752
    01757     int GetDirectArrayCount() const { return GetDirectArray().GetCount(); }
    01758
    01763     FbxLayerElementUserData& operator=( FbxLayerElementUserData const& pOther )
    01764     {
    01765         if (this == &pOther)
    01766             return *this;
    01767
    01768         Clear();
    01769
    01770         mId = pOther.mId;
    01771         mDataTypes = pOther.mDataTypes;
    01772         mDataNames.Resize(pOther.mDataNames.GetCount());
    01773         for(int i = 0; i < pOther.mDataNames.GetCount(); ++i)
    01774             mDataNames.SetAt(i,  FbxNew< FbxString >( *pOther.mDataNames[i] ) );
    01775
    01776         Init();
    01777         for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
    01778         {
    01779             switch (mDataTypes[i].GetType())
    01780             {
    01781             case eFbxBool:
    01782                 FbxGetDirectArray<bool>(this, i) = FbxGetDirectArray<bool>(&pOther, i);
    01783                 break;
    01784
    01785             case eFbxInt:
    01786                 FbxGetDirectArray<int>(this, i) = FbxGetDirectArray<int>(&pOther, i);
    01787                 break;
    01788
    01789             case eFbxFloat:
    01790                 FbxGetDirectArray<float>(this, i) = FbxGetDirectArray<float>(&pOther, i);
    01791                 break;
    01792
    01793             case eFbxDouble:
    01794                 FbxGetDirectArray<double>(this, i) = FbxGetDirectArray<double>(&pOther, i);
    01795                 break;
    01796
    01797             default:
    01798                 FBX_ASSERT_NOW("Unknown type" );
    01799                 break;
    01800             }
    01801         }
    01802
    01803         if ( ( mReferenceMode == FbxLayerElement::eIndex ||
    01804                mReferenceMode == FbxLayerElement::eIndexToDirect) &&
    01805              ( pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
    01806                pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect))
    01807         {
    01808             GetIndexArray() = pOther.GetIndexArray();
    01809         }
    01810
    01811         return *this;
    01812     }
    01813
    01817     bool Clear()
    01818     {
    01819         int i;
    01820         const int lCount = GetDirectArray().GetCount();
    01821         FbxLayerElementArray** directArray = NULL;
    01822         directArray = GetDirectArray().GetLocked(directArray);
    01823         for( i = 0; directArray != NULL && i < lCount; ++i )
    01824         {
    01825             if( directArray[i] )
    01826                 FbxDelete(directArray[i]);
    01827         }
    01828         GetDirectArray().Release((void**)&directArray);
    01829
    01830         for( i = 0; i < mDataNames.GetCount(); ++i )
    01831         {
    01832             FBX_SAFE_DELETE(mDataNames[i]);
    01833         }
    01834         mDataNames.Clear();
    01835         mDataTypes.Clear();
    01836
    01837         FbxLayerElementTemplate<void*>::Clear();
    01838
    01839         return true;
    01840     }
    01841
    01846     virtual int MemorySize() const
    01847     {
    01848         int size = FbxLayerElementTemplate<void*>::MemorySize();
    01849         size += sizeof(mId);
    01850
    01851         for(int i = 0; i < mDataTypes.GetCount(); i++)
    01852         {
    01853             size += sizeof(mDataTypes[i]);
    01854         }
    01855         size += (mDataNames.GetCount() * sizeof(FbxString*));
    01856
    01857         return size;
    01858     }
    01859
    01861 //
    01862 //  WARNING!
    01863 //
    01864 //  Anything beyond these lines may not be documented accurately and is
    01865 //  subject to change without notice.
    01866 //
    01868
    01869 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    01870 protected:
    01880     FbxLayerElementUserData( int pId, FbxArray<FbxDataType>& pDataTypes, FbxArray<const char*>& pDataNames )
    01881         :
    01882         mId( pId ),
    01883         mDataTypes( pDataTypes )
    01884     {
    01885         FBX_ASSERT( pDataTypes.GetCount() == pDataNames.GetCount() );
    01886         for( int i = 0; i < pDataNames.GetCount(); ++i )
    01887         {
    01888             mDataNames.Add( FbxNew< FbxString >( pDataNames[i] ) );
    01889         }
    01890     }
    01891
    01895     FbxLayerElementUserData( FbxLayerElementUserData const& pOther ) : mId(pOther.mId), mDataTypes(pOther.mDataTypes)
    01896     {
    01897         for (int lIndex = 0; lIndex < pOther.mDataNames.GetCount(); ++lIndex)
    01898         {
    01899             mDataNames.Add(FbxNew<FbxString>(*(pOther.mDataNames[lIndex])));
    01900         }
    01901
    01902         SetType(&FbxLayerElementUserDataDT);
    01903         AllocateArrays();
    01904
    01905         for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
    01906         {
    01907             switch (mDataTypes[i].GetType())
    01908             {
    01909             case eFbxBool:
    01910                 FbxGetDirectArray<bool>(this, i) = FbxGetDirectArray<bool>(&pOther, i);
    01911                 break;
    01912
    01913             case eFbxInt:
    01914                 FbxGetDirectArray<int>(this, i) = FbxGetDirectArray<int>(&pOther, i);
    01915                 break;
    01916
    01917             case eFbxFloat:
    01918                 FbxGetDirectArray<float>(this, i) = FbxGetDirectArray<float>(&pOther, i);
    01919                 break;
    01920
    01921             case eFbxDouble:
    01922                 FbxGetDirectArray<double>(this, i) = FbxGetDirectArray<double>(&pOther, i);
    01923                 break;
    01924
    01925             default:
    01926                 FBX_ASSERT_NOW("Unknown type" );
    01927                 break;
    01928             }
    01929         }
    01930
    01931         if ( ( mReferenceMode == FbxLayerElement::eIndex ||
    01932             mReferenceMode == FbxLayerElement::eIndexToDirect) &&
    01933             ( pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
    01934             pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect))
    01935         {
    01936             GetIndexArray() = pOther.GetIndexArray();
    01937         }
    01938     }
    01939
    01941     ~FbxLayerElementUserData()
    01942     {
    01943         Clear();
    01944     }
    01945
    01947     virtual void AllocateArrays()
    01948     {
    01949         FbxLayerElementTemplate<void*>::AllocateArrays();
    01950         Init();
    01951     }
    01952
    01953
    01954 private:
    01955
    01956     void Init()
    01957     {
    01958         int i;
    01959         GetDirectArray().Resize( mDataTypes.GetCount() );
    01960
    01961         // initialize arrays
    01962         for( i = 0; i < mDataTypes.GetCount(); ++i )
    01963         {
    01964             FbxHandle** dst = NULL;
    01965             dst = GetDirectArray().GetLocked(dst);
    01966             if (dst)
    01967             {
    01968                 switch( mDataTypes[i].GetType() )
    01969                 {
    01970                     case eFbxBool:  dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<bool> >(mDataTypes[i].GetType()); break;
    01971                     case eFbxInt:   dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<int> >(mDataTypes[i].GetType());  break;
    01972                     case eFbxFloat: dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<float> >(mDataTypes[i].GetType());    break;
    01973                     case eFbxDouble:    dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<double> >(mDataTypes[i].GetType());   break;
    01974                     //case eFbxDouble3: mDirectArray[i] = new FbxArray< FbxDouble3 >(); break;
    01975                     //case eFbxDouble4: mDirectArray[i] = new FbxArray< FbxDouble4 >(); break;
    01976                     //case eFbxDouble4x4:   mDirectArray[i] = new FbxArray< FbxDouble4x4 >();   break;
    01977                     default:
    01978                         FBX_ASSERT_NOW("Trying to assign an unknown type" ); break;
    01979                 }
    01980                 GetDirectArray().Release((void**)&dst);
    01981             }
    01982         }
    01983     }
    01984
    01985     int mId;
    01986     FbxArray<FbxDataType> mDataTypes;
    01987     FbxArray<FbxString*> mDataNames;
    01988   #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    01989 };
    01990
    01998 template <class T>
    01999 inline FbxLayerElementArrayTemplate<T>& FbxGetDirectArray( FbxLayerElementUserData *pLayerElement,int pIndex, bool* pStatus)
    02000 {
    02001     return *(FbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pIndex,pStatus);
    02002 }
    02003
    02011 template <class T>
    02012 inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, int pIndex, bool* pStatus)
    02013 {
    02014     return *(FbxLayerElementArrayTemplate<T> const*)pLayerElement->GetDirectArrayVoid(pIndex,pStatus);
    02015 }
    02016
    02017
    02025 template <class T>
    02026 inline FbxLayerElementArrayTemplate<T>& FbxGetDirectArray( FbxLayerElementUserData *pLayerElement,const char* pName, bool* pStatus )
    02027 {
    02028     return *(FbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pName,pStatus);
    02029 }
    02030
    02038 template <class T>
    02039 inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, const char* pName, bool* pStatus )
    02040 {
    02041     return *(FbxLayerElementArrayTemplate<T> const*)pLayerElement->GetDirectArrayVoid(pName,pStatus);
    02042 }
    02043
    02044
    02051 class FBXSDK_DLL FbxLayerElementSmoothing : public FbxLayerElementTemplate<int>
    02052 {
    02053 public:
    02054     FBXSDK_FRIEND_NEW();
    02055
    02061     static FbxLayerElementSmoothing* Create(FbxLayerContainer* pOwner, char const *pName);
    02062
    02067     void SetReferenceMode( FbxLayerElement::EReferenceMode pMode )
    02068     {
    02069         if( pMode != FbxLayerElement::eDirect )
    02070         {
    02071             FBX_ASSERT_NOW( "Smoothing layer elements must be direct mapped" );
    02072             return;
    02073         }
    02074     }
    02075
    02077 //
    02078 //  WARNING!
    02079 //
    02080 //  Anything beyond these lines may not be documented accurately and is
    02081 //  subject to change without notice.
    02082 //
    02084 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02085
    02086 protected:
    02087     FbxLayerElementSmoothing()
    02088     {
    02089         mReferenceMode = FbxLayerElement::eDirect;
    02090     }
    02091 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02092 };
    02093
    02097 class FBXSDK_DLL FbxLayerElementCrease : public FbxLayerElementTemplate<double>
    02098 {
    02099 public:
    02100     FBXSDK_FRIEND_NEW();
    02101
    02107     static FbxLayerElementCrease* Create(FbxLayerContainer* pOwner, char const *pName);
    02108
    02113     void SetReferenceMode( FbxLayerElement::EReferenceMode pMode )
    02114     {
    02115         if( pMode != FbxLayerElement::eDirect )
    02116         {
    02117             FBX_ASSERT_NOW( "Crease layer elements must be direct mapped" );
    02118             return;
    02119         }
    02120     }
    02121
    02123 //
    02124 //  WARNING!
    02125 //
    02126 //  Anything beyond these lines may not be documented accurately and is
    02127 //  subject to change without notice.
    02128 //
    02130 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02131
    02132 protected:
    02133     FbxLayerElementCrease()
    02134     {
    02135         mReferenceMode = FbxLayerElement::eDirect;
    02136     }
    02137 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02138
    02139 };
    02140
    02144 class FBXSDK_DLL FbxLayerElementHole : public FbxLayerElementTemplate<bool>
    02145 {
    02146 public:
    02147     FBXSDK_FRIEND_NEW();
    02148
    02154         static FbxLayerElementHole* Create(FbxLayerContainer* pOwner, char const *pName);
    02155
    02160     void SetReferenceMode( FbxLayerElement::EReferenceMode pMode )
    02161     {
    02162         if( pMode != FbxLayerElement::eDirect )
    02163         {
    02164             FBX_ASSERT_NOW( "hole layer elements must be direct mapped" );
    02165             return;
    02166         }
    02167     }
    02168
    02170     //
    02171     //  WARNING!
    02172     //
    02173     //  Anything beyond these lines may not be documented accurately and is
    02174     //  subject to change without notice.
    02175     //
    02177 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02178
    02179 protected:
    02180     FbxLayerElementHole()
    02181     {
    02182         mReferenceMode = FbxLayerElement::eDirect;
    02183     }
    02184 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02185
    02186 };
    02187
    02190 class FBXSDK_DLL FbxLayerElementVisibility : public FbxLayerElementTemplate<bool>
    02191 {
    02192 public:
    02193
    02197     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementVisibility);
    02198
    02200 //
    02201 //  WARNING!
    02202 //
    02203 //  Anything beyond these lines may not be documented accurately and is
    02204 //  subject to change without notice.
    02205 //
    02207
    02208 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02209 protected:
    02210     FbxLayerElementVisibility();
    02211     ~FbxLayerElementVisibility();
    02212 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02213 };
    02214
    02218 typedef class FBXSDK_DLL FbxLayerElementTemplate<FbxTexture*>  FbxLayerElementTextureBase;
    02219
    02238 class FBXSDK_DLL FbxLayerElementTexture : public FbxLayerElementTextureBase
    02239 {
    02240
    02241 public:
    02242
    02246     FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementTexture);
    02247
    02282     enum EBlendMode
    02283     {
    02284         eTranslucent,
    02285         eAdd,
    02286         eModulate,
    02287         eModulate2,
    02288         eOver,
    02289         eNormal,
    02290         eDissolve,
    02291         eDarken,
    02292         eColorBurn,
    02293         eLinearBurn,
    02294         eDarkerColor,
    02295         eLighten,
    02296         eScreen,
    02297         eColorDodge,
    02298         eLinearDodge,
    02299         eLighterColor,
    02300         eSoftLight,
    02301         eHardLight,
    02302         eVividLight,
    02303         eLinearLight,
    02304         ePinLight,
    02305         eHardMix,
    02306         eDifference,
    02307         eExclusion,
    02308         eSubtract,
    02309         eDivide,
    02310         eHue,
    02311         eSaturation,
    02312         eColor,
    02313         eLuminosity,
    02314         eOverlay,
    02315         eBlendModeCount
    02316     };
    02317
    02321     void       SetBlendMode(EBlendMode pBlendMode) { mBlendMode = pBlendMode; }
    02322
    02327     void       SetAlpha(double pAlpha)
    02328     {
    02329         if (pAlpha > 1.0)
    02330             mAlpha = 1.0;
    02331         else if (pAlpha < 0.0)
    02332             mAlpha = 0.0;
    02333         else
    02334             mAlpha = pAlpha;
    02335     }
    02336
    02340     EBlendMode GetBlendMode() const                      { return mBlendMode; }
    02341
    02345     double     GetAlpha() const                          { return mAlpha; }
    02346
    02348 //
    02349 //  WARNING!
    02350 //
    02351 //  Anything beyond these lines may not be documented accurately and is
    02352 //  subject to change without notice.
    02353 //
    02355 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02356
    02357     virtual int MemorySize() const
    02358     {
    02359         int size = FbxLayerElementTextureBase::MemorySize();
    02360         size += sizeof(mBlendMode);
    02361         size += sizeof(mAlpha);
    02362         return size;
    02363     }
    02364
    02365 protected:
    02370     FbxLayerElementTexture() : mBlendMode(eTranslucent)
    02371     {
    02372         mReferenceMode = eIndexToDirect;
    02373         mAlpha         = 1.0;
    02374     }
    02375
    02376 private:
    02377     EBlendMode mBlendMode;
    02378     double     mAlpha;
    02379 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02380 };
    02381
    02382
    02436 class FBXSDK_DLL FbxLayer
    02437 {
    02438
    02439 public:
    02440     FBXSDK_FRIEND_NEW();
    02441
    02446
    02451     FbxLayerElementNormal* GetNormals();
    02452
    02457     FbxLayerElementNormal const* GetNormals() const;
    02458
    02463     FbxLayerElementTangent* GetTangents();
    02464
    02469     FbxLayerElementTangent const* GetTangents() const;
    02470
    02475     FbxLayerElementBinormal* GetBinormals();
    02476
    02481     FbxLayerElementBinormal const* GetBinormals() const;
    02482
    02486     FbxLayerElementMaterial* GetMaterials();
    02487
    02491     FbxLayerElementMaterial const* GetMaterials() const;
    02492
    02496     FbxLayerElementPolygonGroup* GetPolygonGroups();
    02497
    02501     FbxLayerElementPolygonGroup const* GetPolygonGroups() const;
    02502
    02509     FbxLayerElementUV* GetUVs(FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
    02510
    02517     FbxLayerElementUV const* GetUVs(FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse) const;
    02518
    02519
    02522     int GetUVSetCount() const;
    02523
    02526     FbxArray<FbxLayerElement::EType> GetUVSetChannels() const;
    02527
    02530     FbxArray<FbxLayerElementUV const*> GetUVSets() const;
    02531
    02536     FbxLayerElementVertexColor* GetVertexColors();
    02537
    02542     FbxLayerElementVertexColor const* GetVertexColors() const;
    02543
    02548     FbxLayerElementSmoothing* GetSmoothing();
    02549
    02554     FbxLayerElementSmoothing const* GetSmoothing() const;
    02555
    02560     FbxLayerElementCrease* GetVertexCrease();
    02561
    02566     FbxLayerElementCrease const* GetVertexCrease() const;
    02567
    02572     FbxLayerElementCrease* GetEdgeCrease();
    02573
    02578     FbxLayerElementCrease const* GetEdgeCrease() const;
    02579
    02584     FbxLayerElementHole* GetHole();
    02585
    02590     FbxLayerElementHole const* GetHole() const;
    02591
    02595     FbxLayerElementUserData* GetUserData();
    02596
    02600     FbxLayerElementUserData const* GetUserData() const;
    02601
    02605     FbxLayerElementVisibility* GetVisibility();
    02606
    02610     FbxLayerElementVisibility const* GetVisibility() const;
    02611
    02616     FbxLayerElementTexture* GetTextures(FbxLayerElement::EType pType);
    02617
    02622     FbxLayerElementTexture const* GetTextures(FbxLayerElement::EType pType) const;
    02623
    02628     void SetTextures(FbxLayerElement::EType pType, FbxLayerElementTexture* pTextures);
    02629
    02648     FbxLayerElement* GetLayerElementOfType(FbxLayerElement::EType pType, bool pIsUV=false);
    02649
    02668     FbxLayerElement const* GetLayerElementOfType(FbxLayerElement::EType pType, bool pIsUV=false) const;
    02669
    02674     void SetNormals(FbxLayerElementNormal* pNormals);
    02675
    02680     void SetBinormals(FbxLayerElementBinormal* pBinormals);
    02681
    02686     void SetTangents(FbxLayerElementTangent* pTangents);
    02687
    02691     void SetMaterials(FbxLayerElementMaterial* pMaterials);
    02692
    02696     void SetPolygonGroups(FbxLayerElementPolygonGroup* pPolygonGroups);
    02697
    02704     void SetUVs(FbxLayerElementUV* pUVs, FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
    02705
    02710     void SetVertexColors (FbxLayerElementVertexColor* pVertexColors);
    02711
    02716     void SetSmoothing (FbxLayerElementSmoothing* pSmoothing);
    02717
    02722     void SetVertexCrease (FbxLayerElementCrease* pCrease);
    02723
    02728     void SetEdgeCrease (FbxLayerElementCrease* pCrease);
    02729
    02734     void SetHole (FbxLayerElementHole* pHole);
    02735
    02739     void SetUserData (FbxLayerElementUserData* pUserData);
    02740
    02744     void SetVisibility( FbxLayerElementVisibility* pVisibility );
    02745
    02764     void SetLayerElementOfType(FbxLayerElement* pLayerElement, FbxLayerElement::EType pType, bool pIsUV=false);
    02765
    02772     FbxLayerElement* CreateLayerElementOfType(FbxLayerElement::EType pType, bool pIsUV=false);
    02773
    02778     void Clone(FbxLayer const& pSrcLayer, FbxManager* pSdkManager);
    02779
    02780
    02782 //
    02783 //  WARNING!
    02784 //
    02785 //  Anything beyond these lines may not be documented accurately and is
    02786 //  subject to change without notice.
    02787 //
    02789
    02790 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02791 protected:
    02793     FbxLayer& operator=(FbxLayer const& pSrcLayer);
    02795 private:
    02796
    02797     FbxLayer(FbxLayerContainer& pOwner);
    02798     virtual ~FbxLayer();
    02799
    02800     void Clear();
    02801
    02802     FbxLayerContainer& mOwner;
    02803
    02804     FbxLayerElement*             mNonTexturesArray[FbxLayerElement::sTypeNonTextureCount];
    02805     FbxLayerElementUV*           mUVsArray[FbxLayerElement::sTypeTextureCount];
    02806     FbxLayerElementTexture*      mTexturesArray[FbxLayerElement::sTypeTextureCount];
    02807
    02808
    02809     friend class FbxLayerContainer;
    02810
    02811 public:
    02816         bool ContentWriteTo(FbxStream& pStream) const;
    02817         bool ContentReadFrom(const FbxStream& pStream);
    02819     virtual int MemoryUsage() const;
    02820
    02821 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
    02822 };
    02823
    02827 #define FBXSDK_FOR_EACH_TEXTURE(lLayerIndex) for((lLayerIndex)=0;(lLayerIndex)<FbxLayerElement::sTypeTextureCount;(lLayerIndex)++)
    02828
    02832 #define FBXSDK_FOR_EACH_NON_TEXTURE(lLayerIndex) for((lLayerIndex)=0;(lLayerIndex)<FbxLayerElement::sTypeNonTextureCount;(lLayerIndex)++)
    02833
    02837 #define FBXSDK_TEXTURE_INDEX(ElementType) (int(ElementType)-FbxLayerElement::sTypeTextureStartIndex)
    02838
    02842 #define FBXSDK_TEXTURE_TYPE(TextureIndex) (FbxLayerElement::EType((TextureIndex)+FbxLayerElement::sTypeTextureStartIndex))
    02843
    02847 #define FBXSDK_NON_TEXTURE_INDEX(ElementType) (int(ElementType)-FbxLayerElement::sTypeNonTextureStartIndex)
    02848
    02852 #define FBXSDK_NON_TEXTURE_TYPE(Index) (FbxLayerElement::EType((Index)+FbxLayerElement::sTypeNonTextureStartIndex))
    02853
    02866 typedef FbxLayerElement FbxGeometryElement;
    02867 typedef FbxLayerElementNormal FbxGeometryElementNormal;
    02868 typedef FbxLayerElementBinormal FbxGeometryElementBinormal;
    02869 typedef FbxLayerElementTangent FbxGeometryElementTangent;
    02870 typedef FbxLayerElementMaterial FbxGeometryElementMaterial;
    02871 typedef FbxLayerElementPolygonGroup FbxGeometryElementPolygonGroup;
    02872 typedef FbxLayerElementUV FbxGeometryElementUV;
    02873 typedef FbxLayerElementVertexColor FbxGeometryElementVertexColor;
    02874 typedef FbxLayerElementUserData FbxGeometryElementUserData;
    02875 typedef FbxLayerElementSmoothing FbxGeometryElementSmoothing;
    02876 typedef FbxLayerElementCrease FbxGeometryElementCrease;
    02877 typedef FbxLayerElementHole FbxGeometryElementHole;
    02878 typedef FbxLayerElementVisibility FbxGeometryElementVisibility;
    02879
    02880 #undef FBXSDK_LAYER_ELEMENT_CREATE_DECLARE
    02881
    02882 #include <fbxsdk/fbxsdk_nsend.h>
    02883
    02884 #endif /* _FBXSDK_SCENE_GEOMETRY_LAYER_H_ */