FBX C++ API Reference
fbxgeometryconverter.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2015 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 class FbxScene;
31 class FbxNode;
32 class FbxNodeAttribute;
33 class FbxGeometry;
34 
42 {
43 public:
53  bool Triangulate(FbxScene* pScene, bool pReplace, bool pLegacy=false);
54 
63  FbxNodeAttribute* Triangulate(FbxNodeAttribute* pNodeAttribute, bool pReplace, bool pLegacy=false);
64 
72  bool ComputeGeometryControlPointsWeightedMapping(FbxGeometry* pSrcGeom, FbxGeometry* pDstGeom, FbxWeightedMapping* pSrcToDstWeightedMapping, bool pSwapUV=false);
74 
84  FbxNurbs* ConvertPatchToNurbs(FbxPatch *pPatch);
85 
92  bool ConvertPatchToNurbsInPlace(FbxNode* pNode);
93 
99  FbxNurbsSurface* ConvertPatchToNurbsSurface(FbxPatch *pPatch);
100 
107  bool ConvertPatchToNurbsSurfaceInPlace(FbxNode* pNode);
108 
113  FbxNurbsSurface* ConvertNurbsToNurbsSurface( FbxNurbs* pNurbs );
114 
119  FbxNurbs* ConvertNurbsSurfaceToNurbs( FbxNurbsSurface* pNurbs );
120 
126  bool ConvertNurbsToNurbsSurfaceInPlace(FbxNode* pNode);
127 
133  bool ConvertNurbsSurfaceToNurbsInPlace(FbxNode* pNode);
135 
146  FbxNurbs* FlipNurbs(FbxNurbs* pNurbs, bool pSwapUV, bool pSwapClusters);
147 
154  FbxNurbsSurface* FlipNurbsSurface(FbxNurbsSurface* pNurbs, bool pSwapUV, bool pSwapClusters);
156 
174  bool EmulateNormalsByPolygonVertex(FbxMesh* pMesh);
175 
185  bool ComputeEdgeSmoothingFromNormals( FbxMesh* pMesh ) const;
186 
196  bool ComputePolygonSmoothingFromEdgeSmoothing( FbxMesh* pMesh, int pIndex=0 ) const;
197 
205  bool ComputeEdgeSmoothingFromPolygonSmoothing( FbxMesh* pMesh, int pIndex=0 ) const;
207 
215  bool SplitMeshesPerMaterial(FbxScene* pScene, bool pReplace);
216 
225  bool SplitMeshPerMaterial(FbxMesh* pMesh, bool pReplace);
227 
234  bool RecenterSceneToWorldCenter(FbxScene* pScene, FbxDouble pThreshold);
235 
257  FbxNode* MergeMeshes(FbxArray<FbxNode*>& pMeshNodes, const char* pNodeName, FbxScene* pScene);
258 
265  void RemoveBadPolygonsFromMeshes(FbxScene* pScene, FbxArray<FbxNode*>* pAffectedNodes = NULL);
266 
267 /*****************************************************************************************************************************
268 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
269 *****************************************************************************************************************************/
270 #ifndef DOXYGEN_SHOULD_SKIP_THIS
271  FbxGeometryConverter(FbxManager* pManager);
273 
274 private:
275  FbxMesh* TriangulateMeshInternal(const FbxMesh* pMesh);
276  FbxMesh* TriangulateMeshInternalLegacy(const FbxMesh* pMesh);
277  FbxMesh* TriangulatePatchInternal(const FbxPatch* pPatch);
278  FbxMesh* TriangulateNurbsInternal(const FbxNurbs* pNurbs);
279 
280  bool AddAlternateGeometry(FbxNode* pNode, FbxGeometry* pSrcGeom, FbxGeometry* pAltGeom, FbxWeightedMapping* pSrcToAltWeightedMapping, bool pConvertDeformations);
281  bool ConvertGeometryAnimation(FbxNode* pNode, FbxGeometry* pSrcGeom, FbxGeometry* pDstGeom);
282  void ReplaceNodeAttribute(FbxNode* pNode, FbxNodeAttribute* pNewNodeAttr);
283  bool AddTriangulatedMeshGeometry(FbxNode* pNode, int pUVStepCoeff);
284  bool CreateAndCopyLayerElement(FbxMesh *pNewMesh, FbxMesh *pRefMesh);
285  bool SetLayerElements(FbxMesh *pNewMesh, FbxMesh *pMesh, int pPolygonIndex, int pPolyPointIndex, int pLoopIndex, bool pIsSearched, bool pIsEndPolygon);
286 
304  static void FbxTriangulation(int *Index, int pNumSide);
305 
306  bool ComputePatchToMeshControlPointsWeightedMapping(FbxPatch* pSrcPatch, FbxMesh* pDstMesh, FbxWeightedMapping* pMapping, bool pSwapUV=false);
307  bool ComputeNurbsToMeshControlPointsWeightedMapping(FbxNurbsSurface* pSrcNurbs, FbxMesh* pDstMesh, FbxWeightedMapping* pMapping, bool pRescaleUVs=false, bool pSwapUV=false);
308 
309  void InitializeWeightInControlPoints(FbxGeometryBase* pGeometry);
310  void InitializeWeightInNormals(FbxLayerContainer* pLayerContainer);
311  void TriangulateContinuousSurface(FbxMesh* pMesh, FbxSurfaceEvaluator* pSurface, FbxUInt pPointCountX, FbxUInt pPointCountY, bool ClockWise=false);
312  void CheckForZeroWeightInShape(FbxGeometry *pGeometry);
313  FbxMesh* CreateMeshFromParametricSurface(const FbxGeometry* pGeometry);
314  FbxNurbs* CreateNurbsFromPatch(FbxPatch* pPatch);
315  FbxNurbsSurface* CreateNurbsSurfaceFromPatch(FbxPatch* pPatch);
316 
317  void ConvertShapes(const FbxGeometry* pSource, FbxGeometry* pDestination, FbxSurfaceEvaluator* pEvaluator, int pUCount, int pVCount);
318  void ConvertShapes(const FbxGeometry* pSource, FbxGeometry* pDestination, FbxWeightedMapping* pSourceToDestinationMapping);
319  void ConvertClusters(const FbxGeometry* pSource, FbxGeometry* pDestination, FbxWeightedMapping* pSourceToDestinationMapping);
320  void ConvertClusters(FbxArray<FbxCluster*> const& pSourceClusters, int pSourceControlPointsCount, FbxArray<FbxCluster*>& pDestinationClusters, int pDestinationControlPointsCount, FbxWeightedMapping* pSourceToDestinationMapping);
321  void BuildClusterToSourceMapping(FbxArray<FbxCluster*> const& pSourceClusters, FbxWeightedMapping* pClusterToSourceMapping);
322  void CheckClusterToSourceMapping(FbxWeightedMapping* pClusterToSourceMapping);
323  void ConvertCluster(int pSourceClusterIndex, FbxWeightedMapping* pClusterToSourceMapping, FbxWeightedMapping* pSourceToDestinationMapping, FbxCluster* pDestinationCluster);
324  void DuplicateControlPoints(FbxArray<FbxVector4>& pControlPoints, FbxArray<int>& pPolygonVertices);
325  void UpdatePolygon(FbxMesh *pNewMesh, FbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated);
326  void UpdatePolygon(FbxMesh *pNewMesh, FbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated, int pTriangleNum);
327  void ResizePolygon(FbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0, bool pClearFlag = true);
328 
329  template <class T1, class T2> void ConvertNurbs(T1* pNewNurbs, T2* pOldNurb);
330 
331  bool CopyAnimationCurves(FbxNode* pNode, FbxGeometry* pNewGeometry);
332  bool FlipNurbsCurve(FbxNurbsCurve* pCurve) const;
333  void FlipControlPoints(FbxGeometryBase* pPoints, int pUCount, int pVCount) const;
334  bool ConvertMaterialReferenceMode(FbxMesh* pMeshRef) const;
335  void RevertMaterialReferenceModeConversion(FbxMesh* pMeshRef) const;
336 
337  FbxManager* mManager;
338 
339  friend class FbxWriter3ds;
340 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
341 };
342 
343 #include <fbxsdk/fbxsdk_nsend.h>
344 
345 #endif /* _FBXSDK_UTILS_GEOMETRY_CONVERTER_H_ */
unsigned int FbxUInt
Definition: fbxtypes.h:40
FBX SDK environment definition.
SDK object manager.
Definition: fbxmanager.h:56
#define NULL
Definition: fbxarch.h:210
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:173
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.
Class for array of basic elements such as pointers and basic types.
Definition: fbxarray.h:23
A mesh is a geometry made of polygons.
Definition: fbxmesh.h:32