fbxmesh.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2013 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_SCENE_GEOMETRY_MESH_H_
00014 #define _FBXSDK_SCENE_GEOMETRY_MESH_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/base/fbxarray.h>
00019 #include <fbxsdk/scene/geometry/fbxgeometry.h>
00020 
00021 #include <fbxsdk/fbxsdk_nsbegin.h>
00022 
00032 class FBXSDK_DLL FbxMesh : public FbxGeometry
00033 {
00034     FBXSDK_OBJECT_DECLARE(FbxMesh, FbxGeometry);
00035 
00036 public:
00039     virtual FbxNodeAttribute::EType GetAttributeType() const;
00040 
00052         void BeginPolygon(int pMaterial=-1, int pTexture=-1, int pGroup=-1, bool pLegacy=true);
00053 
00060         void BeginPolygonExt(int pMaterial, int* pTextures);
00061 
00066         void AddPolygon(int pIndex, int pTextureUVIndex = -1);
00067 
00069         void EndPolygon();
00070 
00073         inline int GetPolygonCount() const { return mPolygons.GetCount(); }
00074 
00078         inline int GetPolygonSize(int pPolygonIndex) const
00079         {
00080             return ( pPolygonIndex >= 0 && pPolygonIndex < mPolygons.GetCount() ) ? mPolygons[pPolygonIndex].mSize : -1;
00081         }
00082 
00088         int GetPolygonGroup(int pPolygonIndex) const;
00089 
00095         inline void SetPolygonGroup(int pPolygonIndex, int pGroup) const
00096         {
00097             if( pPolygonIndex >= 0 && pPolygonIndex<mPolygons.GetCount() ) mPolygons[pPolygonIndex].mGroup = pGroup;
00098         }
00099 
00104         inline int GetPolygonVertex(int pPolygonIndex, int pPositionInPolygon) const
00105         {
00106             return ( pPolygonIndex >= 0 && pPolygonIndex < mPolygons.GetCount() && pPositionInPolygon >= 0 && pPositionInPolygon < mPolygons[pPolygonIndex].mSize ) ?
00107                 mPolygonVertices[mPolygons[pPolygonIndex].mIndex + pPositionInPolygon] : -1;
00108         }
00109 
00116         bool GetPolygonVertexNormal(int pPolyIndex, int pVertexIndex, FbxVector4& pNormal) const;
00117 
00121         bool GetPolygonVertexNormals(FbxArray<FbxVector4>& pNormals) const;
00122 
00130         bool GetPolygonVertexUV(int pPolyIndex, int pVertexIndex, const char* pUVSetName, FbxVector2& pUV) const;
00131 
00136         bool GetPolygonVertexUVs(const char* pUVSetName, FbxArray<FbxVector2>& pUVs) const;
00137 
00142         int* GetPolygonVertices() const;
00143 
00148         inline int GetPolygonVertexCount() const { return mPolygonVertices.Size(); }
00149 
00167         int GetPolygonVertexIndex(int pPolygonIndex) const;
00168 
00174         int RemovePolygon(int pPolygonIndex);
00175 
00181         int RemoveDuplicatedEdges(FbxArray<int>& pEdgeIndexList);
00183 
00195         void InitTextureUV(int pCount, FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
00196 
00203         void AddTextureUV(FbxVector2 pUV, FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
00204 
00207         int GetTextureUVCount(FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
00208 
00211         int GetUVLayerCount() const;
00212 
00221         FbxArray<FbxLayerElement::EType> GetAllChannelUV(int pLayer);
00223 
00241         void InitMaterialIndices(FbxLayerElement::EMappingMode pMappingMode);
00242 
00254         void InitTextureIndices(FbxLayerElement::EMappingMode pMappingMode, FbxLayerElement::EType pTextureType);
00255 
00270         void InitTextureUVIndices(FbxLayerElement::EMappingMode pMappingMode, FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
00271 
00281         int GetTextureUVIndex(int pPolygonIndex, int pPositionInPolygon, FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
00282 
00291         void SetTextureUVIndex(int pPolygonIndex, int pPositionInPolygon, int pIndex, FbxLayerElement::EType pTypeIdentifier);
00293 
00298         void Reset();
00299 
00303         void ComputeVertexNormals(bool pCW=false);
00304 
00308         bool CheckIfVertexNormalsCCW();
00309 
00311         class DuplicateVertex
00312         {
00313         public:
00314             DuplicateVertex() :
00315                 lVertexPolyIndex(0),
00316                 lNewVertexIndex(0),
00317                 lNormal(0, 0, 0),
00318                 lUV(0, 0),
00319                 lEdgeIndex(0)
00320             {
00321             }
00322 
00323             int         lVertexPolyIndex;   
00324             int         lNewVertexIndex;    
00325             FbxVector4  lNormal;            
00326             FbxVector2  lUV;                
00327             int         lEdgeIndex;         
00328         };
00329 
00331         class VertexNormalInfo
00332         {
00333         public:
00334             VertexNormalInfo() :
00335                 mTotalNormal(0, 0, 0),
00336                 mNumNormal(0)
00337             {
00338             }
00339 
00340             FbxVector4  mTotalNormal;   
00341             int         mNumNormal;     
00342         };
00343 
00346         bool CheckSamePointTwice() const;
00347 
00352         int RemoveBadPolygons();
00354 
00361         bool SplitPoints(FbxLayerElement::EType pTypeIdentifier=FbxLayerElement::eTextureDiffuse);
00362 
00366         bool BuildMergeList(FbxArray<int>& pMergeList, bool pExport=false);
00367 
00370         void MergePointsForPolygonVerteNormals(FbxArray<int> &pMergeList);
00372 
00375 
00376 
00380 
00389 
00394 
00399 
00407 
00413 
00418 
00423 
00427 
00432 
00441 
00454 
00458 
00461 
00467 
00478 
00482 
00484 
00487 
00491 
00502 
00507 
00512 
00517 
00523 
00528 
00534 
00539 
00541 
00547 
00556 
00566 
00571 
00575 
00579 
00584 
00588 
00592 
00596 
00600 
00605 
00609 
00614 
00618 
00623 
00627 
00632 
00634 
00640 
00645 
00651 
00656 
00658 
00670 
00681 
00692 
00694 
00698 
00775