00001
00004 #ifndef _FBXSDK_MESH_H_
00005 #define _FBXSDK_MESH_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 <kaydaradef.h>
00043 #ifndef KFBX_DLL
00044 #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046
00047 #include <kaydara.h>
00048
00049 #include <kfbxplugins/kfbxgeometry.h>
00050
00051 #include <kfbxmath/kfbxvector4.h>
00052 #include <kfbxmath/kfbxvector2.h>
00053
00054 #include <klib/karrayul.h>
00055
00056 #include <fbxfilesdk_nsbegin.h>
00057
00058 class KFbxMesh;
00059 class KFbxMesh_internal;
00060 class KFbxSdkManager;
00061
00075 class KFBX_DLL KFbxMesh : public KFbxGeometry
00076 {
00077 KFBXOBJECT_DECLARE(KFbxMesh);
00078
00079 public:
00083 virtual EAttributeType GetAttributeType() const;
00084
00089
00099 void BeginPolygon(int pMaterial = -1, int pTexture = -1, int pGroup = -1, bool pLegacy=true);
00100
00107 void BeginPolygonExt(int pMaterial, int* pTextures);
00108
00114 void AddPolygon(int pIndex, int pTextureUVIndex = -1);
00115
00117 void EndPolygon();
00118
00122 int GetPolygonCount();
00123
00129 int GetPolygonSize(int pPolygonIndex);
00130
00136 int GetPolygonGroup(int pPolygonIndex);
00137
00145 int GetPolygonVertex(int pPolygonIndex, int pPositionInPolygon);
00146
00154 void GetPolygonVertexNormal(int &pPolyIndex, int &pVertexIndex, KFbxVector4 &pNormal);
00155
00162 int* GetPolygonVertices();
00163
00166 int GetPolygonVertexCount();
00167
00173 int RemovePolygon(int pPolygonIndex);
00174
00176
00187
00193 void InitTextureUV(int pCount, KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00194
00201 void AddTextureUV(KFbxVector2 pUV, KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00202
00206 int GetTextureUVCount(KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00207
00211 int GetUVLayerCount();
00212
00216 KArrayTemplate<KFbxLayerElement::ELayerElementType> GetAllChannelUV(int layer);
00217
00222 KFbxVector2* GetTextureUV(KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00223
00225
00236
00250 void InitMaterialIndices(KFbxLayerElement::EMappingMode pMappingMode);
00251
00259 K_DEPRECATED KFbxLayerElement::EMappingMode GetMaterialMappingMode();
00260
00267 int* GetMaterialIndices();
00268
00279 void InitEmissiveTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00280
00291 void InitEmissiveFactorTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00292
00303 void InitAmbientTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00304
00315 void InitAmbientFactorTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00316
00327 void InitDiffuseTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00328
00339 void InitDiffuseFactorTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00340
00351 void InitSpecularTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00352
00363 void InitSpecularFactorTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00364
00375 void InitShininessTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00376
00387 void InitBumpTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00388
00399 void InitNormalMapTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00400
00411 void InitTransparentTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00412
00423 void InitTransparencyFactorTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00424
00435 void InitReflectionTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00436
00447 void InitReflectionFactorTexturesIndices(KFbxLayerElement::EMappingMode pMappingMode);
00448
00456 K_DEPRECATED KFbxLayerElement::EMappingMode GetEmissiveTexturesMappingMode();
00457
00465 K_DEPRECATED KFbxLayerElement::EMappingMode GetEmissiveFactorTexturesMappingMode();
00466
00474 K_DEPRECATED KFbxLayerElement::EMappingMode GetAmbientTexturesMappingMode();
00475
00483 K_DEPRECATED KFbxLayerElement::EMappingMode GetAmbientFactorTexturesMappingMode();
00484
00492 K_DEPRECATED KFbxLayerElement::EMappingMode GetDiffuseTexturesMappingMode();
00493
00501 K_DEPRECATED KFbxLayerElement::EMappingMode GetDiffuseFactorTexturesMappingMode();
00502
00510 K_DEPRECATED KFbxLayerElement::EMappingMode GetSpecularTexturesMappingMode();
00511
00519 K_DEPRECATED KFbxLayerElement::EMappingMode GetSpecularFactorTexturesMappingMode();
00520
00528 K_DEPRECATED KFbxLayerElement::EMappingMode GetShininessTexturesMappingMode();
00529
00537 K_DEPRECATED KFbxLayerElement::EMappingMode GetBumpTexturesMappingMode();
00538
00546 K_DEPRECATED KFbxLayerElement::EMappingMode GetTransparentTexturesMappingMode();
00547
00555 K_DEPRECATED KFbxLayerElement::EMappingMode GetTransparencyFactorTexturesMappingMode();
00556
00564 K_DEPRECATED KFbxLayerElement::EMappingMode GetReflectionTexturesMappingMode();
00565
00573 K_DEPRECATED KFbxLayerElement::EMappingMode GetReflectionFactorTexturesMappingMode();
00574
00581 int* GetEmissiveTexturesIndices();
00582
00589 int* GetEmissiveFactorTexturesIndices();
00590
00597 int* GetAmbientTexturesIndices();
00598
00605 int* GetAmbientFactorTexturesIndices();
00606
00613 int* GetDiffuseTexturesIndices();
00614
00621 int* GetDiffuseFactorTexturesIndices();
00622
00629 int* GetSpecularTexturesIndices();
00630
00637 int* GetSpecularFactorTexturesIndices();
00638
00645 int* GetShininessTexturesIndices();
00646
00653 int* GetBumpTexturesIndices();
00654
00661 int* GetTransparentTexturesIndices();
00662
00669 int* GetTransparencyFactorTexturesIndices();
00670
00677 int* GetReflectionTexturesIndices();
00678
00685 int* GetReflectionFactorTexturesIndices();
00686
00693 int* GetTexturesIndices(KFbxLayerElement::ELayerElementType pTextureType);
00694
00709 void InitTextureUVIndices(KFbxLayerElement::EMappingMode pMappingMode, KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00710
00718 K_DEPRECATED KFbxLayerElement::EMappingMode GetTextureUVMappingMode(KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00719
00729 int GetTextureUVIndex(int pPolygonIndex, int pPositionInPolygon, KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00730
00731
00740 void SetTextureUVIndex(int pPolygonIndex, int pPositionInPolygon, int pIndex, KFbxLayerElement::ELayerElementType pTypeIdentifier);
00741
00749 K_DEPRECATED KFbxLayerElement::EMappingMode GetNormalsMappingMode();
00750
00758 K_DEPRECATED void SetNormalsMappingMode(KFbxLayerElement::EMappingMode pMappingMode);
00759
00761
00766
00770 void Reset();
00771
00777 void ComputeVertexNormals(bool pCW = false);
00778
00783 bool CheckIfVertexNormalsCCW();
00784
00787 typedef enum
00788 {
00789 eBY_NORMAL
00791 } ESplitObject;
00792
00794 class KDuplicateVertex
00795 {
00796 public:
00797 KDuplicateVertex() :
00798 lVertexPolyIndex(0),
00799 lNewVertexIndex(0),
00800 lNormal(0,0,0)
00801 {
00802 };
00803
00804 int lVertexPolyIndex ;
00805 int lNewVertexIndex;
00806 KFbxVector4 lNormal;
00807 KFbxVector2 lUV;
00808
00809 int lEdgeIndex;
00810 };
00811
00813 class KVertexNormalInfo
00814 {
00815 public:
00816 KVertexNormalInfo():
00817 mTotalNormal(0,0,0),
00818 mNumNormal(0)
00819 {
00820 };
00821
00822 KFbxVector4 mTotalNormal;
00823 int mNumNormal;
00824 };
00825
00826 typedef KArrayTemplate< KDuplicateVertex > KArrayOfDuplicateVertex;
00827
00831 bool CheckSamePointTwice();
00832
00839 int RemoveBadPolygons();
00840
00842
00847
00853 void BuildSplitList(KArrayTemplate<KArrayOfDuplicateVertex* >&pSplitList, ESplitObject pObject);
00854
00858 void SplitPointsForHardEdge(KArrayTemplate<KArrayOfDuplicateVertex* > &pSplitList, KFbxLayerElement::ELayerElementType pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES);
00859
00865 bool BuildMergeList(KArrayTemplate<int> &pMergeList,ESplitObject pObject , bool pExport = false);
00866
00870 void MergePointsForPolygonVerteNormals(KArrayTemplate<int> &pMergeList);
00871
00873
00874
00879
00883 void BuildMeshEdgeArray();
00884
00888 int GetMeshEdgeCount();
00889
00898 int GetMeshEdgeIndex( int pStartVertexIndex, int pEndVertexIndex, bool& pReversed );
00899
00900 int GetMeshEdgeIndexForPolygon( int pPolygon, int pPositionInPolygon );
00901
00908 void GetMeshEdgeVertices( int pEdgeIndex, int& pStartVertexIndex, int& pEndVertexIndex );
00909
00914 void BeginGetMeshEdgeVertices();
00915
00916 void EndGetMeshEdgeVertices();
00917
00921 void SetMeshEdgeCount( int pEdgeCount );
00922
00927 void SetMeshEdge( int pEdgeIndex, int pValue );
00928
00938 int AddMeshEdgeIndex( int pStartVertexIndex, int pEndVertexIndex, bool pCheckForDuplicates );
00939
00940 int SetMeshEdgeIndex( int pEdgeIndex, int pStartVertexIndex, int pEndVertexIndex, bool pCheckForDuplicates );
00941
00945 void BeginAddMeshEdgeIndex();
00946
00949 void EndAddMeshEdgeIndex();
00950
00951
00958 int AddMeshEdgeIndexForPolygon( int pPolygonIndex, int pPositionInPolygon );
00959
00970 bool SetMeshEdgeIndex( int pEdgeIndex, int pPolygonIndex, int pPositionInPolygon );
00971
00972
00973 struct KFbxComponentMap
00974 {
00975 KArrayTemplate<int> mData;
00976 KArrayTemplate<int> mOffsets;
00977
00978 int GetDataCount(int pIndex) { return mOffsets[pIndex + 1] - mOffsets[pIndex]; }
00979 int GetData(int pIndex, int pSubIndex) { return mData[ mOffsets[pIndex] + pSubIndex ]; }
00980 int GetComponentCount() { return mOffsets.GetCount() - 1; }
00981 };
00982
00983 void ComputeComponentMaps( KFbxComponentMap& pEdgeToPolyMap, KFbxComponentMap& pPolyToEdgeMap );
00984
00988 bool IsTriangleMesh() const;
00989
00991
00993
00994
00995
00996
00997
00998
01000
01001 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01002
01003 public:
01004
01005 virtual KObject* GetFbxObject_internal();
01006 virtual KObject const* GetFbxObject_internal() const;
01007
01008
01009 virtual KFbxObject* Clone(KFbxObject::ECloneType pCloneType) const;
01010
01011 protected:
01012 static char const* GetNamePrefix() { return 0; }
01013
01014 void InitTextureIndices(KFbxLayerElementTexture* pLayerElementTexture, KFbxLayerElement::EMappingMode pMappingMode);
01015 int* GetTextureIndices(KFbxLayerElementTexture* pLayerElementTexture);
01016 void RemoveTextureIndex(KFbxLayerElementTexture* pLayerElementTextures, int pPolygonIndex, int pOffset);
01017 void RemoveUVIndex(KFbxLayerElementUV* pLayerElementUV, int pPolygonIndex, int pOffset);
01018
01019 bool IsBadPoly(int pPolygonIndex);
01020
01021 KFbxMesh(KFbxSdkManager& pManager, char const* pName);
01022 ~KFbxMesh();
01023
01024 virtual void Destruct(bool pRecursive, bool pDependents);
01025
01027 KFbxMesh& operator= (KFbxMesh const& pMesh);
01028
01029 virtual KString GetTypeName() const;
01030 virtual KStringList GetTypeFlags() const;
01031
01032 int mUCount, mVCount;
01033 int mUCountExtent, mVCountExtent;
01034 int mUStep, mVStep;
01035 bool mUClosed, mVClosed;
01036 bool mUCapped, mVCapped;
01037
01038 struct KFbxPolygon
01039 {
01040 int mIndex;
01041 int mSize;
01042 int mGroup;
01043 };
01044
01045 struct KFbxSplitEdgeData
01046 {
01047 int mOriginalEdge;
01048 bool mIsNew;
01049 };
01050
01051 KArrayTemplate<KFbxPolygon> mPolygons;
01052 KArrayTemplate<int> mPolygonVertices;
01053
01054 struct KFbxPolyIndex
01055 {
01056 int mPolygonIndex;
01057 int mSubPolygonIndex;
01058 };
01059
01060 struct KFbxV2PVMap
01061 {
01062 KFbxPolyIndex* mV2PV;
01063 int* mV2PVOffset;
01064 int* mV2PVCount;
01065 bool mValid;
01066 };
01067
01068 KFbxV2PVMap mV2PVMap;
01069
01070 struct KFbxEdgeLookup
01071 {
01072 KArrayTemplate<int> mPVFlags;
01073 bool mValid;
01074 };
01075
01076 KFbxEdgeLookup mPVEndFlags;
01077
01078
01079 KFbxMesh_internal* mPH;
01080
01081 protected:
01082 KArrayTemplate< int > mEdgeArray;
01083
01084
01085 int FindPolygonIndex( int pEdgeIndex );
01086
01087 void PolySetTexture(KFbxLayer* pLayer, int pTextureIndex,
01088 KFbxLayerElement::ELayerElementType pTextureType);
01089
01090 friend class KFbxReaderFbx;
01091 friend class KFbxReaderFbx6;
01092 friend class KFbxWriterFbx;
01093 friend class KFbxWriterFbx6;
01094 friend class KFbxGeometryConverter;
01095 friend class KFbxWriter3DS;
01096
01097 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
01098
01099 };
01100
01101
01102 typedef KFbxMesh* HKFbxMesh;
01103
01104 #include <fbxfilesdk_nsend.h>
01105
01106 #endif // #ifndef _FBXSDK_MESH_H_
01107
01108