00001
00002
00003
00004
00005
00006
00007
00008
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/fbxdatatypes.h>
00019 #include <fbxsdk/core/fbxstream.h>
00020 #include <fbxsdk/scene/shading/fbxsurfacematerial.h>
00021 #include <fbxsdk/scene/shading/fbxtexture.h>
00022
00023 #include <fbxsdk/fbxsdk_nsbegin.h>
00024
00025 class FbxLayerElementArray;
00026 class FbxLayerContainer;
00027
00038 class FBXSDK_DLL FbxLayerElement
00039 {
00040 public:
00075 enum EType
00076 {
00077 eUnknown,
00078
00079
00080
00081 eNormal,
00082 eBiNormal,
00083 eTangent,
00084 eMaterial,
00085 ePolygonGroup,
00086 eUV,
00087 eVertexColor,
00088 eSmoothing,
00089 eVertexCrease,
00090 eEdgeCrease,
00091 eHole,
00092 eUserData,
00093 eVisibility,
00094
00095
00096
00097 eTextureDiffuse,
00098 eTextureDiffuseFactor,
00099 eTextureEmissive,
00100 eTextureEmissiveFactor,
00101 eTextureAmbient,
00102 eTextureAmbientFactor,
00103 eTextureSpecular,
00104 eTextureSpecularFactor,
00105 eTextureShininess,
00106 eTextureNormalMap,
00107 eTextureBump,
00108 eTextureTransparency,
00109 eTextureTransparencyFactor,
00110 eTextureReflection,
00111 eTextureReflectionFactor,
00112 eTextureDisplacement,
00113 eTextureDisplacementVector,
00114
00115 eTypeCount
00116 };
00117
00118 const static int sTypeTextureStartIndex = int(eTextureDiffuse);
00119 const static int sTypeTextureEndIndex = int(eTypeCount) - 1;
00120 const static int sTypeTextureCount = sTypeTextureEndIndex - sTypeTextureStartIndex + 1;
00121 const static int sTypeNonTextureStartIndex = int(eNormal);
00122 const static int sTypeNonTextureEndIndex = int(eVisibility);
00123 const static int sTypeNonTextureCount = sTypeNonTextureEndIndex - sTypeNonTextureStartIndex + 1;
00124 static const char* const sTextureNames[];
00125 static const char* const sTextureUVNames[];
00126 static const char* const sNonTextureNames[];
00127 static const FbxDataType sTextureDataTypes[];
00128 static const char* const sTextureChannelNames[];
00129
00140 enum EMappingMode
00141 {
00142 eNone,
00143 eByControlPoint,
00144 eByPolygonVertex,
00145 eByPolygon,
00146 eByEdge,
00147 eAllSame
00148 };
00149
00163 enum EReferenceMode
00164 {
00165 eDirect,
00166 eIndex,
00167 eIndexToDirect
00168 };
00169
00170
00174 void SetMappingMode(EMappingMode pMappingMode) { mMappingMode = pMappingMode; }
00175
00179 void SetReferenceMode(EReferenceMode pReferenceMode) { mReferenceMode = pReferenceMode; }
00180
00184 EMappingMode GetMappingMode() const { return mMappingMode; }
00185
00189 EReferenceMode GetReferenceMode() const { return mReferenceMode; }
00190
00194 void SetName(const char* pName) { mName = FbxString(pName); }
00195
00199 const char* GetName() const { return ((FbxLayerElement*)this)->mName.Buffer(); }
00200
00205 bool operator==(const FbxLayerElement& pOther) const
00206 {
00207 return (mName == pOther.mName) &&
00208 (mMappingMode == pOther.mMappingMode) &&
00209 (mReferenceMode == pOther.mReferenceMode);
00210 }
00211
00216 FbxLayerElement& operator=( FbxLayerElement const& pOther )
00217 {
00218 mMappingMode = pOther.mMappingMode;
00219 mReferenceMode = pOther.mReferenceMode;
00220
00221
00222 return *this;
00223 }
00224
00226 void Destroy();
00227
00229 virtual bool Clear()
00230 {
00231 return true;
00232 }
00233
00234
00235
00236
00237 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00238 void SetType(const FbxDataType* pType) { mType = pType; }
00239 const FbxLayerContainer* GetOwner() const { return mOwner; }
00240
00241 protected:
00242 FbxLayerElement()
00243 : mMappingMode(eNone)
00244 , mReferenceMode(eDirect)
00245 , mName("")
00246 , mOwner(NULL)
00247 {
00248 }
00249
00250 virtual ~FbxLayerElement()
00251 {
00252 }
00253
00254 EMappingMode mMappingMode;
00255 EReferenceMode mReferenceMode;
00256
00257 FbxString mName;
00258 const FbxDataType* mType;
00259 FbxLayerContainer* mOwner;
00260
00261 void Destruct() { FbxDelete(this); }
00262 virtual void SetOwner(FbxLayerContainer* pOwner);
00263
00264 FBXSDK_FRIEND_NEW();
00265
00266 public:
00267 virtual int MemorySize() const { return 0; }
00268 virtual bool ContentWriteTo(FbxStream& pStream) const;
00269 virtual bool ContentReadFrom(const FbxStream& pStream);
00270
00271 friend class FbxLayerContainer;
00272 #endif
00273 };
00274
00280 class FBXSDK_DLL LockAccessStatus
00281 {
00282 public:
00295 enum ELockAccessStatus
00296 {
00297 eSuccess,
00298 eUnsupportedDTConversion,
00299 eCorruptedCopyback,
00300 eBadValue,
00301 eLockMismatch,
00302 eNoWriteLock,
00303 eNoReadLock,
00304 eNotOwner,
00305 eDirectLockExist
00306 };
00307 };
00308
00309
00310 typedef FbxHandle* FbxRefPtr;
00311 typedef FbxLayerElementArray* FbxLayerElementArrayPtr;
00312 typedef FbxSurfaceMaterial* FbxSurfaceMaterialPtr;
00313 typedef FbxTexture* FbxTexturePtr;
00314
00315 inline EFbxType FbxTypeOf(const FbxRefPtr&){ return eFbxReference; }
00316 inline EFbxType FbxTypeOf(const FbxLayerElementArrayPtr&){ return eFbxReference; }
00317 inline EFbxType FbxTypeOf(const FbxSurfaceMaterialPtr&){ return eFbxReference; }
00318 inline EFbxType FbxTypeOf(const FbxTexturePtr&){ return eFbxReference; }
00319
00325 class FBXSDK_DLL FbxLayerElementArray
00326 {
00327 public:
00332
00336 FbxLayerElementArray(EFbxType pDataType);
00337
00339 virtual ~FbxLayerElementArray();
00340
00342
00347
00349 inline void ClearStatus() { mStatus = LockAccessStatus::eSuccess; }
00350
00352 inline LockAccessStatus::ELockAccessStatus GetStatus() const { return mStatus; }
00354
00359
00363 inline bool IsWriteLocked() const { return mWriteLock; };
00364
00368 inline int GetReadLockCount() const { return mReadLockCount; }
00370
00374 bool IsInUse() const;
00375
00379 int ReadLock() const;
00380
00384 int ReadUnlock() const;
00385
00390 bool WriteLock() const;
00391
00394 void WriteUnlock() const;
00395
00400 bool ReadWriteLock() const;
00401
00404 void ReadWriteUnlock() const;
00405
00406
00412 enum ELockMode
00413 {
00414 eReadLock = 1,
00415 eWriteLock = 2,
00416 eReadWriteLock = 3
00417 };
00418
00431 virtual void* GetLocked(ELockMode pLockMode, EFbxType pDataType);
00432
00444 void* GetLocked(ELockMode pLockMode=eReadWriteLock) { return GetLocked(pLockMode, mDataType); }
00445
00457 template <class T> inline T* GetLocked(T*, ELockMode pLockMode=eReadWriteLock) {T v; return (T*)GetLocked(pLockMode, FbxTypeOf(v)); }
00458
00469 virtual void Release(void** pDataPtr, EFbxType pDataType);
00470
00480 void Release(void** pDataPtr) { Release(pDataPtr, mDataType); }
00481
00492 template <class T> inline void Release(T** pDataPtr, T* dummy) { Release((void**)pDataPtr, FbxTypeOf(*dummy)); }
00493
00496 virtual size_t GetStride() const;
00497
00502
00504 int GetCount() const;
00505
00509 void SetCount(int pCount);
00510
00512 void Clear();
00513
00517 void Resize(int pItemCount);
00518
00522 void AddMultiple(int pItemCount);
00523
00529 int Add(const void* pItem, EFbxType pValueType);
00530
00538 int InsertAt(int pIndex, const void* pItem, EFbxType pValueType);
00539
00546 void SetAt(int pIndex, const void* pItem, EFbxType pValueType);
00547
00553 void SetLast(const void* pItem, EFbxType pValueType);
00554
00561 void RemoveAt(int pIndex, void** pItem, EFbxType pValueType);
00562
00568 void RemoveLast(void** pItem, EFbxType pValueType);
00569
00575 bool RemoveIt(void** pItem, EFbxType pValueType);
00576
00584 bool GetAt(int pIndex, void** pItem, EFbxType pValueType) const;
00585
00591 bool GetFirst(void** pItem, EFbxType pValueType) const;
00592
00598 bool GetLast(void** pItem, EFbxType pValueType) const;
00599
00606 int Find(const void* pItem, EFbxType pValueType) const;
00607
00615 int FindAfter(int pAfterIndex, const void* pItem, EFbxType pValueType) const;
00616
00624 int FindBefore(int pBeforeIndex, const void* pItem, EFbxType pValueType) const;
00625
00630 bool IsEqual(const FbxLayerElementArray& pArray) const;
00631
00636 template <class T> inline int Add(T const& pItem) { return Add((const void*)&pItem, FbxTypeOf(pItem)); }
00637
00644 template <class T> inline int InsertAt(int pIndex, T const& pItem) { return InsertAt(pIndex, (const void*)&pItem, FbxTypeOf(pItem)); }
00645
00651 template <class T> inline void SetAt(int pIndex, T const& pItem) { SetAt(pIndex, (const void*)&pItem, FbxTypeOf(pItem)); }
00652
00657 template <class T> inline void SetLast(T const& pItem) { SetLast((const void*)&pItem, FbxTypeOf(pItem)); }
00658
00664 template <class T> inline void RemoveAt(int pIndex, T* pItem) { RemoveAt(pIndex, (void**)&pItem, FbxTypeOf(*pItem)); }
00665
00670 template <class T> inline void RemoveLast(T* pItem) { RemoveLast((void**)&pItem, FbxTypeOf(*pItem)); }
00671
00676 template <class T> inline bool RemoveIt(T* pItem) { return RemoveIt((void**)&pItem, FbxTypeOf(*pItem)); }
00677
00684 template <class T> inline bool GetAt(int pIndex, T* pItem) const { return GetAt(pIndex, (void**)&pItem, FbxTypeOf(*pItem)); }
00685
00690 template <class T> inline bool GetFirst(T* pItem) const { return GetFirst((void**)&pItem, FbxTypeOf(*pItem)); }
00691
00696 template <class T> inline bool GetLast(T* pItem) const { return GetLast((void**)&pItem, FbxTypeOf(*pItem)); }
00697
00703 template <class T> inline int Find(T const& pItem) const { return Find((const void*)&pItem, FbxTypeOf(pItem)); }
00704
00711 template <class T> inline int FindAfter(int pAfterIndex, T const& pItem) const { return FindAfter(pAfterIndex, (const void*)&pItem, FbxTypeOf(pItem)); }
00712
00719 template <class T> inline int FindBefore(int pBeforeIndex, T const& pItem) const { return FindBefore(pBeforeIndex, (const void*)&pItem, FbxTypeOf(pItem)); }
00720
00721
00725 template<typename T> inline void CopyTo(FbxArray<T>& pDst)
00726 {
00727 T src;
00728 T* srcPtr = &src;
00729
00730 pDst.Clear();
00731 if (mDataType != FbxTypeOf(src))
00732 {
00733 SetStatus(LockAccessStatus::eUnsupportedDTConversion);
00734 return;
00735 }
00736
00737 pDst.Resize(GetCount());
00738 for (int i = 0; i < GetCount(); i++)
00739 {
00740 if (GetAt(i, (void**)&srcPtr, mDataType))
00741 {
00742 pDst.SetAt(i, src);
00743 }
00744 }
00745 SetStatus(LockAccessStatus::eSuccess);
00746 }
00748
00749 protected:
00750 void* GetDataPtr();
00751 void* GetReference(int pIndex, EFbxType pValueType);
00752 void GetReferenceTo(int pIndex, void** pRef, EFbxType pValueType);
00753
00754 inline void SetStatus(LockAccessStatus::ELockAccessStatus pVal) const
00755 {
00756 const_cast<FbxLayerElementArray*>(this)->mStatus = pVal;
00757 }
00758
00759 void SetImplementation(void* pImplementation);
00760 inline void* GetImplementation() { return mImplementation; }
00761 virtual void ConvertDataType(EFbxType pDataType, void** pDataPtr, size_t* pStride);
00762
00763 EFbxType mDataType;
00764
00765 private:
00766 LockAccessStatus::ELockAccessStatus mStatus;
00767
00768 int mReadLockCount;
00769 bool mWriteLock;
00770 void* mImplementation;
00771 size_t mStride;
00772 int mDirectLockOn;
00773 bool mDirectAccessOn;
00774
00775 FbxArray<void*> mConvertedData;
00776
00777 };
00778
00782 template <typename T>
00783 struct FbxLayerElementArrayReadLock
00784 {
00788 FbxLayerElementArrayReadLock(FbxLayerElementArray& pArray) : mArray(pArray)
00789 {
00790 mLockedData = mArray.GetLocked((T*)NULL, FbxLayerElementArray::eReadLock);
00791 }
00792
00796 ~FbxLayerElementArrayReadLock()
00797 {
00798 if( mLockedData )
00799 {
00800 mArray.Release((void **) &mLockedData);
00801 }
00802 }
00803
00807 const T* GetData() const
00808 {
00809 return mLockedData;
00810 }
00811
00812 private:
00813 FbxLayerElementArray& mArray;
00814 T* mLockedData;
00815 };
00816
00817 class FbxLayerElementUserData;
00818
00823 template <class T> class FbxLayerElementArrayTemplate : public FbxLayerElementArray
00824 {
00825 public:
00826
00830 FbxLayerElementArrayTemplate(EFbxType pDataType) :
00831 FbxLayerElementArray(pDataType)
00832 {
00833 }
00834
00839 inline int Add( T const &pItem ) { return FbxLayerElementArray::Add(pItem); }
00840
00846 inline int InsertAt(int pIndex, T const &pItem) { return FbxLayerElementArray::InsertAt(pIndex, pItem); }
00847
00852 inline void SetAt(int pIndex, T const &pItem) { FbxLayerElementArray::SetAt(pIndex, pItem); }
00853
00857 inline void SetLast( T const &pItem) { FbxLayerElementArray::SetLast(pItem); }
00858
00863 inline T RemoveAt(int pIndex) { T lValue; FbxLayerElementArray::RemoveAt(pIndex, &lValue); return lValue; }
00864
00868 inline T RemoveLast() { T lValue; FbxLayerElementArray::RemoveLast(&lValue); return lValue; }
00869
00874 inline bool RemoveIt(T const &pItem) { return FbxLayerElementArray::RemoveIt(&pItem); }
00875
00881 inline T GetAt(int pIndex) const { T lValue; FbxLayerElementArray::GetAt(pIndex, &lValue); return lValue; }
00882
00886 inline T GetFirst() const { T lValue; FbxLayerElementArray::GetFirst(&lValue); return lValue; }
00887
00891 inline T GetLast() const { T lValue; FbxLayerElementArray::GetLast(&lValue); return lValue; }
00892
00898 inline int Find(T const &pItem) { return FbxLayerElementArray::Find(pItem); }
00899
00906 inline int FindAfter(int pAfterIndex, T const &pItem) { return FbxLayerElementArray::FindAfter(pAfterIndex, pItem); }
00907
00914 inline int FindBefore(int pBeforeIndex, T const &pItem) { return FbxLayerElementArray::FindBefore(pBeforeIndex, pItem); }
00915
00921 T operator[](int pIndex) const { T lValue; FbxLayerElementArray::GetAt(pIndex, &lValue); return lValue; }
00922
00926 FbxLayerElementArray& operator=(const FbxArray<T>& pArrayTemplate)
00927 {
00928 SetStatus(LockAccessStatus::eNoWriteLock);
00929 if (WriteLock())
00930 {
00931 SetCount(pArrayTemplate.GetCount());
00932 for (int i = 0; i < pArrayTemplate.GetCount(); i++)
00933 SetAt(i, pArrayTemplate.GetAt(i));
00934 WriteUnlock();
00935 SetStatus(LockAccessStatus::eSuccess);
00936 }
00937 return *this;
00938 }
00939
00943 FbxLayerElementArrayTemplate<T>& operator=(const FbxLayerElementArrayTemplate<T>& pArrayTemplate)
00944 {
00945 if ( this != &pArrayTemplate )
00946 {
00947 SetStatus(LockAccessStatus::eNoWriteLock);
00948 if (WriteLock())
00949 {
00950 SetCount(pArrayTemplate.GetCount());
00951 for (int i = 0; i < pArrayTemplate.GetCount(); i++)
00952 SetAt(i, pArrayTemplate.GetAt(i));
00953 WriteUnlock();
00954 SetStatus(LockAccessStatus::eSuccess);
00955 }
00956 }
00957 return *this;
00958 }
00959
00960 private:
00961
00962
00963
00964 friend class FbxLayerElementUserData;
00965 T& AsReference(int pIndex) { T* v = (T*)FbxLayerElementArray::GetReference(pIndex, mDataType); return (v)?*v:dummy;}
00966
00967 T dummy;
00968 };
00969
00970
00978 extern int RemapIndexArrayTo(FbxLayerElement* pLayerEl,
00979 FbxLayerElement::EMappingMode pNewMapping,
00980 FbxLayerElementArrayTemplate<int>* pIndexArray);
00981
00982
00987 template <class Type> class FbxLayerElementTemplate : public FbxLayerElement
00988 {
00989 public:
00990
00995 FbxLayerElementArrayTemplate<Type>& GetDirectArray() const
00996 {
00997 FBX_ASSERT(mReferenceMode == FbxLayerElement::eDirect || mReferenceMode == FbxLayerElement::eIndexToDirect);
00998 return *mDirectArray;
00999 }
01000
01005 FbxLayerElementArrayTemplate<Type>& GetDirectArray()
01006 {
01007 FBX_ASSERT(mReferenceMode == FbxLayerElement::eDirect || mReferenceMode == FbxLayerElement::eIndexToDirect);
01008 return *mDirectArray;
01009 }
01010
01015 FbxLayerElementArrayTemplate<int>& GetIndexArray() const
01016 {
01017 FBX_ASSERT(mReferenceMode == FbxLayerElement::eIndex || mReferenceMode == FbxLayerElement::eIndexToDirect);
01018 return *mIndexArray;
01019 }
01020
01025 FbxLayerElementArrayTemplate<int>& GetIndexArray()
01026 {
01027 FBX_ASSERT(mReferenceMode == FbxLayerElement::eIndex || mReferenceMode == FbxLayerElement::eIndexToDirect);
01028 return *mIndexArray;
01029 }
01030
01035 bool Clear()
01036 {
01037 bool ret = true;
01038 mDirectArray->Clear();
01039 ret = (mDirectArray->GetStatus() == LockAccessStatus::eSuccess);
01040
01041 mIndexArray->Clear();
01042 ret |= (mIndexArray->GetStatus() == LockAccessStatus::eSuccess);
01043
01044 return ret;
01045 }
01046
01047 public:
01048
01053 bool operator==(const FbxLayerElementTemplate& pOther) const
01054 {
01055 bool ret = true;
01056
01057 if (pOther.GetReferenceMode() == FbxLayerElement::eDirect ||
01058 pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
01059 {
01060 const FbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
01061 if( directArray.GetCount() != mDirectArray->GetCount() ||
01062 !directArray.ReadLock() || !mDirectArray->ReadLock() )
01063 {
01064 ret = false;
01065 }
01066
01067 if( ret && !mDirectArray->IsEqual(directArray) )
01068 ret = false;
01069
01070 directArray.ReadUnlock();
01071 mDirectArray->ReadUnlock();
01072 }
01073
01074 if (ret)
01075 {
01076 if (pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
01077 pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
01078 {
01079 const FbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
01080 if( indexArray.GetCount() != mIndexArray->GetCount() ||
01081 !indexArray.ReadLock() || !mIndexArray->ReadLock() )
01082 {
01083 ret = false;
01084 }
01085
01086 if( ret && !mIndexArray->IsEqual(indexArray) )
01087 ret = false;
01088
01089 indexArray.ReadUnlock();
01090 mIndexArray->ReadUnlock();
01091 }
01092 }
01093
01094 if (ret == false)
01095 return false;
01096
01097 return FbxLayerElement::operator==(pOther);
01098 }
01099
01103 FbxLayerElementTemplate& operator=( FbxLayerElementTemplate const& pOther )
01104 {
01105 FBX_ASSERT(mDirectArray != NULL);
01106 FBX_ASSERT(mIndexArray != NULL);
01107
01108 if (pOther.GetReferenceMode() == FbxLayerElement::eDirect ||
01109 pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
01110 {
01111 const FbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
01112 *mDirectArray = directArray;
01113 }
01114
01115 if (pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
01116 pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
01117 {
01118 const FbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
01119 *mIndexArray = indexArray;
01120 }
01121
01122 FbxLayerElement* myself = (FbxLayerElement*)this;
01123 FbxLayerElement* myOther = (FbxLayerElement*)&pOther;
01124 *myself = *myOther;
01125 return *this;
01126 }
01127
01135 int RemapIndexTo(FbxLayerElement::EMappingMode pNewMapping)
01136 {
01137 return RemapIndexArrayTo(this, pNewMapping, mIndexArray);
01138 }
01139
01140
01141
01142
01143 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01144 protected:
01145 FbxLayerElementTemplate()
01146 {
01147 mDirectArray = NULL;
01148 mIndexArray = NULL;
01149 }
01150
01151 ~FbxLayerElementTemplate()
01152 {
01153 FbxDelete(mDirectArray);
01154 FbxDelete(mIndexArray);
01155 }
01156
01157 virtual void AllocateArrays()
01158 {
01159 mDirectArray = FbxNew< FbxLayerElementArrayTemplate<Type> >(mType->GetType());
01160 mIndexArray = FbxNew< FbxLayerElementArrayTemplate<int> >(FbxIntDT.GetType());
01161 }
01162
01163 public:
01164 virtual int MemorySize() const
01165 {
01166 int size = FbxLayerElement::MemorySize();
01167 size += (mDirectArray->GetCount()*sizeof(Type));
01168 size += (mIndexArray->GetCount()*sizeof(int));
01169 return size;
01170 }
01171
01176 virtual bool ContentWriteTo(FbxStream& pStream) const
01177 {
01178 void* a;
01179 int s,v;
01180 int count = 0;
01181
01182
01183 count = mDirectArray->GetCount();
01184 s = pStream.Write(&count, sizeof(int));
01185 if (s != sizeof(int)) return false;
01186 if (count > 0)
01187 {
01188 a = mDirectArray->GetLocked();
01189 FBX_ASSERT(a != NULL);
01190 v = count*sizeof(Type);
01191 s = pStream.Write(a, v);
01192 mDirectArray->Release(&a);
01193 if (s != v) return false;
01194 }
01195
01196
01197 count = mIndexArray->GetCount();
01198 s = pStream.Write(&count, sizeof(int));
01199 if (s != sizeof(int)) return false;
01200 if (count > 0)
01201 {
01202 a = mIndexArray->GetLocked();
01203 FBX_ASSERT(a != NULL);
01204 v = count*sizeof(int);
01205 s = pStream.Write(a, v);
01206 mIndexArray->Release(&a);
01207 if (s != v) return false;
01208 }
01209
01210 return FbxLayerElement::ContentWriteTo(pStream);
01211 }
01212
01213 virtual bool ContentReadFrom(const FbxStream& pStream)
01214 {
01215 void* a;
01216 int s,v;
01217 int count = 0;
01218
01219
01220 s = pStream.Read(&count, sizeof(int));
01221 if (s != sizeof(int)) return false;
01222 mDirectArray->Resize(count);
01223 if (count > 0)
01224 {
01225 a = mDirectArray->GetLocked();
01226 FBX_ASSERT(a != NULL);
01227 v = count*sizeof(Type);
01228 s = pStream.Read(a, v);
01229 mDirectArray->Release(&a);
01230 if (s != v) return false;
01231 }
01232
01233
01234 s = pStream.Read(&count, sizeof(int));
01235 if (s != sizeof(int)) return false;
01236 mIndexArray->Resize(count);
01237 if (count > 0)
01238 {
01239 a = mIndexArray->GetLocked();
01240 FBX_ASSERT(a != NULL);
01241 v = count*sizeof(int);
01242 s = pStream.Read(a, v);
01243 mIndexArray->Release(&a);
01244 if (s != v) return false;
01245 }
01246 return FbxLayerElement::ContentReadFrom(pStream);
01247 }
01249
01250 typedef Type ArrayElementType;
01251 typedef FbxLayerElementArrayTemplate<Type> DirectArrayType;
01252 typedef FbxLayerElementArrayTemplate<int> IndexArrayType;
01253
01254 FbxLayerElementArrayTemplate<Type>* mDirectArray;
01255 FbxLayerElementArrayTemplate<int>* mIndexArray;
01256 #endif
01257 };
01258
01259 #define FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(classDesc) \
01260 FBXSDK_FRIEND_NEW(); \
01261 static Fbx##classDesc* Create(FbxLayerContainer* pOwner, const char* pName);
01262
01268 class FBXSDK_DLL FbxLayerElementNormal : public FbxLayerElementTemplate<FbxVector4>
01269 {
01270 public:
01271
01275 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementNormal);
01276
01277 protected:
01278 FbxLayerElementNormal();
01279 ~FbxLayerElementNormal();
01280 };
01281
01285 class FBXSDK_DLL FbxLayerElementBinormal : public FbxLayerElementTemplate<FbxVector4>
01286 {
01287 public:
01288
01292 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementBinormal);
01293
01294 protected:
01295 FbxLayerElementBinormal();
01296 ~FbxLayerElementBinormal();
01297 };
01298
01302 class FBXSDK_DLL FbxLayerElementTangent : public FbxLayerElementTemplate<FbxVector4>
01303 {
01304 public:
01305
01309 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementTangent);
01310
01311 protected:
01312 FbxLayerElementTangent();
01313 ~FbxLayerElementTangent();
01314 };
01315
01359 class FBXSDK_DLL FbxLayerElementMaterial : public FbxLayerElementTemplate<FbxSurfaceMaterial*>
01360 {
01361 public:
01362 typedef FbxLayerElementTemplate<FbxSurfaceMaterial*> ParentClass;
01363
01367 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementMaterial);
01368
01374 class LayerElementArrayProxy : public FbxLayerElementArrayTemplate<FbxSurfaceMaterial*>
01375 {
01376 public:
01377 typedef FbxLayerElementArrayTemplate<FbxSurfaceMaterial*> ParentClass;
01378
01379 LayerElementArrayProxy(EFbxType pType);
01380 void SetContainer( FbxLayerContainer* pContainer, int pInstance = 0);
01381 };
01382
01383
01384
01385
01386 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01387 virtual void AllocateArrays();
01388 virtual void SetOwner( FbxLayerContainer* pOwner, int pInstance = 0);
01389 virtual void SetInstance( int pInstance ) { SetOwner( mOwner, pInstance ); }
01390
01391 protected:
01392 FbxLayerElementMaterial();
01393 ~FbxLayerElementMaterial();
01394
01395 private:
01396 FbxLayerElementArrayTemplate<FbxSurfaceMaterial*>& GetDirectArray() const
01397 {
01398 return ParentClass::GetDirectArray();
01399 }
01400
01401 FbxLayerElementArrayTemplate<FbxSurfaceMaterial*>& GetDirectArray()
01402 {
01403 return ParentClass::GetDirectArray();
01404 }
01405
01406 friend class FbxLayerContainer;
01407 #endif
01408 };
01409
01415 class FBXSDK_DLL FbxLayerElementPolygonGroup : public FbxLayerElementTemplate<int>
01416 {
01417 public:
01418
01422 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementPolygonGroup);
01423
01424 protected:
01425 FbxLayerElementPolygonGroup();
01426 ~FbxLayerElementPolygonGroup();
01427 };
01428
01443 class FBXSDK_DLL FbxLayerElementUV : public FbxLayerElementTemplate<FbxVector2>
01444 {
01445 public:
01449 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementUV);
01450
01451 protected:
01452 FbxLayerElementUV();
01453 ~FbxLayerElementUV();
01454 };
01455
01459 class FBXSDK_DLL FbxLayerElementVertexColor : public FbxLayerElementTemplate<FbxColor>
01460 {
01461 public:
01462
01466 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementVertexColor);
01467
01468 protected:
01469 FbxLayerElementVertexColor();
01470 ~FbxLayerElementVertexColor();
01471 };
01472
01473 template <class T> inline FbxLayerElementArrayTemplate<T>& FbxGetDirectArray(FbxLayerElementUserData *pLayerElement, int pIndex, bool* pStatus = NULL);
01474 template <class T> inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, int pIndex, bool* pStatus = NULL);
01475 template <class T> inline FbxLayerElementArrayTemplate<T>& FbxGetDirectArray(FbxLayerElementUserData *pLayerElement, const char* pName, bool* pStatus = NULL );
01476 template <class T> inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, const char* pName, bool* pStatus = NULL );
01477
01483 class FBXSDK_DLL FbxLayerElementUserData : public FbxLayerElementTemplate<void*>
01484 {
01485 public:
01486 FBXSDK_FRIEND_NEW();
01487
01497 static FbxLayerElementUserData* Create(FbxLayerContainer* pOwner, const char* pName, int pId, FbxArray<FbxDataType>& pDataTypes, FbxArray<const char*>& pDataNames);
01498
01504 static FbxLayerElementUserData* Create(FbxLayerContainer* pOwner, FbxLayerElementUserData const& pOther );
01505
01511 FbxLayerElementArrayTemplate<void*>* GetDirectArrayVoid( int pIndex, bool* pStatus = NULL)
01512 {
01513 if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
01514 {
01515 if (pStatus) *pStatus = true;
01516 return (FbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
01517 }
01518 else
01519 {
01520 if( pStatus ) *pStatus = false;
01521 FBX_ASSERT_NOW("Index out of bounds");
01522 return (FbxLayerElementArrayTemplate<void*>*)NULL;
01523 }
01524 }
01525
01531 const FbxLayerElementArrayTemplate<void*>* GetDirectArrayVoid( int pIndex, bool* pStatus = NULL) const
01532 {
01533 if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
01534 {
01535 if (pStatus) *pStatus = true;
01536 return (FbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
01537 }
01538 else
01539 {
01540 if( pStatus ) *pStatus = false;
01541 FBX_ASSERT_NOW("Index out of bounds");
01542 return (const FbxLayerElementArrayTemplate<void*>*)NULL;
01543 }
01544 }
01545
01546
01552 FbxLayerElementArrayTemplate<void *>* GetDirectArrayVoid ( const char* pName, bool* pStatus = NULL )
01553 {
01554 FbxString lName( pName );
01555 for( int i = 0; i < mDataNames.GetCount(); ++i )
01556 {
01557 if( *mDataNames[i] == lName )
01558 return GetDirectArrayVoid(i, pStatus);
01559 }
01560
01561 if (pStatus) *pStatus = false;
01562 return (FbxLayerElementArrayTemplate<void *>*)NULL;
01563 }
01564
01570 const FbxLayerElementArrayTemplate<void*>* GetDirectArrayVoid ( const char* pName, bool* pStatus = NULL ) const
01571 {
01572 FbxString lName( pName );
01573 for( int i = 0; i < mDataNames.GetCount(); ++i )
01574 {
01575 if( *mDataNames[i] == lName )
01576 return GetDirectArrayVoid(i, pStatus);
01577 }
01578
01579 if (pStatus) *pStatus = false;
01580 return (const FbxLayerElementArrayTemplate<void*>*)NULL;
01581 }
01582
01587 FbxDataType GetDataType( int pIndex ) const
01588 {
01589 if( pIndex < 0 || pIndex >= mDataTypes.GetCount() )
01590 return FbxUndefinedDT;
01591
01592 return mDataTypes[pIndex];
01593 }
01594
01599 FbxDataType GetDataType( const char* pName ) const
01600 {
01601 FbxString lName( pName );
01602
01603 for( int i = 0; i < mDataNames.GetCount(); ++i )
01604 {
01605 if( *mDataNames[i] == lName )
01606 return mDataTypes[i];
01607 }
01608
01609 return FbxUndefinedDT;
01610 }
01611
01616 const char* GetDataName( int pIndex ) const
01617 {
01618 if( pIndex >= 0 && pIndex < mDataNames.GetCount() )
01619 return mDataNames[pIndex]->Buffer();
01620
01621 return NULL;
01622 }
01623
01627 void ResizeAllDirectArrays( int pSize )
01628 {
01629 for( int i = 0; i < GetDirectArray().GetCount(); ++i )
01630 {
01631 switch( mDataTypes[i].GetType() )
01632 {
01633 case eFbxBool: FbxGetDirectArray<bool>(this,i).Resize( pSize ) ; break;
01634 case eFbxInt: FbxGetDirectArray<int>(this,i).Resize( pSize ) ; break;
01635 case eFbxFloat: FbxGetDirectArray<float>(this,i).Resize( pSize ) ; break;
01636 case eFbxDouble: FbxGetDirectArray<double>(this,i).Resize( pSize ); break;
01637
01638
01639
01640 default:
01641 FBX_ASSERT_NOW("unknown type" ); break;
01642 }
01643 }
01644 }
01645
01649 void RemoveFromAllDirectArrays( int pIndex )
01650 {
01651 for( int i = 0; i < GetDirectArray().GetCount(); ++i )
01652 {
01653 switch( mDataTypes[i].GetType() )
01654 {
01655 case eFbxBool: FbxGetDirectArray<bool>(this,i).RemoveAt( pIndex ) ; break;
01656 case eFbxInt: FbxGetDirectArray<int>(this,i).RemoveAt( pIndex ) ; break;
01657 case eFbxFloat: FbxGetDirectArray<float>(this,i).RemoveAt( pIndex ) ; break;
01658 case eFbxDouble: FbxGetDirectArray<double>(this,i).RemoveAt( pIndex ); break;
01659
01660
01661
01662 default:
01663 FBX_ASSERT_NOW("unknown type" ); break;
01664 }
01665 }
01666 }
01667
01672 int GetArrayCount( int pIndex ) const
01673 {
01674 if( pIndex >= 0 && pIndex < GetDirectArray().GetCount() )
01675 {
01676 switch( mDataTypes[pIndex].GetType() )
01677 {
01678 case eFbxBool: return FbxGetDirectArray<bool>(this,pIndex).GetCount();
01679 case eFbxInt: return FbxGetDirectArray<int>(this,pIndex).GetCount();
01680 case eFbxFloat: return FbxGetDirectArray<float>(this,pIndex).GetCount();
01681 case eFbxDouble: return FbxGetDirectArray<double>(this,pIndex).GetCount();
01682
01683
01684
01685 default:
01686 FBX_ASSERT_NOW("Unknown type" ); break;
01687 }
01688 }
01689
01690 return -1;
01691 }
01692
01696 int GetId() const { return mId; }
01697
01702 int GetDirectArrayCount() const { return GetDirectArray().GetCount(); }
01703
01708 FbxLayerElementUserData& operator=( FbxLayerElementUserData const& pOther )
01709 {
01710 if (this == &pOther)
01711 return *this;
01712
01713 Clear();
01714
01715 mId = pOther.mId;
01716 mDataTypes = pOther.mDataTypes;
01717 mDataNames.Resize(pOther.mDataNames.GetCount());
01718 for(int i = 0; i < pOther.mDataNames.GetCount(); ++i)
01719 mDataNames.SetAt(i, FbxNew< FbxString >( *pOther.mDataNames[i] ) );
01720
01721 Init();
01722 for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
01723 {
01724 switch (mDataTypes[i].GetType())
01725 {
01726 case eFbxBool:
01727 FbxGetDirectArray<bool>(this, i) = FbxGetDirectArray<bool>(&pOther, i);
01728 break;
01729
01730 case eFbxInt:
01731 FbxGetDirectArray<int>(this, i) = FbxGetDirectArray<int>(&pOther, i);
01732 break;
01733
01734 case eFbxFloat:
01735 FbxGetDirectArray<float>(this, i) = FbxGetDirectArray<float>(&pOther, i);
01736 break;
01737
01738 case eFbxDouble:
01739 FbxGetDirectArray<double>(this, i) = FbxGetDirectArray<double>(&pOther, i);
01740 break;
01741
01742 default:
01743 FBX_ASSERT_NOW("Unknown type" );
01744 break;
01745 }
01746 }
01747
01748 if ( ( mReferenceMode == FbxLayerElement::eIndex ||
01749 mReferenceMode == FbxLayerElement::eIndexToDirect) &&
01750 ( pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
01751 pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect))
01752 {
01753 GetIndexArray() = pOther.GetIndexArray();
01754 }
01755
01756 return *this;
01757 }
01758
01762 bool Clear()
01763 {
01764 int i;
01765 const int lCount = GetDirectArray().GetCount();
01766 FbxLayerElementArray** directArray = NULL;
01767 directArray = GetDirectArray().GetLocked(directArray);
01768 for( i = 0; directArray != NULL && i < lCount; ++i )
01769 {
01770 if( directArray[i] )
01771 FbxDelete(directArray[i]);
01772 }
01773 GetDirectArray().Release((void**)&directArray);
01774
01775 for( i = 0; i < mDataNames.GetCount(); ++i )
01776 {
01777 FBX_SAFE_DELETE(mDataNames[i]);
01778 }
01779 mDataNames.Clear();
01780 mDataTypes.Clear();
01781
01782 FbxLayerElementTemplate<void*>::Clear();
01783
01784 return true;
01785 }
01786
01791 virtual int MemorySize() const
01792 {
01793 int size = FbxLayerElementTemplate<void*>::MemorySize();
01794 size += sizeof(mId);
01795
01796 for(int i = 0; i < mDataTypes.GetCount(); i++)
01797 {
01798 size += sizeof(mDataTypes[i]);
01799 }
01800 size += (mDataNames.GetCount() * sizeof(FbxString*));
01801
01802 return size;
01803 }
01804
01805
01806
01807
01808 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01809 protected:
01819 FbxLayerElementUserData( int pId, FbxArray<FbxDataType>& pDataTypes, FbxArray<const char*>& pDataNames )
01820 :
01821 mId( pId ),
01822 mDataTypes( pDataTypes )
01823 {
01824 FBX_ASSERT( pDataTypes.GetCount() == pDataNames.GetCount() );
01825 for( int i = 0; i < pDataNames.GetCount(); ++i )
01826 {
01827 mDataNames.Add( FbxNew< FbxString >( pDataNames[i] ) );
01828 }
01829 }
01830
01834 FbxLayerElementUserData( FbxLayerElementUserData const& pOther ) : mId(pOther.mId), mDataTypes(pOther.mDataTypes)
01835 {
01836 for (int lIndex = 0; lIndex < pOther.mDataNames.GetCount(); ++lIndex)
01837 {
01838 mDataNames.Add(FbxNew<FbxString>(*(pOther.mDataNames[lIndex])));
01839 }
01840
01841 SetType(&FbxLayerElementUserDataDT);
01842 AllocateArrays();
01843
01844 for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
01845 {
01846 switch (mDataTypes[i].GetType())
01847 {
01848 case eFbxBool:
01849 FbxGetDirectArray<bool>(this, i) = FbxGetDirectArray<bool>(&pOther, i);
01850 break;
01851
01852 case eFbxInt:
01853 FbxGetDirectArray<int>(this, i) = FbxGetDirectArray<int>(&pOther, i);
01854 break;
01855
01856 case eFbxFloat:
01857 FbxGetDirectArray<float>(this, i) = FbxGetDirectArray<float>(&pOther, i);
01858 break;
01859
01860 case eFbxDouble:
01861 FbxGetDirectArray<double>(this, i) = FbxGetDirectArray<double>(&pOther, i);
01862 break;
01863
01864 default:
01865 FBX_ASSERT_NOW("Unknown type" );
01866 break;
01867 }
01868 }
01869
01870 if ( ( mReferenceMode == FbxLayerElement::eIndex ||
01871 mReferenceMode == FbxLayerElement::eIndexToDirect) &&
01872 ( pOther.GetReferenceMode() == FbxLayerElement::eIndex ||
01873 pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect))
01874 {
01875 GetIndexArray() = pOther.GetIndexArray();
01876 }
01877 }
01878
01880 ~FbxLayerElementUserData()
01881 {
01882 Clear();
01883 }
01884
01886 virtual void AllocateArrays()
01887 {
01888 FbxLayerElementTemplate<void*>::AllocateArrays();
01889 Init();
01890 }
01891
01892
01893 private:
01894
01895 void Init()
01896 {
01897 int i;
01898 GetDirectArray().Resize( mDataTypes.GetCount() );
01899
01900
01901 for( i = 0; i < mDataTypes.GetCount(); ++i )
01902 {
01903 FbxHandle** dst = NULL;
01904 dst = GetDirectArray().GetLocked(dst);
01905 if (dst)
01906 {
01907 switch( mDataTypes[i].GetType() )
01908 {
01909 case eFbxBool: dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<bool> >(mDataTypes[i].GetType()); break;
01910 case eFbxInt: dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<int> >(mDataTypes[i].GetType()); break;
01911 case eFbxFloat: dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<float> >(mDataTypes[i].GetType()); break;
01912 case eFbxDouble: dst[i] = (FbxHandle*)FbxNew< FbxLayerElementArrayTemplate<double> >(mDataTypes[i].GetType()); break;
01913 default:
01914 FBX_ASSERT_NOW("Trying to assign an unknown type" ); break;
01915 }
01916 GetDirectArray().Release((void**)&dst);
01917 }
01918 }
01919 }
01920
01921 int mId;
01922 FbxArray<FbxDataType> mDataTypes;
01923 FbxArray<FbxString*> mDataNames;
01924 #endif
01925 };
01926
01934 template <class T>
01935 inline FbxLayerElementArrayTemplate<T>& FbxGetDirectArray( FbxLayerElementUserData *pLayerElement,int pIndex, bool* pStatus)
01936 {
01937 return *(FbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pIndex,pStatus);
01938 }
01939
01947 template <class T>
01948 inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, int pIndex, bool* pStatus)
01949 {
01950 return *(const FbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pIndex,pStatus);
01951 }
01952
01953
01961 template <class T>
01962 inline FbxLayerElementArrayTemplate<T>& FbxGetDirectArray( FbxLayerElementUserData *pLayerElement,const char* pName, bool* pStatus )
01963 {
01964 return *(FbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pName,pStatus);
01965 }
01966
01974 template <class T>
01975 inline FbxLayerElementArrayTemplate<T> const& FbxGetDirectArray(FbxLayerElementUserData const *pLayerElement, const char* pName, bool* pStatus )
01976 {
01977 return *(const FbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pName,pStatus);
01978 }
01979
01980
01987 class FBXSDK_DLL FbxLayerElementSmoothing : public FbxLayerElementTemplate<int>
01988 {
01989 public:
01990 FBXSDK_FRIEND_NEW();
01991
01997 static FbxLayerElementSmoothing* Create(FbxLayerContainer* pOwner, const char* pName);
01998
02003 void SetReferenceMode( FbxLayerElement::EReferenceMode pMode )
02004 {
02005 if( pMode != FbxLayerElement::eDirect )
02006 {
02007 FBX_ASSERT_NOW( "Smoothing layer elements must be direct mapped" );
02008 return;
02009 }
02010 }
02011
02012
02013
02014
02015 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02016 protected:
02017 FbxLayerElementSmoothing()
02018 {
02019 mReferenceMode = FbxLayerElement::eDirect;
02020 }
02021 #endif
02022 };
02023
02027 class FBXSDK_DLL FbxLayerElementCrease : public FbxLayerElementTemplate<double>
02028 {
02029 public:
02030 FBXSDK_FRIEND_NEW();
02031
02037 static FbxLayerElementCrease* Create(FbxLayerContainer* pOwner, const char* pName);
02038
02043 void SetReferenceMode( FbxLayerElement::EReferenceMode pMode )
02044 {
02045 if( pMode != FbxLayerElement::eDirect )
02046 {
02047 FBX_ASSERT_NOW( "Crease layer elements must be direct mapped" );
02048 return;
02049 }
02050 }
02051
02052
02053
02054
02055 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02056 protected:
02057 FbxLayerElementCrease()
02058 {
02059 mReferenceMode = FbxLayerElement::eDirect;
02060 }
02061 #endif
02062 };
02063
02067 class FBXSDK_DLL FbxLayerElementHole : public FbxLayerElementTemplate<bool>
02068 {
02069 public:
02070 FBXSDK_FRIEND_NEW();
02071
02077 static FbxLayerElementHole* Create(FbxLayerContainer* pOwner, const char* pName);
02078
02083 void SetReferenceMode( FbxLayerElement::EReferenceMode pMode )
02084 {
02085 if( pMode != FbxLayerElement::eDirect )
02086 {
02087 FBX_ASSERT_NOW( "hole layer elements must be direct mapped" );
02088 return;
02089 }
02090 }
02091
02092
02093
02094
02095 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02096 protected:
02097 FbxLayerElementHole()
02098 {
02099 mReferenceMode = FbxLayerElement::eDirect;
02100 }
02101 #endif
02102 };
02103
02106 class FBXSDK_DLL FbxLayerElementVisibility : public FbxLayerElementTemplate<bool>
02107 {
02108 public:
02109
02113 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementVisibility);
02114
02115
02116
02117
02118 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02119 protected:
02120 FbxLayerElementVisibility();
02121 ~FbxLayerElementVisibility();
02122 #endif
02123 };
02124
02143 class FBXSDK_DLL FbxLayerElementTexture : public FbxLayerElementTemplate<FbxTexture*>
02144 {
02145 public:
02149 FBXSDK_LAYER_ELEMENT_CREATE_DECLARE(LayerElementTexture);
02150
02185 enum EBlendMode
02186 {
02187 eTranslucent,
02188 eAdd,
02189 eModulate,
02190 eModulate2,
02191 eOver,
02192 eNormal,
02193 eDissolve,
02194 eDarken,
02195 eColorBurn,
02196 eLinearBurn,
02197 eDarkerColor,
02198 eLighten,
02199 eScreen,
02200 eColorDodge,
02201 eLinearDodge,
02202 eLighterColor,
02203 eSoftLight,
02204 eHardLight,
02205 eVividLight,
02206 eLinearLight,
02207 ePinLight,
02208 eHardMix,
02209 eDifference,
02210 eExclusion,
02211 eSubtract,
02212 eDivide,
02213 eHue,
02214 eSaturation,
02215 eColor,
02216 eLuminosity,
02217 eOverlay,
02218 eBlendModeCount
02219 };
02220
02224 void SetBlendMode(EBlendMode pBlendMode) { mBlendMode = pBlendMode; }
02225
02230 void SetAlpha(double pAlpha)
02231 {
02232 if (pAlpha > 1.0)
02233 mAlpha = 1.0;
02234 else if (pAlpha < 0.0)
02235 mAlpha = 0.0;
02236 else
02237 mAlpha = pAlpha;
02238 }
02239
02243 EBlendMode GetBlendMode() const { return mBlendMode; }
02244
02248 double GetAlpha() const { return mAlpha; }
02249
02250
02251
02252
02253 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02254 virtual int MemorySize() const
02255 {
02256 int size = FbxLayerElementTemplate<FbxTexture*>::MemorySize();
02257 size += sizeof(mBlendMode);
02258 size += sizeof(mAlpha);
02259 return size;
02260 }
02261
02262 protected:
02267 FbxLayerElementTexture() : mBlendMode(eTranslucent)
02268 {
02269 mReferenceMode = eIndexToDirect;
02270 mAlpha = 1.0;
02271 }
02272
02273 private:
02274 EBlendMode mBlendMode;
02275 double mAlpha;
02276 #endif
02277 };
02278
02279
02333 class FBXSDK_DLL FbxLayer
02334 {
02335
02336 public:
02337 FBXSDK_FRIEND_NEW();
02338
02343
02348 FbxLayerElementNormal* GetNormals();
02349
02354 const FbxLayerElementNormal* GetNormals() const;
02355
02360 FbxLayerElementTangent* GetTangents();
02361
02366 const FbxLayerElementTangent* GetTangents() const;
02367
02372 FbxLayerElementBinormal* GetBinormals();
02373
02378 const FbxLayerElementBinormal* GetBinormals() const;
02379
02383 FbxLayerElementMaterial* GetMaterials();
02384
02388 const FbxLayerElementMaterial* GetMaterials() const;
02389
02393 FbxLayerElementPolygonGroup* GetPolygonGroups();
02394
02398 const FbxLayerElementPolygonGroup* GetPolygonGroups() const;
02399
02406 FbxLayerElementUV* GetUVs(FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
02407
02414 const FbxLayerElementUV* GetUVs(FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse) const;
02415
02416
02419 int GetUVSetCount() const;
02420
02423 FbxArray<FbxLayerElement::EType> GetUVSetChannels() const;
02424
02427 FbxArray<const FbxLayerElementUV*> GetUVSets() const;
02428
02433 FbxLayerElementVertexColor* GetVertexColors();
02434
02439 const FbxLayerElementVertexColor* GetVertexColors() const;
02440
02445 FbxLayerElementSmoothing* GetSmoothing();
02446
02451 const FbxLayerElementSmoothing* GetSmoothing() const;
02452
02457 FbxLayerElementCrease* GetVertexCrease();
02458
02463 const FbxLayerElementCrease* GetVertexCrease() const;
02464
02469 FbxLayerElementCrease* GetEdgeCrease();
02470
02475 const FbxLayerElementCrease* GetEdgeCrease() const;
02476
02481 FbxLayerElementHole* GetHole();
02482
02487 const FbxLayerElementHole* GetHole() const;
02488
02492 FbxLayerElementUserData* GetUserData();
02493
02497 const FbxLayerElementUserData* GetUserData() const;
02498
02502 FbxLayerElementVisibility* GetVisibility();
02503
02507 const FbxLayerElementVisibility* GetVisibility() const;
02508
02513 FbxLayerElementTexture* GetTextures(FbxLayerElement::EType pType);
02514
02519 const FbxLayerElementTexture* GetTextures(FbxLayerElement::EType pType) const;
02520
02525 void SetTextures(FbxLayerElement::EType pType, FbxLayerElementTexture* pTextures);
02526
02545 FbxLayerElement* GetLayerElementOfType(FbxLayerElement::EType pType, bool pIsUV=false);
02546
02565 const FbxLayerElement* GetLayerElementOfType(FbxLayerElement::EType pType, bool pIsUV=false) const;
02566
02571 void SetNormals(FbxLayerElementNormal* pNormals);
02572
02577 void SetBinormals(FbxLayerElementBinormal* pBinormals);
02578
02583 void SetTangents(FbxLayerElementTangent* pTangents);
02584
02588 void SetMaterials(FbxLayerElementMaterial* pMaterials);
02589
02593 void SetPolygonGroups(FbxLayerElementPolygonGroup* pPolygonGroups);
02594
02601 void SetUVs(FbxLayerElementUV* pUVs, FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
02602
02607 void SetVertexColors (FbxLayerElementVertexColor* pVertexColors);
02608
02613 void SetSmoothing (FbxLayerElementSmoothing* pSmoothing);
02614
02619 void SetVertexCrease (FbxLayerElementCrease* pCrease);
02620
02625 void SetEdgeCrease (FbxLayerElementCrease* pCrease);
02626
02631 void SetHole (FbxLayerElementHole* pHole);
02632
02636 void SetUserData (FbxLayerElementUserData* pUserData);
02637
02641 void SetVisibility( FbxLayerElementVisibility* pVisibility );
02642
02661 void SetLayerElementOfType(FbxLayerElement* pLayerElement, FbxLayerElement::EType pType, bool pIsUV=false);
02662
02669 FbxLayerElement* CreateLayerElementOfType(FbxLayerElement::EType pType, bool pIsUV=false);
02670
02674 void Clone(FbxLayer const& pSrcLayer);
02675
02676
02677
02678
02679 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02680 protected:
02682 FbxLayer& operator=(FbxLayer const& pSrcLayer);
02684 private:
02685
02686 FbxLayer(FbxLayerContainer& pOwner);
02687 virtual ~FbxLayer();
02688
02689 void Clear();
02690
02691 FbxLayerContainer& mOwner;
02692
02693 FbxLayerElement* mNonTexturesArray[FbxLayerElement::sTypeNonTextureCount];
02694 FbxLayerElementUV* mUVsArray[FbxLayerElement::sTypeTextureCount];
02695 FbxLayerElementTexture* mTexturesArray[FbxLayerElement::sTypeTextureCount];
02696
02697
02698 friend class FbxLayerContainer;
02699
02700 public:
02705 bool ContentWriteTo(FbxStream& pStream) const;
02706 bool ContentReadFrom(const FbxStream& pStream);
02708 virtual int MemoryUsage() const;
02709 #endif
02710 };
02711
02715 #define FBXSDK_FOR_EACH_TEXTURE(lLayerIndex) for((lLayerIndex)=0;(lLayerIndex)<FbxLayerElement::sTypeTextureCount;(lLayerIndex)++)
02716
02720 #define FBXSDK_FOR_EACH_NON_TEXTURE(lLayerIndex) for((lLayerIndex)=0;(lLayerIndex)<FbxLayerElement::sTypeNonTextureCount;(lLayerIndex)++)
02721
02725 #define FBXSDK_TEXTURE_INDEX(ElementType) (int(ElementType)-FbxLayerElement::sTypeTextureStartIndex)
02726
02730 #define FBXSDK_TEXTURE_TYPE(TextureIndex) (FbxLayerElement::EType((TextureIndex)+FbxLayerElement::sTypeTextureStartIndex))
02731
02735 #define FBXSDK_NON_TEXTURE_INDEX(ElementType) (int(ElementType)-FbxLayerElement::sTypeNonTextureStartIndex)
02736
02740 #define FBXSDK_NON_TEXTURE_TYPE(Index) (FbxLayerElement::EType((Index)+FbxLayerElement::sTypeNonTextureStartIndex))
02741
02754 typedef FbxLayerElement FbxGeometryElement;
02755 typedef FbxLayerElementNormal FbxGeometryElementNormal;
02756 typedef FbxLayerElementBinormal FbxGeometryElementBinormal;
02757 typedef FbxLayerElementTangent FbxGeometryElementTangent;
02758 typedef FbxLayerElementMaterial FbxGeometryElementMaterial;
02759 typedef FbxLayerElementPolygonGroup FbxGeometryElementPolygonGroup;
02760 typedef FbxLayerElementUV FbxGeometryElementUV;
02761 typedef FbxLayerElementVertexColor FbxGeometryElementVertexColor;
02762 typedef FbxLayerElementUserData FbxGeometryElementUserData;
02763 typedef FbxLayerElementSmoothing FbxGeometryElementSmoothing;
02764 typedef FbxLayerElementCrease FbxGeometryElementCrease;
02765 typedef FbxLayerElementHole FbxGeometryElementHole;
02766 typedef FbxLayerElementVisibility FbxGeometryElementVisibility;
02767
02768 #undef FBXSDK_LAYER_ELEMENT_CREATE_DECLARE
02769
02770 #include <fbxsdk/fbxsdk_nsend.h>
02771
02772 #endif