fbxsdk/utils/fbxgeometryconverter.h Source File

fbxgeometryconverter.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2014 Autodesk, Inc.
4  All rights reserved.
5 
6  Use of this software is subject to the terms of the Autodesk license agreement
7  provided at the time of installation or download, or which otherwise accompanies
8  this software in either electronic or hard copy form.
9 
10 ****************************************************************************************/
11 
13 #ifndef _FBXSDK_UTILS_GEOMETRY_CONVERTER_H_
14 #define _FBXSDK_UTILS_GEOMETRY_CONVERTER_H_
15 
16 #include <fbxsdk/fbxsdk_def.h>
17 
19 
20 #include <fbxsdk/fbxsdk_nsbegin.h>
21 
22 class FbxManager;
23 class FbxMesh;
24 class FbxPatch;
25 class FbxNurbs;
26 class FbxNurbsSurface;
27 class FbxNurbsCurve;
28 class FbxWeightedMapping;
29 class FbxSurfaceEvaluator;
30 
38 {
39 public:
49  bool Triangulate(FbxScene* pScene, bool pReplace, bool pLegacy=false);
50 
59  FbxNodeAttribute* Triangulate(FbxNodeAttribute* pNodeAttribute, bool pReplace, bool pLegacy=false);
60 
68  bool ComputeGeometryControlPointsWeightedMapping(FbxGeometry* pSrcGeom, FbxGeometry* pDstGeom, FbxWeightedMapping* pSrcToDstWeightedMapping, bool pSwapUV=false);
70 
80  FbxNurbs* ConvertPatchToNurbs(FbxPatch *pPatch);
81 
88  bool ConvertPatchToNurbsInPlace(FbxNode* pNode);
89 
95  FbxNurbsSurface* ConvertPatchToNurbsSurface(FbxPatch *pPatch);
96 
103  bool ConvertPatchToNurbsSurfaceInPlace(FbxNode* pNode);
104 
109  FbxNurbsSurface* ConvertNurbsToNurbsSurface( FbxNurbs* pNurbs );
110 
115  FbxNurbs* ConvertNurbsSurfaceToNurbs( FbxNurbsSurface* pNurbs );
116 
122  bool ConvertNurbsToNurbsSurfaceInPlace(FbxNode* pNode);
123 
129  bool ConvertNurbsSurfaceToNurbsInPlace(FbxNode* pNode);
131 
142  FbxNurbs* FlipNurbs(FbxNurbs* pNurbs, bool pSwapUV, bool pSwapClusters);
143 
150  FbxNurbsSurface* FlipNurbsSurface(FbxNurbsSurface* pNurbs, bool pSwapUV, bool pSwapClusters);
152 
170  bool EmulateNormalsByPolygonVertex(FbxMesh* pMesh);
171 
181  bool ComputeEdgeSmoothingFromNormals( FbxMesh* pMesh ) const;
182 
192  bool ComputePolygonSmoothingFromEdgeSmoothing( FbxMesh* pMesh, int pIndex=0 ) const;
193 
201  bool ComputeEdgeSmoothingFromPolygonSmoothing( FbxMesh* pMesh, int pIndex=0 ) const;
203 
211  bool SplitMeshesPerMaterial(FbxScene* pScene, bool pReplace);
212 
221  bool SplitMeshPerMaterial(FbxMesh* pMesh, bool pReplace);
223 
230  bool RecenterSceneToWorldCenter(FbxScene* pScene, FbxDouble pThreshold);
231 
253  FbxNode* MergeMeshes(FbxArray<FbxNode*>& pMeshNodes, const char* pNodeName, FbxScene* pScene);
254 
255 /*****************************************************************************************************************************
256 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
257 *****************************************************************************************************************************/
258 #ifndef DOXYGEN_SHOULD_SKIP_THIS
259  FbxGeometryConverter(FbxManager* pManager);
261 
262 private:
263  FbxMesh* TriangulateMeshInternal(const FbxMesh* pMesh);
264  FbxMesh* TriangulateMeshInternalLegacy(const FbxMesh* pMesh);
265  FbxMesh* TriangulatePatchInternal(const FbxPatch* pPatch);
266  FbxMesh* TriangulateNurbsInternal(const FbxNurbs* pNurbs);
267 
268  bool AddAlternateGeometry(FbxNode* pNode, FbxGeometry* pSrcGeom, FbxGeometry* pAltGeom, FbxWeightedMapping* pSrcToAltWeightedMapping, bool pConvertDeformations);
269  bool ConvertGeometryAnimation(FbxNode* pNode, FbxGeometry* pSrcGeom, FbxGeometry* pDstGeom);
270  void ReplaceNodeAttribute(FbxNode* pNode, FbxNodeAttribute* pNewNodeAttr);
271  bool AddTriangulatedMeshGeometry(FbxNode* pNode, int pUVStepCoeff);
272  bool CreateAndCopyLayerElement(FbxMesh *pNewMesh, FbxMesh *pRefMesh);
273  bool SetLayerElements(FbxMesh *pNewMesh, FbxMesh *pMesh, int pPolygonIndex, int pPolyPointIndex, int pLoopIndex, bool pIsSearched, bool pIsEndPolygon);
274 
292  static void FbxTriangulation(int *Index, int pNumSide);
293 
294  bool ComputePatchToMeshControlPointsWeightedMapping(FbxPatch* pSrcPatch, FbxMesh* pDstMesh, FbxWeightedMapping* pMapping, bool pSwapUV=false);
295  bool ComputeNurbsToMeshControlPointsWeightedMapping(FbxNurbsSurface* pSrcNurbs, FbxMesh* pDstMesh, FbxWeightedMapping* pMapping, bool pRescaleUVs=false, bool pSwapUV=false);
296 
297  void InitializeWeightInControlPoints(FbxGeometryBase* pGeometry);
298  void InitializeWeightInNormals(FbxLayerContainer* pLayerContainer);
299  void TriangulateContinuousSurface(FbxMesh* pMesh, FbxSurfaceEvaluator* pSurface, FbxUInt pPointCountX, FbxUInt pPointCountY, bool ClockWise=false);
300  void CheckForZeroWeightInShape(FbxGeometry *pGeometry);
301  FbxMesh* CreateMeshFromParametricSurface(const FbxGeometry* pGeometry);
302  FbxNurbs* CreateNurbsFromPatch(FbxPatch* pPatch);
303  FbxNurbsSurface* CreateNurbsSurfaceFromPatch(FbxPatch* pPatch);
304 
305  void ConvertShapes(const FbxGeometry* pSource, FbxGeometry* pDestination, FbxSurfaceEvaluator* pEvaluator, int pUCount, int pVCount);
306  void ConvertShapes(const FbxGeometry* pSource, FbxGeometry* pDestination, FbxWeightedMapping* pSourceToDestinationMapping);
307  void ConvertClusters(const FbxGeometry* pSource, FbxGeometry* pDestination, FbxWeightedMapping* pSourceToDestinationMapping);
308  void ConvertClusters(FbxArray<FbxCluster*> const& pSourceClusters, int pSourceControlPointsCount, FbxArray<FbxCluster*>& pDestinationClusters, int pDestinationControlPointsCount, FbxWeightedMapping* pSourceToDestinationMapping);
309  void BuildClusterToSourceMapping(FbxArray<FbxCluster*> const& pSourceClusters, FbxWeightedMapping* pClusterToSourceMapping);
310  void CheckClusterToSourceMapping(FbxWeightedMapping* pClusterToSourceMapping);
311  void ConvertCluster(int pSourceClusterIndex, FbxWeightedMapping* pClusterToSourceMapping, FbxWeightedMapping* pSourceToDestinationMapping, FbxCluster* pDestinationCluster);
312  void DuplicateControlPoints(FbxArray<FbxVector4>& pControlPoints, FbxArray<int>& pPolygonVertices);
313  void UpdatePolygon(FbxMesh *pNewMesh, FbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated);
314  void UpdatePolygon(FbxMesh *pNewMesh, FbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated, int pTriangleNum);
315  void ResizePolygon(FbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0, bool pClearFlag = true);
316 
317  template <class T1, class T2> void ConvertNurbs(T1* pNewNurbs, T2* pOldNurb);
318 
319  bool CopyAnimationCurves(FbxNode* pNode, FbxGeometry* pNewGeometry);
320  bool FlipNurbsCurve(FbxNurbsCurve* pCurve) const;
321  void FlipControlPoints(FbxGeometryBase* pPoints, int pUCount, int pVCount) const;
322  bool ConvertMaterialReferenceMode(FbxMesh* pMeshRef) const;
323  void RevertMaterialReferenceModeConversion(FbxMesh* pMeshRef) const;
324 
325  FbxManager* mManager;
326 
327  friend class FbxWriter3ds;
328 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
329 };
330 
331 #include <fbxsdk/fbxsdk_nsend.h>
332 
333 #endif /* _FBXSDK_UTILS_GEOMETRY_CONVERTER_H_ */
unsigned int FbxUInt
Definition: fbxtypes.h:40
FBX SDK environment definition.
SDK object manager.
Definition: fbxmanager.h:56
Contains a collection of FbxLayer objects.
Class for clusters (links).
Definition: fbxcluster.h:47
double FbxDouble
Definition: fbxtypes.h:42
Represents an element in the scene graph.
Definition: fbxnode.h:72
A patch is a type of node attribute with parametric surface.
Definition: fbxpatch.h:26
This class contains the description of a 3D scene.
Definition: fbxscene.h:61
This class is the base class for geometric object such as meshes, NURBS and patches.
A NURBS surface is a type of parametric geometry.
#define FBXSDK_DLL
Definition: fbxarch.h:170
A NURBS surface is a type of parametric geometry.
Definition: fbxnurbs.h:31
A Non-Uniform Rational B-Spline (NURBS) curve is a type of parametric geometry.
Definition: fbxnurbscurve.h:60
Define a weighted bidirectional mapping relation on objects.
The base class of geometric objects that support control point deformations (e.g. ...
Definition: fbxgeometry.h:45
This class provides the functionality to convert geometry nodes attributes (FbxMesh, FbxNurbs and FbxPatch) and mainly focuses on the two major categories: Triangulation and conversion between NURBS and Patches surfaces.
This class is the base class to all types of node attributes.
A mesh is a geometry made of polygons.
Definition: fbxmesh.h:32