fbxgeometryconverter.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_UTILS_GEOMETRY_CONVERTER_H_
00014 #define _FBXSDK_UTILS_GEOMETRY_CONVERTER_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/base/fbxarray.h>
00019 
00020 #include <fbxsdk/fbxsdk_nsbegin.h>
00021 
00022 class FbxManager;
00023 class FbxMesh;
00024 class FbxPatch;
00025 class FbxNurbs;
00026 class FbxNurbsSurface;
00027 class FbxNurbsCurve;
00028 class FbxWeightedMapping;
00029 class FbxSurfaceEvaluator;
00030 
00037 class FBXSDK_DLL FbxGeometryConverter
00038 {
00039 public:
00043     FbxGeometryConverter(FbxManager* pManager);
00044 
00047     ~FbxGeometryConverter();
00048 
00058         FbxMesh* TriangulateMesh(FbxMesh const* pMesh);
00059 
00066         FbxMesh* TriangulatePatch(FbxPatch const* pPatch);
00067 
00074         FbxMesh* TriangulateNurbs(FbxNurbs const* pNurbs);
00075 
00082         bool TriangulateInPlace(FbxNode* pNode);
00083 
00095         bool AddAlternateGeometry(FbxNode* pNode, FbxGeometry* pSrcGeom, FbxGeometry* pAltGeom, FbxWeightedMapping* pSrcToAltWeightedMapping, bool pConvertDeformations);
00096 
00106         bool ConvertGeometryAnimation(FbxNode* pNode, FbxGeometry* pSrcGeom, FbxGeometry* pDstGeom);
00107 
00116         bool ComputeGeometryControlPointsWeightedMapping(FbxGeometry* pSrcGeom, FbxGeometry* pDstGeom, FbxWeightedMapping* pSrcToDstWeightedMapping, bool pSwapUV=false);
00118 
00128         FbxNurbs* ConvertPatchToNurbs(FbxPatch *pPatch);
00129 
00136         bool ConvertPatchToNurbsInPlace(FbxNode* pNode);
00137 
00143         FbxNurbsSurface* ConvertPatchToNurbsSurface(FbxPatch *pPatch);
00144 
00151         bool ConvertPatchToNurbsSurfaceInPlace(FbxNode* pNode);
00152 
00157         FbxNurbsSurface* ConvertNurbsToNurbsSurface( FbxNurbs* pNurbs );
00158 
00163         FbxNurbs* ConvertNurbsSurfaceToNurbs( FbxNurbsSurface* pNurbs );
00164 
00170         bool ConvertNurbsToNurbsSurfaceInPlace(FbxNode* pNode);
00171 
00177         bool ConvertNurbsSurfaceToNurbsInPlace(FbxNode* pNode);
00179 
00190         FbxNurbs* FlipNurbs(FbxNurbs* pNurbs, bool pSwapUV, bool pSwapClusters);
00191 
00198         FbxNurbsSurface* FlipNurbsSurface(FbxNurbsSurface* pNurbs, bool pSwapUV, bool pSwapClusters);
00200 
00218         bool EmulateNormalsByPolygonVertex(FbxMesh* pMesh);
00219 
00229         bool ComputeEdgeSmoothingFromNormals( FbxMesh* pMesh ) const;
00230 
00240         bool ComputePolygonSmoothingFromEdgeSmoothing( FbxMesh* pMesh, int pIndex=0 ) const;
00241 
00249         bool ComputeEdgeSmoothingFromPolygonSmoothing( FbxMesh* pMesh, int pIndex=0 ) const;
00251 
00258     void ReplaceNodeAttribute(FbxNode* pNode, FbxNodeAttribute* pNewNodeAttr);
00259 
00268     bool AddTriangulatedMeshGeometry(FbxNode* pNode, int pUVStepCoeff);
00269 
00284     bool SplitMeshPerMaterial(FbxMesh* pMesh);
00285 
00290     bool SplitMeshesPerMaterial(FbxScene* pScene);
00291 
00297     bool CreateAndCopyLayerElement(FbxMesh *pNewMesh, FbxMesh *pRefMesh);
00298 
00304     bool SetLayerElements(FbxMesh *pNewMesh, FbxMesh *pMesh, int pPolygonIndex, int pPolyPointIndex, int pLoopIndex, bool pIsSearched, bool pIsEndPolygon);
00305 
00312     FbxMesh* TriangulateMeshAdvance(FbxMesh const* pMesh, bool& pStatus);
00313 
00335     FbxNode* MergeMeshes(FbxArray<FbxNode*>& pMeshNodes, const char* pNodeName, FbxScene* pScene);
00336 
00355     static void FbxTriangulation(int *Index, int pNumSide);
00356 
00357 /*****************************************************************************************************************************
00358 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00359 *****************************************************************************************************************************/
00360 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00361 protected:
00362     bool ComputePatchToMeshControlPointsWeightedMapping(FbxPatch* pSrcPatch, FbxMesh* pDstMesh, FbxWeightedMapping* pMapping, bool pSwapUV=false);
00363     bool ComputeNurbsToMeshControlPointsWeightedMapping(FbxNurbsSurface* pSrcNurbs, FbxMesh* pDstMesh, FbxWeightedMapping* pMapping, bool pRescaleUVs=false, bool pSwapUV=false);
00364 
00365     void InitializeWeightInControlPoints(FbxGeometryBase* pGeometry);
00366     void InitializeWeightInNormals(FbxLayerContainer* pLayerContainer);
00367     void TriangulateContinuousSurface(FbxMesh* pMesh, FbxSurfaceEvaluator* pSurface, FbxUInt pPointCountX, FbxUInt pPointCountY, bool ClockWise=false);
00368     void CheckForZeroWeightInShape(FbxGeometry *pGeometry);
00369     FbxMesh* CreateMeshFromParametricSurface(FbxGeometry const* pGeometry);
00370     FbxNurbs* CreateNurbsFromPatch(FbxPatch* pPatch);
00371     FbxNurbsSurface* CreateNurbsSurfaceFromPatch(FbxPatch* pPatch);
00372 
00373     void ConvertShapes(FbxGeometry const* pSource, FbxGeometry* pDestination, FbxSurfaceEvaluator* pEvaluator, int pUCount, int pVCount);
00374     void ConvertShapes(FbxGeometry const* pSource, FbxGeometry* pDestination, FbxWeightedMapping* pSourceToDestinationMapping);
00375     void ConvertClusters(FbxGeometry const* pSource, FbxGeometry* pDestination, FbxWeightedMapping* pSourceToDestinationMapping);
00376     void ConvertClusters(FbxArray<FbxCluster*> const& pSourceClusters, int pSourceControlPointsCount, FbxArray<FbxCluster*>& pDestinationClusters, int pDestinationControlPointsCount, FbxWeightedMapping* pSourceToDestinationMapping);
00377     void BuildClusterToSourceMapping(FbxArray<FbxCluster*> const& pSourceClusters, FbxWeightedMapping* pClusterToSourceMapping);
00378     void CheckClusterToSourceMapping(FbxWeightedMapping* pClusterToSourceMapping);
00379     void ConvertCluster(int pSourceClusterIndex, FbxWeightedMapping* pClusterToSourceMapping, FbxWeightedMapping* pSourceToDestinationMapping, FbxCluster* pDestinationCluster);
00380     void DuplicateControlPoints(FbxArray<FbxVector4>& pControlPoints, FbxArray<int>& pPolygonVertices);
00381     void UpdatePolygon(FbxMesh *pNewMesh, FbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated);
00382     void UpdatePolygon(FbxMesh *pNewMesh, FbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated, int pTriangleNum);
00383     void ResizePolygon(FbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0, bool pClearFlag = true);
00384 
00385     template <class T1, class T2> void ConvertNurbs(T1* pNewNurbs, T2* pOldNurb);
00386 
00387     bool CopyAnimationCurves(FbxNode* pNode, FbxGeometry* pNewGeometry);
00388     bool FlipNurbsCurve(FbxNurbsCurve* pCurve) const;
00389     void FlipControlPoints(FbxGeometryBase* pPoints, int pUCount, int pVCount) const;
00390     bool ConvertMaterialReferenceMode(FbxMesh* pMeshRef) const;
00391     void RevertMaterialReferenceModeConversion(FbxMesh* pMeshRef) const;
00392 
00393     FbxManager* mManager;
00394 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00395 };
00396 
00397 #include <fbxsdk/fbxsdk_nsend.h>
00398 
00399 #endif /* _FBXSDK_UTILS_GEOMETRY_CONVERTER_H_ */