00001
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXLAYER_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXLAYER_H
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <fbxfilesdk/components/kbaselib/kaydara.h>
00044
00045 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00046 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00047 #include <fbxfilesdk/components/kbaselib/klib/kdebug.h>
00048
00049 #include <fbxfilesdk/kfbxmath/kfbxvector2.h>
00050 #include <fbxfilesdk/kfbxmath/kfbxvector4.h>
00051 #include <fbxfilesdk/kfbxplugins/kfbxcolor.h>
00052 #include <fbxfilesdk/kfbxplugins/kfbxdatatypes.h>
00053 #include <fbxfilesdk/kfbxplugins/kfbxstream.h>
00054
00055 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00056
00057 class KFbxTexture;
00058 class KFbxSurfaceMaterial;
00059 class KFbxSdkManager;
00060
00061 class KFbxGeometryBase;
00062 class KFbxLayer;
00063 class KFbxLayerContainer;
00064 class KFbxMesh;
00065 class KFbxNode;
00066 class KFbxReader3DS;
00067 class KFbxReaderObj;
00068
00069
00070
00071
00077 class KFBX_DLL KFbxLayerElement
00078 {
00079
00080 public:
00081
00114 typedef enum
00115 {
00116 eUNDEFINED,
00117
00118
00119 eNORMAL,
00120 eBINORMAL,
00121 eTANGENT,
00122 eMATERIAL,
00123 ePOLYGON_GROUP,
00124 eUV,
00125 eVERTEX_COLOR,
00126 eSMOOTHING,
00127 eVERTEX_CREASE,
00128 eEDGE_CREASE,
00129 eUSER_DATA,
00130 eVISIBILITY,
00131
00132
00133
00134
00135
00136 eDIFFUSE_TEXTURES,
00137 eDIFFUSE_FACTOR_TEXTURES,
00138 eEMISSIVE_TEXTURES,
00139 eEMISSIVE_FACTOR_TEXTURES,
00140 eAMBIENT_TEXTURES,
00141 eAMBIENT_FACTOR_TEXTURES,
00142 eSPECULAR_TEXTURES,
00143 eSPECULAR_FACTOR_TEXTURES,
00144 eSHININESS_TEXTURES,
00145 eNORMALMAP_TEXTURES,
00146 eBUMP_TEXTURES,
00147 eTRANSPARENT_TEXTURES,
00148 eTRANSPARENCY_FACTOR_TEXTURES,
00149 eREFLECTION_TEXTURES,
00150 eREFLECTION_FACTOR_TEXTURES,
00151 eDISPLACEMENT_TEXTURES,
00152
00153
00154
00155
00156
00157 eLAST_ELEMENT_TYPE
00158 } ELayerElementType;
00159
00160
00161
00163 const static int LAYERELEMENT_TYPE_TEXTURE_START_INDEX = int(eDIFFUSE_TEXTURES);
00164
00166 const static int LAYERELEMENT_TYPE_TEXTURE_END_INDEX = int(eDISPLACEMENT_TEXTURES);
00167
00169 const static int LAYERELEMENT_TYPE_TEXTURE_COUNT = int(eLAST_ELEMENT_TYPE - eDIFFUSE_TEXTURES);
00170
00172 const static int LAYERELEMENT_TYPE_NON_TEXTURE_START_INDEX = int(eNORMAL);
00173
00175 const static int LAYERELEMENT_TYPE_NON_TEXTURE_END_INDEX = int(eVISIBILITY);
00176
00178 const static int LAYERELEMENT_TYPE_NON_TEXTURE_COUNT = int(eDIFFUSE_TEXTURES - eUNDEFINED - 1);
00179
00180
00181
00183 static const char* TEXTURE_NAMES[];
00184
00186 static const char* TEXTURE_UV_NAMES[];
00187
00189 static const char* NON_TEXTURE_NAMES[];
00190
00192 static KFbxDataType TEXTURE_TYPES[];
00193
00195 static const char* TEXTURE_CHANNEL_NAMES[];
00196
00207 typedef enum
00208 {
00209 eNONE,
00210 eBY_CONTROL_POINT,
00211 eBY_POLYGON_VERTEX,
00212 eBY_POLYGON,
00213 eBY_EDGE,
00214 eALL_SAME
00215 } EMappingMode;
00216
00230 typedef enum
00231 {
00232 eDIRECT,
00233 eINDEX,
00234 eINDEX_TO_DIRECT
00235 } EReferenceMode;
00236
00237
00241 void SetMappingMode(EMappingMode pMappingMode) { mMappingMode = pMappingMode; }
00242
00246 void SetReferenceMode(EReferenceMode pReferenceMode) { mReferenceMode = pReferenceMode; }
00247
00251 EMappingMode GetMappingMode() const { return mMappingMode; }
00252
00256 EReferenceMode GetReferenceMode() const { return mReferenceMode; }
00257
00261 void SetName(const char* pName) { mName = KString(pName); }
00262
00266 const char* GetName() const { return ((KFbxLayerElement*)this)->mName.Buffer(); }
00267
00272 bool operator==(const KFbxLayerElement& pOther) const
00273 {
00274 return (mName == pOther.mName) &&
00275 (mMappingMode == pOther.mMappingMode) &&
00276 (mReferenceMode == pOther.mReferenceMode);
00277 }
00278
00283 KFbxLayerElement& operator=( KFbxLayerElement const& pOther )
00284 {
00285 mMappingMode = pOther.mMappingMode;
00286 mReferenceMode = pOther.mReferenceMode;
00287
00288
00289 return *this;
00290 }
00291
00293 void Destroy();
00294
00296 virtual bool Clear()
00297 {
00298 return true;
00299 }
00300
00302
00303
00304
00305
00306
00307
00309
00310 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00311 void SetType(KFbxDataType* pType) { mType = pType; }
00312 const KFbxLayerContainer* GetOwner() const { return mOwner; }
00313
00314 protected:
00315 KFbxLayerElement()
00316 : mMappingMode(eNONE)
00317 , mReferenceMode(eDIRECT)
00318 , mName("")
00319 , mOwner(NULL)
00320 {
00321 }
00322
00323 virtual ~KFbxLayerElement()
00324 {
00325 }
00326
00327 EMappingMode mMappingMode;
00328 EReferenceMode mReferenceMode;
00329
00330 KString mName;
00331 KFbxDataType* mType;
00332 KFbxLayerContainer* mOwner;
00333
00334 void Destruct() { delete this; }
00335 virtual void SetOwner(KFbxLayerContainer* pOwner);
00336
00337 friend class KFbxLayerContainer;
00338
00339 public:
00344 virtual int MemorySize() const { return 0; }
00345
00350
00356 virtual bool ContentWriteTo(KFbxStream& pStream) const;
00357
00363 virtual bool ContentReadFrom(const KFbxStream& pStream);
00365
00366 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00367 };
00368
00373 class KFBX_DLL LockAccessStatus
00374 {
00375 public:
00387 typedef enum {
00388 eSuccess,
00389 eUnsupportedDTConversion,
00390 eCorruptedCopyback,
00391 eBadValue,
00392 eLockMismatch,
00393 eNoWriteLock,
00394 eNoReadLock,
00395 eNotOwner,
00396 eDirectLockExist
00397 } ELockAccessStatus;
00398 };
00399
00405 class KFBX_DLL KFbxLayerElementArray
00406 {
00407 public:
00412
00416 KFbxLayerElementArray(EFbxType pDataType);
00417
00419 virtual ~KFbxLayerElementArray();
00420
00422
00427
00429 inline void ClearStatus() { mStatus = LockAccessStatus::eSuccess; }
00430
00432 inline LockAccessStatus::ELockAccessStatus GetStatus() const { return mStatus; }
00434
00439
00443 inline bool IsWriteLocked() const { return mWriteLock; };
00444
00448 inline int GetReadLockCount() const { return mReadLockCount; }
00450
00454 bool IsInUse() const;
00455
00459 int ReadLock() const;
00460
00464 int ReadUnlock() const;
00465
00470 bool WriteLock() const;
00471
00474 void WriteUnlock() const;
00475
00480 bool ReadWriteLock() const;
00481
00484 void ReadWriteUnlock() const;
00485
00486
00492 typedef enum {
00493 eREAD_LOCK = 1,
00494 eWRITE_LOCK = 2,
00495 eREADWRITE_LOCK = 3
00496 } ELockMode;
00497
00510 virtual void* GetLocked(ELockMode pLockMode, EFbxType pDataType);
00511
00523 void* GetLocked(ELockMode pLockMode=eREADWRITE_LOCK) { return GetLocked(pLockMode, mDataType); }
00524
00537 template <class T> inline T* GetLocked(T* dummy=NULL, ELockMode pLockMode=eREADWRITE_LOCK) {T v; return (T*)GetLocked(pLockMode, _FbxTypeOf(v)); }
00538
00549 virtual void Release(void** pDataPtr, EFbxType pDataType);
00550
00560 void Release(void** pDataPtr) { Release(pDataPtr, mDataType); }
00561
00572 template <class T> inline void Release(T** pDataPtr, T* dummy) { Release((void**)pDataPtr, _FbxTypeOf(*dummy)); }
00573
00576 virtual size_t GetStride() const;
00577
00582
00584 int GetCount() const;
00585
00589 void SetCount(int pCount);
00590
00592 void Clear();
00593
00597 void Resize(int pItemCount);
00598
00602 void AddMultiple(int pItemCount);
00603
00609 int Add(void const* pItem, EFbxType pValueType);
00610
00617 int InsertAt(int pIndex, void const* pItem, EFbxType pValueType);
00618
00624 void SetAt(int pIndex, void const* pItem, EFbxType pValueType);
00625
00626
00631 void SetLast(void const* pItem, EFbxType pValueType);
00632
00638 void RemoveAt(int pIndex, void** pItem, EFbxType pValueType);
00639
00644 void RemoveLast(void** pItem, EFbxType pValueType);
00645
00651 bool RemoveIt(void** pItem, EFbxType pValueType);
00652
00660 bool GetAt(int pIndex, void** pItem, EFbxType pValueType) const;
00661
00667 bool GetFirst(void** pItem, EFbxType pValueType) const;
00668
00674 bool GetLast(void** pItem, EFbxType pValueType) const;
00675
00682 int Find(void const* pItem, EFbxType pValueType) const;
00683
00691 int FindAfter(int pAfterIndex, void const* pItem, EFbxType pValueType) const;
00692
00700 int FindBefore(int pBeforeIndex, void const* pItem, EFbxType pValueType) const;
00701
00706 bool IsEqual(const KFbxLayerElementArray& pArray);
00707
00712 template <class T> inline int Add(T const& pItem) { return Add((void const*)&pItem, _FbxTypeOf(pItem)); }
00713
00719 template <class T> inline int InsertAt(int pIndex, T const& pItem) { return InsertAt(pIndex, (void const*)&pItem, _FbxTypeOf(pItem)); }
00720
00725 template <class T> inline void SetAt(int pIndex, T const& pItem) { SetAt(pIndex, (void const*)&pItem, _FbxTypeOf(pItem)); }
00726
00730 template <class T> inline void SetLast(T const& pItem) { SetLast((void const*)&pItem, _FbxTypeOf(pItem)); }
00731
00736 template <class T> inline void RemoveAt(int pIndex, T* pItem) { RemoveAt(pIndex, (void**)&pItem, _FbxTypeOf(*pItem)); }
00737
00741 template <class T> inline void RemoveLast(T* pItem) { RemoveLast((void**)&pItem, _FbxTypeOf(*pItem)); }
00742
00747 template <class T> inline bool RemoveIt(T* pItem) { return RemoveIt((void**)&pItem, _FbxTypeOf(*pItem)); }
00748
00755 template <class T> inline bool GetAt(int pIndex, T* pItem) const { return GetAt(pIndex, (void**)&pItem, _FbxTypeOf(*pItem)); }
00756
00761 template <class T> inline bool GetFirst(T* pItem) const { return GetFirst((void**)&pItem, _FbxTypeOf(*pItem)); }
00762
00767 template <class T> inline bool GetLast(T* pItem) const { return GetLast((void**)&pItem, _FbxTypeOf(*pItem)); }
00768
00774 template <class T> inline int Find(T const& pItem) const { return Find((void const*)&pItem, _FbxTypeOf(pItem)); }
00775
00782 template <class T> inline int FindAfter(int pAfterIndex, T const& pItem) const { return FindAfter(pAfterIndex, (void const*)&pItem, _FbxTypeOf(pItem)); }
00783
00790 template <class T> inline int FindBefore(int pBeforeIndex, T const& pItem) const { return FindBefore(pBeforeIndex, (void const*)&pItem, _FbxTypeOf(pItem)); }
00791
00792
00796 template<typename T> inline void CopyTo(KArrayTemplate<T>& pDst)
00797 {
00798 T src;
00799 T* srcPtr = &src;
00800
00801 pDst.Clear();
00802 if (mDataType != _FbxTypeOf(src))
00803 {
00804 SetStatus(LockAccessStatus::eUnsupportedDTConversion);
00805 return;
00806 }
00807
00808 pDst.SetCount(GetCount());
00809 for (int i = 0; i < GetCount(); i++)
00810 {
00811 if (GetAt(i, (void**)&srcPtr, mDataType))
00812 {
00813 pDst.SetAt(i, src);
00814 }
00815 }
00816 SetStatus(LockAccessStatus::eSuccess);
00817 }
00819
00820 protected:
00821 void* GetDataPtr();
00822 void* GetReference(int pIndex, EFbxType pValueType);
00823 void GetReferenceTo(int pIndex, void** pRef, EFbxType pValueType);
00824
00825 inline void SetStatus(LockAccessStatus::ELockAccessStatus pVal) const
00826 {
00827 const_cast<KFbxLayerElementArray*>(this)->mStatus = pVal;
00828 }
00829
00830 void SetImplementation(void* pImplementation);
00831 inline void* GetImplementation() { return mImplementation; }
00832 virtual void ConvertDataType(EFbxType pDataType, void** pDataPtr, size_t* pStride);
00833
00834 EFbxType mDataType;
00835
00836 private:
00837 LockAccessStatus::ELockAccessStatus mStatus;
00838
00839 int mReadLockCount;
00840 bool mWriteLock;
00841 void* mImplementation;
00842 size_t mStride;
00843 int mDirectLockOn;
00844 bool mDirectAccessOn;
00845
00846 KArrayTemplate<void*> mConvertedData;
00847
00848 };
00849
00850 template <typename T>
00851 struct KFbxLayerElementArrayReadLock
00852 {
00853 KFbxLayerElementArrayReadLock(KFbxLayerElementArray& pArray)
00854 : mArray(pArray)
00855 {
00856 mLockedData = mArray.GetLocked((T*)NULL, KFbxLayerElementArray::eREAD_LOCK);
00857 }
00858
00859 ~KFbxLayerElementArrayReadLock()
00860 {
00861 if( mLockedData )
00862 {
00863 mArray.Release((void **) &mLockedData);
00864 }
00865 }
00866
00867 const T* GetData() const
00868 {
00869 return mLockedData;
00870 }
00871
00872 private:
00873 KFbxLayerElementArray& mArray;
00874 T* mLockedData;
00875 };
00876
00877 class KFbxLayerElementUserData;
00878
00883 template <class T> class KFbxLayerElementArrayTemplate : public KFbxLayerElementArray
00884 {
00885 public:
00886
00890 KFbxLayerElementArrayTemplate(EFbxType pDataType) :
00891 KFbxLayerElementArray(pDataType)
00892 {
00893 }
00894
00899 inline int Add( T const &pItem ) { return KFbxLayerElementArray::Add(pItem); }
00900
00906 inline int InsertAt(int pIndex, T const &pItem) { return KFbxLayerElementArray::InsertAt(pIndex, pItem); }
00907
00912 inline void SetAt(int pIndex, T const &pItem) { KFbxLayerElementArray::SetAt(pIndex, pItem); }
00913
00917 inline void SetLast( T const &pItem) { KFbxLayerElementArray::SetLast(pItem); }
00918
00923 inline T RemoveAt(int pIndex) { T lValue; KFbxLayerElementArray::RemoveAt(pIndex, &lValue); return lValue; }
00924
00928 inline T RemoveLast() { T lValue; KFbxLayerElementArray::RemoveLast(&lValue); return lValue; }
00929
00934 inline bool RemoveIt(T const &pItem) { return KFbxLayerElementArray::RemoveIt(&pItem); }
00935
00941 inline T GetAt(int pIndex) const { T lValue; KFbxLayerElementArray::GetAt(pIndex, &lValue); return lValue; }
00942
00946 inline T GetFirst() const { T lValue; KFbxLayerElementArray::GetFirst(&lValue); return lValue; }
00947
00951 inline T GetLast() const { T lValue; KFbxLayerElementArray::GetLast(&lValue); return lValue; }
00952
00958 inline int Find(T const &pItem) { return KFbxLayerElementArray::Find(pItem); }
00959
00966 inline int FindAfter(int pAfterIndex, T const &pItem) { return KFbxLayerElementArray::FindAfter(pAfterIndex, pItem); }
00967
00974 inline int FindBefore(int pBeforeIndex, T const &pItem) { return KFbxLayerElementArray::FindBefore(pBeforeIndex, pItem); }
00975
00981 T operator[](int pIndex) const { T lValue; KFbxLayerElementArray::GetAt(pIndex, &lValue); return lValue; }
00982
00986 KFbxLayerElementArray& operator=(const KArrayTemplate<T>& pArrayTemplate)
00987 {
00988 SetStatus(LockAccessStatus::eNoWriteLock);
00989 if (WriteLock())
00990 {
00991 SetCount(pArrayTemplate.GetCount());
00992 for (int i = 0; i < pArrayTemplate.GetCount(); i++)
00993 SetAt(i, pArrayTemplate.GetAt(i));
00994 WriteUnlock();
00995 SetStatus(LockAccessStatus::eSuccess);
00996 }
00997 return *this;
00998 }
00999
01003 KFbxLayerElementArrayTemplate<T>& operator=(const KFbxLayerElementArrayTemplate<T>& pArrayTemplate)
01004 {
01005 SetStatus(LockAccessStatus::eNoWriteLock);
01006 if (WriteLock())
01007 {
01008 SetCount(pArrayTemplate.GetCount());
01009 for (int i = 0; i < pArrayTemplate.GetCount(); i++)
01010 SetAt(i, pArrayTemplate.GetAt(i));
01011 WriteUnlock();
01012 SetStatus(LockAccessStatus::eSuccess);
01013 }
01014 return *this;
01015 }
01016
01017 private:
01018
01019
01020
01021 friend class KFbxLayerElementUserData;
01022 T& AsReference(int pIndex) { T* v = (T*)KFbxLayerElementArray::GetReference(pIndex, mDataType); return (v)?*v:dummy;}
01023
01024 T dummy;
01025 };
01026
01027
01028 extern int RemapIndexArrayTo(KFbxLayerElement* pLayerEl,
01029 KFbxLayerElement::EMappingMode pNewMapping,
01030 KFbxLayerElementArrayTemplate<int>* pIndexArray);
01031
01032
01037 template <class Type> class KFbxLayerElementTemplate : public KFbxLayerElement
01038 {
01039 public:
01040
01045 KFbxLayerElementArrayTemplate<Type>& GetDirectArray() const
01046 {
01047 K_ASSERT(mReferenceMode == KFbxLayerElement::eDIRECT || mReferenceMode == KFbxLayerElement::eINDEX_TO_DIRECT);
01048 return *mDirectArray;
01049 }
01050
01055 KFbxLayerElementArrayTemplate<Type>& GetDirectArray()
01056 {
01057 K_ASSERT(mReferenceMode == KFbxLayerElement::eDIRECT || mReferenceMode == KFbxLayerElement::eINDEX_TO_DIRECT);
01058 return *mDirectArray;
01059 }
01060
01065 KFbxLayerElementArrayTemplate<int>& GetIndexArray() const
01066 {
01067 K_ASSERT(mReferenceMode == KFbxLayerElement::eINDEX || mReferenceMode == KFbxLayerElement::eINDEX_TO_DIRECT);
01068 return *mIndexArray;
01069 }
01070
01075 KFbxLayerElementArrayTemplate<int>& GetIndexArray()
01076 {
01077 K_ASSERT(mReferenceMode == KFbxLayerElement::eINDEX || mReferenceMode == KFbxLayerElement::eINDEX_TO_DIRECT);
01078 return *mIndexArray;
01079 }
01080
01085 bool Clear()
01086 {
01087 bool ret = true;
01088 mDirectArray->Clear();
01089 ret = (mDirectArray->GetStatus() == LockAccessStatus::eSuccess);
01090
01091 mIndexArray->Clear();
01092 ret |= (mIndexArray->GetStatus() == LockAccessStatus::eSuccess);
01093
01094 return ret;
01095 }
01096
01097 public:
01098
01103 bool operator==(const KFbxLayerElementTemplate& pOther) const
01104 {
01105 bool ret = true;
01106
01107 if (pOther.GetReferenceMode() == KFbxLayerElement::eDIRECT ||
01108 pOther.GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT)
01109 {
01110 const KFbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
01111 if( directArray.GetCount() != mDirectArray->GetCount() ||
01112 !directArray.ReadLock() || !mDirectArray->ReadLock() )
01113 {
01114 ret = false;
01115 }
01116
01117 if( ret && !mDirectArray->IsEqual(directArray) )
01118 ret = false;
01119
01120 directArray.ReadUnlock();
01121 mDirectArray->ReadUnlock();
01122 }
01123
01124 if (ret)
01125 {
01126 if (pOther.GetReferenceMode() == KFbxLayerElement::eINDEX ||
01127 pOther.GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT)
01128 {
01129 const KFbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
01130 if( indexArray.GetCount() != mIndexArray->GetCount() ||
01131 !indexArray.ReadLock() || !mIndexArray->ReadLock() )
01132 {
01133 ret = false;
01134 }
01135
01136 if( ret && !mIndexArray->IsEqual(indexArray) )
01137 ret = false;
01138
01139 indexArray.ReadUnlock();
01140 mIndexArray->ReadUnlock();
01141 }
01142 }
01143
01144 if (ret == false)
01145 return false;
01146
01147 return KFbxLayerElement::operator==(pOther);
01148 }
01149
01153 KFbxLayerElementTemplate& operator=( KFbxLayerElementTemplate const& pOther )
01154 {
01155 K_ASSERT(mDirectArray != NULL);
01156 K_ASSERT(mIndexArray != NULL);
01157
01158 if (pOther.GetReferenceMode() == KFbxLayerElement::eDIRECT ||
01159 pOther.GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT)
01160 {
01161 const KFbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
01162 *mDirectArray = directArray;
01163 }
01164
01165 if (pOther.GetReferenceMode() == KFbxLayerElement::eINDEX ||
01166 pOther.GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT)
01167 {
01168 const KFbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
01169 *mIndexArray = indexArray;
01170 }
01171
01172 KFbxLayerElement* myself = (KFbxLayerElement*)this;
01173 KFbxLayerElement* myOther = (KFbxLayerElement*)&pOther;
01174 *myself = *myOther;
01175 return *this;
01176 }
01177
01185 int RemapIndexTo(KFbxLayerElement::EMappingMode pNewMapping)
01186 {
01187 return RemapIndexArrayTo(this, pNewMapping, mIndexArray);
01188 }
01189
01191
01192
01193
01194
01195
01196
01198
01199 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01200 protected:
01201 KFbxLayerElementTemplate()
01202 {
01203 mDirectArray = NULL;
01204 mIndexArray = NULL;
01205 }
01206
01207 ~KFbxLayerElementTemplate()
01208 {
01209 delete mDirectArray;
01210 delete mIndexArray;
01211 }
01212
01213 virtual void AllocateArrays()
01214 {
01215 mDirectArray = new KFbxLayerElementArrayTemplate<Type>(mType->GetType());
01216 mIndexArray = new KFbxLayerElementArrayTemplate<int>(DTInteger.GetType());
01217 }
01218
01219 public:
01220 virtual int MemorySize() const
01221 {
01222 int size = KFbxLayerElement::MemorySize();
01223 size += (mDirectArray->GetCount()*sizeof(Type));
01224 size += (mIndexArray->GetCount()*sizeof(int));
01225 return size;
01226 }
01227
01232 virtual bool ContentWriteTo(KFbxStream& pStream) const
01233 {
01234 void* a;
01235 int s,v;
01236 int count = 0;
01237
01238
01239 count = mDirectArray->GetCount();
01240 s = pStream.Write(&count, sizeof(int));
01241 if (s != sizeof(int)) return false;
01242 if (count > 0)
01243 {
01244 a = mDirectArray->GetLocked();
01245 K_ASSERT(a != NULL);
01246 v = count*sizeof(Type);
01247 s = pStream.Write(a, v);
01248 mDirectArray->Release(&a);
01249 if (s != v) return false;
01250 }
01251
01252
01253 count = mIndexArray->GetCount();
01254 s = pStream.Write(&count, sizeof(int));
01255 if (s != sizeof(int)) return false;
01256 if (count > 0)
01257 {
01258 a = mIndexArray->GetLocked();
01259 K_ASSERT(a != NULL);
01260 v = count*sizeof(int);
01261 s = pStream.Write(a, v);
01262 mIndexArray->Release(&a);
01263 if (s != v) return false;
01264 }
01265
01266 return KFbxLayerElement::ContentWriteTo(pStream);
01267 }
01268
01269 virtual bool ContentReadFrom(const KFbxStream& pStream)
01270 {
01271 void* a;
01272 int s,v;
01273 int count = 0;
01274
01275
01276 s = pStream.Read(&count, sizeof(int));
01277 if (s != sizeof(int)) return false;
01278 mDirectArray->Resize(count);
01279 if (count > 0)
01280 {
01281 a = mDirectArray->GetLocked();
01282 K_ASSERT(a != NULL);
01283 v = count*sizeof(Type);
01284 s = pStream.Read(a, v);
01285 mDirectArray->Release(&a);
01286 if (s != v) return false;
01287 }
01288
01289
01290 s = pStream.Read(&count, sizeof(int));
01291 if (s != sizeof(int)) return false;
01292 mIndexArray->Resize(count);
01293 if (count > 0)
01294 {
01295 a = mIndexArray->GetLocked();
01296 K_ASSERT(a != NULL);
01297 v = count*sizeof(int);
01298 s = pStream.Read(a, v);
01299 mIndexArray->Release(&a);
01300 if (s != v) return false;
01301 }
01302 return KFbxLayerElement::ContentReadFrom(pStream);
01303 }
01305
01306 KFbxLayerElementArrayTemplate<Type>* mDirectArray;
01307 KFbxLayerElementArrayTemplate<int>* mIndexArray;
01308 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
01309 };
01310
01311 #define CREATE_DECLARE(classDesc) \
01312 static KFbx##classDesc* Create(KFbxLayerContainer* pOwner, char const *pName);
01313
01317 class KFBX_DLL KFbxLayerElementNormal : public KFbxLayerElementTemplate<KFbxVector4>
01318 {
01319 public:
01320
01324 CREATE_DECLARE(LayerElementNormal);
01325
01326 protected:
01327 KFbxLayerElementNormal();
01328 ~KFbxLayerElementNormal();
01329 };
01330
01334 class KFBX_DLL KFbxLayerElementBinormal : public KFbxLayerElementTemplate<KFbxVector4>
01335 {
01336 public:
01337
01341 CREATE_DECLARE(LayerElementBinormal);
01342
01343 protected:
01344 KFbxLayerElementBinormal();
01345 ~KFbxLayerElementBinormal();
01346 };
01347
01351 class KFBX_DLL KFbxLayerElementTangent : public KFbxLayerElementTemplate<KFbxVector4>
01352 {
01353 public:
01354
01358 CREATE_DECLARE(LayerElementTangent);
01359
01360 protected:
01361 KFbxLayerElementTangent();
01362 ~KFbxLayerElementTangent();
01363 };
01364
01368 class KFBX_DLL KFbxLayerElementMaterial : public KFbxLayerElementTemplate<KFbxSurfaceMaterial*>
01369 {
01370 public:
01371 typedef KFbxLayerElementTemplate<KFbxSurfaceMaterial*> ParentClass;
01372
01376 CREATE_DECLARE(LayerElementMaterial);
01377
01378 class LayerElementArrayProxy : public KFbxLayerElementArrayTemplate<KFbxSurfaceMaterial*>
01379 {
01380 public:
01381 typedef KFbxLayerElementArrayTemplate<KFbxSurfaceMaterial*> ParentClass;
01382
01383 LayerElementArrayProxy(EFbxType pType);
01384 void SetContainer( KFbxLayerContainer* pContainer, int pInstance = 0);
01385 };
01386
01387
01389
01390
01391
01392
01393
01394
01396 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01397
01398 virtual void AllocateArrays();
01399 virtual void SetOwner( KFbxLayerContainer* pOwner, int pInstance = 0);
01400 virtual void SetInstance( int pInstance ) { SetOwner( mOwner, pInstance ); }
01401
01402 protected:
01403 KFbxLayerElementMaterial();
01404 ~KFbxLayerElementMaterial();
01405
01406 #endif //DOXYGEN_SHOULD_SKIP_THIS
01407 };
01408
01412 class KFBX_DLL KFbxLayerElementPolygonGroup : public KFbxLayerElementTemplate<int>
01413 {
01414 public:
01415
01419 CREATE_DECLARE(LayerElementPolygonGroup);
01420
01421 protected:
01422 KFbxLayerElementPolygonGroup();
01423 ~KFbxLayerElementPolygonGroup();
01424 };
01425
01429 class KFBX_DLL KFbxLayerElementUV : public KFbxLayerElementTemplate<KFbxVector2>
01430 {
01431 public:
01435 CREATE_DECLARE(LayerElementUV);
01436
01437 protected:
01438 KFbxLayerElementUV();
01439 ~KFbxLayerElementUV();
01440 };
01441
01445 class KFBX_DLL KFbxLayerElementVertexColor : public KFbxLayerElementTemplate<KFbxColor>
01446 {
01447 public:
01448
01452 CREATE_DECLARE(LayerElementVertexColor);
01453
01454 protected:
01455 KFbxLayerElementVertexColor();
01456 ~KFbxLayerElementVertexColor();
01457 };
01458
01461 const int kNoMapping = -1;
01462
01463 template <class T> inline KFbxLayerElementArrayTemplate<T>& KFbxGetDirectArray(KFbxLayerElementUserData *pLayerElement, int pIndex, bool* pStatus = NULL);
01464 template <class T> inline KFbxLayerElementArrayTemplate<T> const& KFbxGetDirectArray(KFbxLayerElementUserData const *pLayerElement, int pIndex, bool* pStatus = NULL);
01465 template <class T> inline KFbxLayerElementArrayTemplate<T>& KFbxGetDirectArray(KFbxLayerElementUserData *pLayerElement, const char* pName, bool* pStatus = NULL );
01466 template <class T> inline KFbxLayerElementArrayTemplate<T> const& KFbxGetDirectArray(KFbxLayerElementUserData const *pLayerElement, const char* pName, bool* pStatus = NULL );
01467
01473 class KFBX_DLL KFbxLayerElementUserData : public KFbxLayerElementTemplate<void*>
01474 {
01475 public:
01476
01486 static KFbxLayerElementUserData* Create(KFbxLayerContainer* pOwner, char const *pName, int pId, KArrayTemplate<KFbxDataType>& pDataTypes, KArrayTemplate<const char*>& pDataNames);
01487
01493 static KFbxLayerElementUserData* Create(KFbxLayerContainer* pOwner, KFbxLayerElementUserData const& pOther );
01494
01500 KFbxLayerElementArrayTemplate<void*>* GetDirectArrayVoid( int pIndex, bool* pStatus = NULL)
01501 {
01502 if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
01503 {
01504 if (pStatus) *pStatus = true;
01505 return (KFbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
01506 }
01507 else
01508 {
01509 if( pStatus ) *pStatus = false;
01510 K_ASSERT_MSG_NOW("Index out of bounds");
01511 return (KFbxLayerElementArrayTemplate<void*>*)NULL;
01512 }
01513 }
01514
01520 KFbxLayerElementArrayTemplate<void*> const* GetDirectArrayVoid( int pIndex, bool* pStatus = NULL) const
01521 {
01522 if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
01523 {
01524 if (pStatus) *pStatus = true;
01525 return (KFbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
01526 }
01527 else
01528 {
01529 if( pStatus ) *pStatus = false;
01530 K_ASSERT_MSG_NOW("Index out of bounds");
01531 return (KFbxLayerElementArrayTemplate<void*> const*)NULL;
01532 }
01533 }
01534
01535
01541 KFbxLayerElementArrayTemplate<void *>* GetDirectArrayVoid ( const char* pName, bool* pStatus = NULL )
01542 {
01543 KString lName( pName );
01544 for( int i = 0; i < mDataNames.GetCount(); ++i )
01545 {
01546 if( *mDataNames[i] == lName )
01547 return GetDirectArrayVoid(i, pStatus);
01548 }
01549
01550 if (pStatus) *pStatus = false;
01551 return (KFbxLayerElementArrayTemplate<void *>*)NULL;
01552 }
01553
01559 KFbxLayerElementArrayTemplate<void *> const* GetDirectArrayVoid ( const char* pName, bool* pStatus = NULL ) const
01560 {
01561 KString lName( pName );
01562 for( int i = 0; i < mDataNames.GetCount(); ++i )
01563 {
01564 if( *mDataNames[i] == lName )
01565 return GetDirectArrayVoid(i, pStatus);
01566 }
01567
01568 if (pStatus) *pStatus = false;
01569 return (KFbxLayerElementArrayTemplate<void *> const*)NULL;
01570 }
01571
01576 KFbxDataType GetDataType( int pIndex ) const
01577 {
01578 if( pIndex < 0 || pIndex >= mDataTypes.GetCount() )
01579 return DTNone;
01580
01581 return mDataTypes[pIndex];
01582 }
01583
01588 KFbxDataType GetDataType( const char* pName ) const
01589 {
01590 KString lName( pName );
01591
01592 for( int i = 0; i < mDataNames.GetCount(); ++i )
01593 {
01594 if( *mDataNames[i] == lName )
01595 return mDataTypes[i];
01596 }
01597
01598 return DTNone;
01599 }
01600
01605 const char* GetDataName( int pIndex ) const
01606 {
01607 if( pIndex >= 0 && pIndex < mDataNames.GetCount() )
01608 return mDataNames[pIndex]->Buffer();
01609
01610 return NULL;
01611 }
01612
01616 void ResizeAllDirectArrays( int pSize )
01617 {
01618 for( int i = 0; i < GetDirectArray().GetCount(); ++i )
01619 {
01620 switch( mDataTypes[i].GetType() )
01621 {
01622 case eBOOL1: KFbxGetDirectArray<bool>(this,i).Resize( pSize ) ; break;
01623 case eINTEGER1: KFbxGetDirectArray<int>(this,i).Resize( pSize ) ; break;
01624 case eFLOAT1: KFbxGetDirectArray<float>(this,i).Resize( pSize ) ; break;
01625 case eDOUBLE1: KFbxGetDirectArray<double>(this,i).Resize( pSize ); break;
01626
01627
01628
01629 default:
01630 K_ASSERT_MSG_NOW("unknown type" ); break;
01631 }
01632 }
01633 }
01634
01638 void RemoveFromAllDirectArrays( int pIndex )
01639 {
01640 for( int i = 0; i < GetDirectArray().GetCount(); ++i )
01641 {
01642 switch( mDataTypes[i].GetType() )
01643 {
01644 case eBOOL1: KFbxGetDirectArray<bool>(this,i).RemoveAt( pIndex ) ; break;
01645 case eINTEGER1: KFbxGetDirectArray<int>(this,i).RemoveAt( pIndex ) ; break;
01646 case eFLOAT1: KFbxGetDirectArray<float>(this,i).RemoveAt( pIndex ) ; break;
01647 case eDOUBLE1: KFbxGetDirectArray<double>(this,i).RemoveAt( pIndex ); break;
01648
01649
01650
01651 default:
01652 K_ASSERT_MSG_NOW("unknown type" ); break;
01653 }
01654 }
01655 }
01656
01661 int GetArrayCount( int pIndex ) const
01662 {
01663 if( pIndex >= 0 && pIndex < GetDirectArray().GetCount() )
01664 {
01665 switch( mDataTypes[pIndex].GetType() )
01666 {
01667 case eBOOL1: return KFbxGetDirectArray<bool>(this,pIndex).GetCount();
01668 case eINTEGER1: return KFbxGetDirectArray<int>(this,pIndex).GetCount();
01669 case eFLOAT1: return KFbxGetDirectArray<float>(this,pIndex).GetCount();
01670 case eDOUBLE1: return KFbxGetDirectArray<double>(this,pIndex).GetCount();
01671
01672
01673
01674 default:
01675 K_ASSERT_MSG_NOW("Unknown type" ); break;
01676 }
01677 }
01678
01679 return -1;
01680 }
01681
01685 int GetId() const { return mId; }
01686
01691 int GetDirectArrayCount() const { return GetDirectArray().GetCount(); }
01692
01697 KFbxLayerElementUserData& operator=( KFbxLayerElementUserData const& pOther )
01698 {
01699 int i;
01700 Clear();
01701
01702
01703
01704 mDataNames.Resize(pOther.mDataNames.GetCount());
01705 for( i = 0; i < pOther.mDataNames.GetCount(); ++i )
01706 mDataNames.SetAt(i, new KString( *pOther.mDataNames[i] ) );
01707
01708 mDataTypes.Resize(pOther.mDataTypes.GetCount());
01709 for( i = 0; i < pOther.mDataTypes.GetCount(); ++i )
01710 mDataTypes.SetAt(i, pOther.mDataTypes[i] );
01711
01712
01713 Init();
01714 kReference** dummy = NULL;
01715 for( i = 0; i < pOther.GetDirectArrayCount(); ++i )
01716 {
01717 kReference** src = pOther.GetDirectArray().GetLocked(dummy, KFbxLayerElementArray::eREAD_LOCK);
01718 kReference** dst = GetDirectArray().GetLocked(dummy, KFbxLayerElementArray::eREADWRITE_LOCK);
01719
01720 if (src && dst)
01721 {
01722 *dst[i] = *src[i];
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736 GetDirectArray().Release((void**)&dst);
01737 pOther.GetDirectArray().Release((void**)&src);
01738 }
01739 else
01740 K_ASSERT_MSG_NOW("Unable to get lock");
01741 }
01742
01743 mId = pOther.mId;
01744
01745 if ( ( mReferenceMode == KFbxLayerElement::eINDEX ||
01746 mReferenceMode == KFbxLayerElement::eINDEX_TO_DIRECT) &&
01747 ( pOther.GetReferenceMode() == KFbxLayerElement::eINDEX ||
01748 pOther.GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT))
01749 {
01750 GetIndexArray() = pOther.GetIndexArray();
01751 }
01752
01753 return *this;
01754 }
01755
01759 bool Clear()
01760 {
01761 int i;
01762 const int lCount = GetDirectArray().GetCount();
01763 KFbxLayerElementArray** directArray = NULL;
01764 directArray = GetDirectArray().GetLocked(directArray);
01765 for( i = 0; directArray != NULL && i < lCount; ++i )
01766 {
01767 if( directArray[i] )
01768 delete directArray[i];
01769 }
01770 GetDirectArray().Release((void**)&directArray);
01771
01772 for( i = 0; i < mDataNames.GetCount(); ++i )
01773 {
01774 if( mDataNames[i] )
01775 {
01776 delete mDataNames[i];
01777 mDataNames[i] = NULL;
01778 }
01779 }
01780 mDataNames.Clear();
01781 mDataTypes.Clear();
01782
01783 KFbxLayerElementTemplate<void*>::Clear();
01784
01785 return true;
01786 }
01787
01792 virtual int MemorySize() const
01793 {
01794 int size = KFbxLayerElementTemplate<void*>::MemorySize();
01795 size += sizeof(mId);
01796 return size;
01797 }
01798
01800
01801
01802
01803
01804
01805
01807
01808 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01809 protected:
01819 KFbxLayerElementUserData( int pId, KArrayTemplate<KFbxDataType>& pDataTypes, KArrayTemplate<const char*>& pDataNames )
01820 :
01821 mId( pId ),
01822 mDataTypes( pDataTypes )
01823 {
01824 K_ASSERT( pDataTypes.GetCount() == pDataNames.GetCount() );
01825 for( int i = 0; i < pDataNames.GetCount(); ++i )
01826 {
01827 mDataNames.Add( new KString( pDataNames[i] ) );
01828 }
01829 }
01830
01834 KFbxLayerElementUserData( KFbxLayerElementUserData const& pOther )
01835 {
01836 *this = pOther;
01837 }
01838
01840 ~KFbxLayerElementUserData()
01841 {
01842 Clear();
01843 }
01844
01846 virtual void AllocateArrays()
01847 {
01848 KFbxLayerElementTemplate<void*>::AllocateArrays();
01849 Init();
01850 }
01851
01852
01853 private:
01854
01855 void Init()
01856 {
01857 int i;
01858 GetDirectArray().Resize( mDataTypes.GetCount() );
01859
01860
01861 for( i = 0; i < mDataTypes.GetCount(); ++i )
01862 {
01863 kReference** dst = NULL;
01864 dst = GetDirectArray().GetLocked(dst);
01865 if (dst)
01866 {
01867 switch( mDataTypes[i].GetType() )
01868 {
01869 case eBOOL1: dst[i] = (kReference*)new KFbxLayerElementArrayTemplate<bool>(mDataTypes[i].GetType()); break;
01870 case eINTEGER1: dst[i] = (kReference*)new KFbxLayerElementArrayTemplate<int>(mDataTypes[i].GetType()); break;
01871 case eFLOAT1: dst[i] = (kReference*)new KFbxLayerElementArrayTemplate<float>(mDataTypes[i].GetType()); break;
01872 case eDOUBLE1: dst[i] = (kReference*)new KFbxLayerElementArrayTemplate<double>(mDataTypes[i].GetType()); break;
01873
01874
01875
01876 default:
01877 K_ASSERT_MSG_NOW("Trying to assign an unknown type" ); break;
01878 }
01879 GetDirectArray().Release((void**)&dst);
01880 }
01881 }
01882 }
01883
01884 int mId;
01885 KArrayTemplate<KFbxDataType> mDataTypes;
01886 KArrayTemplate<KString*> mDataNames;
01887 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
01888 };
01889
01897 template <class T>
01898 inline KFbxLayerElementArrayTemplate<T>& KFbxGetDirectArray( KFbxLayerElementUserData *pLayerElement,int pIndex, bool* pStatus)
01899 {
01900 return *(KFbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pIndex,pStatus);
01901 }
01902
01910 template <class T>
01911 inline KFbxLayerElementArrayTemplate<T> const& KFbxGetDirectArray(KFbxLayerElementUserData const *pLayerElement, int pIndex, bool* pStatus)
01912 {
01913 return *(KFbxLayerElementArrayTemplate<T> const*)pLayerElement->GetDirectArrayVoid(pIndex,pStatus);
01914 }
01915
01916
01924 template <class T>
01925 inline KFbxLayerElementArrayTemplate<T>& KFbxGetDirectArray( KFbxLayerElementUserData *pLayerElement,const char* pName, bool* pStatus )
01926 {
01927 return *(KFbxLayerElementArrayTemplate<T>*)pLayerElement->GetDirectArrayVoid(pName,pStatus);
01928 }
01929
01937 template <class T>
01938 inline KFbxLayerElementArrayTemplate<T> const& KFbxGetDirectArray(KFbxLayerElementUserData const *pLayerElement, const char* pName, bool* pStatus )
01939 {
01940 return *(KFbxLayerElementArrayTemplate<T> const*)pLayerElement->GetDirectArrayVoid(pName,pStatus);
01941 }
01942
01943
01947 class KFBX_DLL KFbxLayerElementSmoothing : public KFbxLayerElementTemplate<int>
01948 {
01949 public:
01955 static KFbxLayerElementSmoothing* Create(KFbxLayerContainer* pOwner, char const *pName);
01956
01961 void SetReferenceMode( KFbxLayerElement::EReferenceMode pMode )
01962 {
01963 if( pMode != KFbxLayerElement::eDIRECT )
01964 {
01965 K_ASSERT_MSG_NOW( "Smoothing layer elements must be direct mapped" );
01966 return;
01967 }
01968 }
01969
01971
01972
01973
01974
01975
01976
01978 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01979
01980 protected:
01981 KFbxLayerElementSmoothing()
01982 {
01983 mReferenceMode = KFbxLayerElement::eDIRECT;
01984 }
01985 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
01986 };
01987
01991 class KFBX_DLL KFbxLayerElementCrease : public KFbxLayerElementTemplate<double>
01992 {
01993 public:
01999 static KFbxLayerElementCrease* Create(KFbxLayerContainer* pOwner, char const *pName);
02000
02005 void SetReferenceMode( KFbxLayerElement::EReferenceMode pMode )
02006 {
02007 if( pMode != KFbxLayerElement::eDIRECT )
02008 {
02009 K_ASSERT_MSG_NOW( "Crease layer elements must be direct mapped" );
02010 return;
02011 }
02012 }
02013
02015
02016
02017
02018
02019
02020
02022 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02023
02024 protected:
02025 KFbxLayerElementCrease()
02026 {
02027 mReferenceMode = KFbxLayerElement::eDIRECT;
02028 }
02029 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
02030
02031 };
02032
02035 class KFBX_DLL KFbxLayerElementVisibility : public KFbxLayerElementTemplate<bool>
02036 {
02037 public:
02038
02042 CREATE_DECLARE(LayerElementVisibility);
02043
02045
02046
02047
02048
02049
02050
02052
02053 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02054 protected:
02055 KFbxLayerElementVisibility();
02056 ~KFbxLayerElementVisibility();
02057 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
02058 };
02059
02060 typedef class KFBX_DLL KFbxLayerElementTemplate<KFbxTexture*> KFbxLayerElementTextureBase;
02061
02065 class KFBX_DLL KFbxLayerElementTexture : public KFbxLayerElementTextureBase
02066 {
02067
02068 public:
02069
02073 CREATE_DECLARE(LayerElementTexture);
02074
02083 typedef enum
02084 {
02085 eTRANSLUCENT,
02086 eADD,
02087 eMODULATE,
02088 eMODULATE2,
02089 eOVER,
02090 eMAXBLEND
02091 } EBlendMode;
02092
02096 void SetBlendMode(EBlendMode pBlendMode) { mBlendMode = pBlendMode; }
02097
02102 void SetAlpha(double pAlpha)
02103 {
02104 mAlpha = pAlpha > 1.0 ? 1.0 : pAlpha;
02105 mAlpha = pAlpha < 0.0 ? 0.0 : pAlpha;
02106 }
02107
02111 EBlendMode GetBlendMode() { return mBlendMode; }
02112
02116 double GetAlpha() { return mAlpha; }
02117
02119
02120
02121
02122
02123
02124
02126 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02127
02128 virtual int MemorySize() const
02129 {
02130 int size = KFbxLayerElementTextureBase::MemorySize();
02131 size += sizeof(mBlendMode);
02132 size += sizeof(mAlpha);
02133 return size;
02134 }
02135
02136 protected:
02141 KFbxLayerElementTexture() : mBlendMode(eTRANSLUCENT)
02142 {
02143 mReferenceMode = eINDEX_TO_DIRECT;
02144 mAlpha = 1.0;
02145 }
02146
02147 private:
02148 EBlendMode mBlendMode;
02149 double mAlpha;
02150 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
02151 };
02152
02153
02186 class KFBX_DLL KFbxLayer
02187 {
02188
02189 public:
02190
02195
02200 KFbxLayerElementNormal* GetNormals();
02201
02206 KFbxLayerElementNormal const* GetNormals() const;
02207
02212 KFbxLayerElementTangent* GetTangents();
02213
02218 KFbxLayerElementTangent const* GetTangents() const;
02219
02224 KFbxLayerElementBinormal* GetBinormals();
02225
02230 KFbxLayerElementBinormal const* GetBinormals() const;
02231
02235 KFbxLayerElementMaterial* GetMaterials();
02236
02240 KFbxLayerElementMaterial const* GetMaterials() const;
02241
02245 KFbxLayerElementPolygonGroup* GetPolygonGroups();
02246
02250 KFbxLayerElementPolygonGroup const* GetPolygonGroups() const;
02251
02252
02257 K_DEPRECATED KFbxLayerElementUV* GetEmissiveUV();
02258
02263 K_DEPRECATED KFbxLayerElementUV const* GetEmissiveUV() const;
02264
02269 K_DEPRECATED KFbxLayerElementUV* GetEmissiveFactorUV();
02270
02275 K_DEPRECATED KFbxLayerElementUV const* GetEmissiveFactorUV() const;
02276
02281 K_DEPRECATED KFbxLayerElementUV* GetAmbientUV();
02282
02287 K_DEPRECATED KFbxLayerElementUV const* GetAmbientUV() const;
02288
02293 K_DEPRECATED KFbxLayerElementUV* GetAmbientFactorUV();
02294
02299 K_DEPRECATED KFbxLayerElementUV const* GetAmbientFactorUV() const;
02300
02305 K_DEPRECATED KFbxLayerElementUV* GetDiffuseUV();
02306
02311 K_DEPRECATED KFbxLayerElementUV const* GetDiffuseUV() const;
02312
02317 K_DEPRECATED KFbxLayerElementUV* GetDiffuseFactorUV();
02318
02323 K_DEPRECATED KFbxLayerElementUV const* GetDiffuseFactorUV() const;
02324
02328 K_DEPRECATED KFbxLayerElementUV* GetSpecularUV();
02329
02334 K_DEPRECATED KFbxLayerElementUV const* GetSpecularUV() const;
02335
02340 K_DEPRECATED KFbxLayerElementUV* GetSpecularFactorUV();
02341
02346 K_DEPRECATED KFbxLayerElementUV const* GetSpecularFactorUV() const;
02347
02352 K_DEPRECATED KFbxLayerElementUV* GetShininessUV();
02353
02358 K_DEPRECATED KFbxLayerElementUV const* GetShininessUV() const;
02359
02364 K_DEPRECATED KFbxLayerElementUV* GetNormalMapUV();
02365
02370 K_DEPRECATED KFbxLayerElementUV const* GetNormalMapUV() const;
02371
02376 K_DEPRECATED KFbxLayerElementUV* GetBumpUV();
02377
02382 K_DEPRECATED KFbxLayerElementUV const* GetBumpUV() const;
02383
02388 K_DEPRECATED KFbxLayerElementUV* GetTransparentUV();
02389
02394 K_DEPRECATED KFbxLayerElementUV const* GetTransparentUV() const;
02395
02400 K_DEPRECATED KFbxLayerElementUV* GetTransparencyFactorUV();
02401
02406 K_DEPRECATED KFbxLayerElementUV const* GetTransparencyFactorUV() const;
02407
02412 K_DEPRECATED KFbxLayerElementUV* GetReflectionUV();
02413
02418 K_DEPRECATED KFbxLayerElementUV const* GetReflectionUV() const;
02419
02424 K_DEPRECATED KFbxLayerElementUV* GetReflectionFactorUV();
02425
02430 K_DEPRECATED KFbxLayerElementUV const* GetReflectionFactorUV() const;
02431
02436 K_DEPRECATED KFbxLayerElementUV* GetDisplacementUV();
02437
02442 K_DEPRECATED KFbxLayerElementUV const* GetDisplacementUV() const;
02443
02450 KFbxLayerElementUV* GetUVs(KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
02451
02458 KFbxLayerElementUV const* GetUVs(KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES) const;
02459
02460
02463 int GetUVSetCount() const;
02464
02467 KArrayTemplate<KFbxLayerElement::ELayerElementType> GetUVSetChannels() const;
02468
02471 KArrayTemplate<KFbxLayerElementUV const*> GetUVSets() const;
02472
02477 KFbxLayerElementVertexColor* GetVertexColors();
02478
02483 KFbxLayerElementVertexColor const* GetVertexColors() const;
02484
02489 KFbxLayerElementSmoothing* GetSmoothing();
02490
02495 KFbxLayerElementSmoothing const* GetSmoothing() const;
02496
02501 KFbxLayerElementCrease* GetVertexCrease();
02502
02507 KFbxLayerElementCrease const* GetVertexCrease() const;
02508
02513 KFbxLayerElementCrease* GetEdgeCrease();
02514
02519 KFbxLayerElementCrease const* GetEdgeCrease() const;
02520
02524 KFbxLayerElementUserData* GetUserData();
02525
02529 KFbxLayerElementUserData const* GetUserData() const;
02530
02534 KFbxLayerElementVisibility* GetVisibility();
02535
02539 KFbxLayerElementVisibility const* GetVisibility() const;
02540
02545 K_DEPRECATED KFbxLayerElementTexture* GetEmissiveTextures();
02546
02551 K_DEPRECATED KFbxLayerElementTexture const* GetEmissiveTextures() const;
02552
02557 K_DEPRECATED KFbxLayerElementTexture* GetEmissiveFactorTextures();
02558
02563 K_DEPRECATED KFbxLayerElementTexture const* GetEmissiveFactorTextures() const;
02564
02569 K_DEPRECATED KFbxLayerElementTexture* GetAmbientTextures();
02570
02575 K_DEPRECATED KFbxLayerElementTexture const* GetAmbientTextures() const;
02576
02581 K_DEPRECATED KFbxLayerElementTexture* GetAmbientFactorTextures();
02582
02587 K_DEPRECATED KFbxLayerElementTexture const* GetAmbientFactorTextures() const;
02588
02593 K_DEPRECATED KFbxLayerElementTexture* GetDiffuseTextures();
02594
02599 K_DEPRECATED KFbxLayerElementTexture const* GetDiffuseTextures() const;
02600
02605 K_DEPRECATED KFbxLayerElementTexture* GetDiffuseFactorTextures();
02606
02611 K_DEPRECATED KFbxLayerElementTexture const* GetDiffuseFactorTextures() const;
02612
02617 K_DEPRECATED KFbxLayerElementTexture* GetSpecularTextures();
02618
02623 K_DEPRECATED KFbxLayerElementTexture const* GetSpecularTextures() const;
02624
02629 K_DEPRECATED KFbxLayerElementTexture* GetSpecularFactorTextures();
02630
02635 K_DEPRECATED KFbxLayerElementTexture const* GetSpecularFactorTextures() const;
02636
02641 K_DEPRECATED KFbxLayerElementTexture* GetShininessTextures();
02642
02647 K_DEPRECATED KFbxLayerElementTexture const* GetShininessTextures() const;
02648
02653 K_DEPRECATED KFbxLayerElementTexture* GetNormalMapTextures();
02654
02659 K_DEPRECATED KFbxLayerElementTexture const* GetNormalMapTextures() const;
02660
02665 K_DEPRECATED KFbxLayerElementTexture* GetBumpTextures();
02666
02671 K_DEPRECATED KFbxLayerElementTexture const* GetBumpTextures() const;
02672
02677 K_DEPRECATED KFbxLayerElementTexture* GetTransparentTextures();
02678
02683 K_DEPRECATED KFbxLayerElementTexture const* GetTransparentTextures() const;
02684
02689 K_DEPRECATED KFbxLayerElementTexture* GetTransparencyFactorTextures();
02690
02695 K_DEPRECATED KFbxLayerElementTexture const* GetTransparencyFactorTextures() const;
02696
02701 K_DEPRECATED KFbxLayerElementTexture* GetReflectionTextures();
02702
02707 K_DEPRECATED KFbxLayerElementTexture const* GetReflectionTextures() const;
02708
02713 K_DEPRECATED KFbxLayerElementTexture* GetReflectionFactorTextures();
02714
02719 K_DEPRECATED KFbxLayerElementTexture const* GetReflectionFactorTextures() const;
02720
02725 K_DEPRECATED KFbxLayerElementTexture* GetDisplacementTextures();
02726
02731 K_DEPRECATED KFbxLayerElementTexture const* GetDisplacementTextures() const;
02732
02737 KFbxLayerElementTexture* GetTextures(KFbxLayerElement::ELayerElementType pType);
02738
02743 KFbxLayerElementTexture const* GetTextures(KFbxLayerElement::ELayerElementType pType) const;
02744
02749 void SetTextures(KFbxLayerElement::ELayerElementType pType, KFbxLayerElementTexture* pTextures);
02750
02769 KFbxLayerElement* GetLayerElementOfType(KFbxLayerElement::ELayerElementType pType, bool pIsUV=false);
02770
02789 KFbxLayerElement const* GetLayerElementOfType(KFbxLayerElement::ELayerElementType pType, bool pIsUV=false) const;
02790
02795 void SetNormals(KFbxLayerElementNormal* pNormals);
02796
02801 void SetBinormals(KFbxLayerElementBinormal* pBinormals);
02802
02807 void SetTangents(KFbxLayerElementTangent* pTangents);
02808
02812 void SetMaterials(KFbxLayerElementMaterial* pMaterials);
02813
02817 void SetPolygonGroups(KFbxLayerElementPolygonGroup* pPolygonGroups);
02818
02825 void SetUVs(KFbxLayerElementUV* pUVs, KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
02826
02831 void SetVertexColors (KFbxLayerElementVertexColor* pVertexColors);
02832
02837 void SetSmoothing (KFbxLayerElementSmoothing* pSmoothing);
02838
02843 void SetVertexCrease (KFbxLayerElementCrease* pCrease);
02844
02849 void SetEdgeCrease (KFbxLayerElementCrease* pCrease);
02850
02854 void SetUserData (KFbxLayerElementUserData* pUserData);
02855
02859 void SetVisibility( KFbxLayerElementVisibility* pVisibility );
02860
02865 K_DEPRECATED void SetEmissiveTextures(KFbxLayerElementTexture* pTextures);
02866
02871 K_DEPRECATED void SetEmissiveFactorTextures(KFbxLayerElementTexture* pTextures);
02872
02877 K_DEPRECATED void SetAmbientTextures(KFbxLayerElementTexture* pTextures);
02878
02883 K_DEPRECATED void SetAmbientFactorTextures(KFbxLayerElementTexture* pTextures);
02884
02889 K_DEPRECATED void SetDiffuseTextures(KFbxLayerElementTexture* pTextures);
02890
02895 K_DEPRECATED void SetDiffuseFactorTextures(KFbxLayerElementTexture* pTextures);
02896
02901 K_DEPRECATED void SetSpecularTextures(KFbxLayerElementTexture* pTextures);
02902
02907 K_DEPRECATED void SetSpecularFactorTextures(KFbxLayerElementTexture* pTextures);
02908
02913 K_DEPRECATED void SetShininessTextures(KFbxLayerElementTexture* pTextures);
02914
02919 K_DEPRECATED void SetNormalMapTextures(KFbxLayerElementTexture* pTextures);
02920
02925 K_DEPRECATED void SetBumpTextures(KFbxLayerElementTexture* pTextures);
02926
02931 K_DEPRECATED void SetTransparentTextures(KFbxLayerElementTexture* pTextures);
02932
02937 K_DEPRECATED void SetTransparencyFactorTextures(KFbxLayerElementTexture* pTextures);
02938
02943 K_DEPRECATED void SetReflectionTextures(KFbxLayerElementTexture* pTextures);
02944
02949 K_DEPRECATED void SetReflectionFactorTextures(KFbxLayerElementTexture* pTextures);
02950
02955 K_DEPRECATED void SetDisplacementTextures(KFbxLayerElementTexture* pTextures);
02956
02957
02964 KFbxLayerElement* CreateLayerElementOfType(KFbxLayerElement::ELayerElementType pType, bool pIsUV=false);
02965
02970 void Clone(KFbxLayer const& pSrcLayer, KFbxSdkManager* pSdkManager);
02971
02972
02974
02975
02976
02977
02978
02979
02981
02982 #ifndef DOXYGEN_SHOULD_SKIP_THIS
02983 protected:
02985 KFbxLayer& operator=(KFbxLayer const& pSrcLayer);
02987 private:
02988
02989 KFbxLayer(KFbxLayerContainer& pOwner);
02990 virtual ~KFbxLayer();
02991
02992 void Clear();
02993
02994 KFbxLayerContainer& mOwner;
02995
02996 KFbxLayerElement* mNonTexturesArray[KFbxLayerElement::LAYERELEMENT_TYPE_NON_TEXTURE_COUNT];
02997 KFbxLayerElementUV* mUVsArray[KFbxLayerElement::LAYERELEMENT_TYPE_TEXTURE_COUNT];
02998 KFbxLayerElementTexture* mTexturesArray[KFbxLayerElement::LAYERELEMENT_TYPE_TEXTURE_COUNT];
02999
03000
03001 friend class KFbxLayerContainer;
03002
03003 public:
03008 bool ContentWriteTo(KFbxStream& pStream) const;
03009 bool ContentReadFrom(const KFbxStream& pStream);
03011 virtual int MemoryUsage() const;
03012
03013 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
03014 };
03015
03016
03017 #define FOR_EACH_TEXTURE(lLayerIndex) for((lLayerIndex) = 0; (lLayerIndex) < KFbxLayerElement::LAYERELEMENT_TYPE_TEXTURE_COUNT; (lLayerIndex)++)
03018
03019 #define FOR_EACH_NON_TEXTURE(lLayerIndex) for((lLayerIndex) = 0; (lLayerIndex) < KFbxLayerElement::LAYERELEMENT_TYPE_NON_TEXTURE_COUNT; (lLayerIndex)++)
03020
03021 #define TEXTURE_INDEX(ElementType) (int(ElementType) - KFbxLayerElement::LAYERELEMENT_TYPE_TEXTURE_START_INDEX)
03022 #define TEXTURE_TYPE(TextureIndex) (KFbxLayerElement::ELayerElementType((TextureIndex) + KFbxLayerElement::LAYERELEMENT_TYPE_TEXTURE_START_INDEX))
03023
03024 #define NON_TEXTURE_INDEX(ElementType) (int(ElementType) - KFbxLayerElement::LAYERELEMENT_TYPE_NON_TEXTURE_START_INDEX)
03025 #define NON_TEXTURE_TYPE(Index) (KFbxLayerElement::ELayerElementType((Index) + KFbxLayerElement::LAYERELEMENT_TYPE_NON_TEXTURE_START_INDEX))
03026
03027 #undef CREATE_DECLARE
03028 #include <fbxfilesdk/fbxfilesdk_nsend.h>
03029
03030 #endif // FBXFILESDK_KFBXPLUGINS_KFBXLAYER_H
03031