FBX C++ API Reference
FbxGeometryConverter Class Reference

#include <fbxgeometryconverter.h>

Class Description

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.

Examples:
Normals/main.cxx, and ViewScene/SceneContext.cxx.

Definition at line 41 of file fbxgeometryconverter.h.

Public Member Functions

bool RecenterSceneToWorldCenter (FbxScene *pScene, FbxDouble pThreshold)
 Re-parent nodes at root node level under a new node to re-center them at world center. More...
 
FbxNodeMergeMeshes (FbxArray< FbxNode *> &pMeshNodes, const char *pNodeName, FbxScene *pScene)
 Merge multiple meshes to one mesh. More...
 
void RemoveBadPolygonsFromMeshes (FbxScene *pScene, FbxArray< FbxNode *> *pAffectedNodes=((void *) 0))
 Cleanup or remove degenerated meshes. More...
 

Triangulation Utilities

bool Triangulate (FbxScene *pScene, bool pReplace, bool pLegacy=false)
 Triangulate all node attributes in the scene that can be triangulated. More...
 
FbxNodeAttributeTriangulate (FbxNodeAttribute *pNodeAttribute, bool pReplace, bool pLegacy=false)
 Triangulate a node attribute, if supported, and preserve the skins and shapes animation channels. More...
 
bool ComputeGeometryControlPointsWeightedMapping (FbxGeometry *pSrcGeom, FbxGeometry *pDstGeom, FbxWeightedMapping *pSrcToDstWeightedMapping, bool pSwapUV=false)
 Compute a "vertex-correspondence" table that helps passing from source to destination geometry. More...
 

Geometry Conversion

FbxNurbsConvertPatchToNurbs (FbxPatch *pPatch)
 Convert from patch to nurb. More...
 
bool ConvertPatchToNurbsInPlace (FbxNode *pNode)
 Convert a patch contained in a node to a nurb. More...
 
FbxNurbsSurfaceConvertPatchToNurbsSurface (FbxPatch *pPatch)
 Convert a patch to nurb surface. More...
 
bool ConvertPatchToNurbsSurfaceInPlace (FbxNode *pNode)
 Convert a patch contained in a node to a nurb surface. More...
 
FbxNurbsSurfaceConvertNurbsToNurbsSurface (FbxNurbs *pNurbs)
 Convert a FbxNurbs to a FbxNurbsSurface. More...
 
FbxNurbsConvertNurbsSurfaceToNurbs (FbxNurbsSurface *pNurbs)
 Convert a FbxNurbsSurface to a FbxNurbs. More...
 
bool ConvertNurbsToNurbsSurfaceInPlace (FbxNode *pNode)
 Convert a nurb, contained in a node, to a nurbs surface. More...
 
bool ConvertNurbsSurfaceToNurbsInPlace (FbxNode *pNode)
 Convert a nurb contained in a node to a nurbs surface. More...
 

Nurb UV and Links Swapping

FbxNurbsFlipNurbs (FbxNurbs *pNurbs, bool pSwapUV, bool pSwapClusters)
 Flip UV and/or skin clusters of a nurb. More...
 
FbxNurbsSurfaceFlipNurbsSurface (FbxNurbsSurface *pNurbs, bool pSwapUV, bool pSwapClusters)
 Flip UV and/or skin clusters of a nurb surface. More...
 

Normals By Polygon Vertex Emulation

bool EmulateNormalsByPolygonVertex (FbxMesh *pMesh)
 Emulate normals by polygon vertex mode for a mesh. More...
 
bool ComputeEdgeSmoothingFromNormals (FbxMesh *pMesh) const
 Create edge smoothing information from polygon-vertex mapped normals. More...
 
bool ComputePolygonSmoothingFromEdgeSmoothing (FbxMesh *pMesh, int pIndex=0) const
 Convert edge smoothing to polygon smoothing group. More...
 
bool ComputeEdgeSmoothingFromPolygonSmoothing (FbxMesh *pMesh, int pIndex=0) const
 Convert polygon smoothing group to edge smoothing. More...
 

Split Mesh Per Materials

bool SplitMeshesPerMaterial (FbxScene *pScene, bool pReplace)
 Split all the mesh in the scene per material. More...
 
bool SplitMeshPerMaterial (FbxMesh *pMesh, bool pReplace)
 Split mesh per material. More...
 

Member Function Documentation

◆ Triangulate() [1/2]

bool Triangulate ( FbxScene pScene,
bool  pReplace,
bool  pLegacy = false 
)

Triangulate all node attributes in the scene that can be triangulated.

Parameters
pSceneThe scene to iterate through to triangulate meshes.
pReplaceIf true, replace the original meshes with the new triangulated meshes on all the nodes, and delete the original meshes. Otherwise, original meshes are left untouched.
pLegacyIf true, use legacy triangulation method that does not support holes in geometry. Provided for backward compatibility.
Returns
true if all node attributes that can be triangulated were triangulated successfully.
Remarks
The function will still iterate through all meshes regardless if one fails to triangulate, but will return false in that case. This function currently only supports node attribute of type eMesh, ePatch, eNurbs or eNurbsSurface.
Examples:
ViewScene/SceneContext.cxx.

◆ Triangulate() [2/2]

FbxNodeAttribute* Triangulate ( FbxNodeAttribute pNodeAttribute,
bool  pReplace,
bool  pLegacy = false 
)

Triangulate a node attribute, if supported, and preserve the skins and shapes animation channels.

Parameters
pNodeAttributePointer to the node containing the geometry to triangulate.
pReplaceIf true, replace the original geometry with the new triangulated geometry on the nodes, and delete the original geometry. Otherwise, the original geometry is left untouched, the new one is added to the nodes, and becomes the default one.
pLegacyIf true, use legacy triangulation method that does not support holes in geometry. Provided for backward compatibility.
Returns
The newly created node attribute if successful, otherwise NULL. If node attribute type is not supported by triangulation, it returns the original node attribute.
Remarks
This function currently only supports node attribute of type eMesh, ePatch, eNurbs or eNurbsSurface. If the node attribute does not support triangulation, or if it is already triangulated, this function will return pNodeAttribute.

◆ ComputeGeometryControlPointsWeightedMapping()

bool ComputeGeometryControlPointsWeightedMapping ( FbxGeometry pSrcGeom,
FbxGeometry pDstGeom,
FbxWeightedMapping pSrcToDstWeightedMapping,
bool  pSwapUV = false 
)

Compute a "vertex-correspondence" table that helps passing from source to destination geometry.

Parameters
pSrcGeomPointer to the source geometry.
pDstGeomPointer to the destination geometry.
pSrcToDstWeightedMappingPointer to the weighted mapping table.
pSwapUVSet to true to swap UVs.
Returns
true on success, false if the function fails to compute the correspondence.
Remarks
Skins and shapes are also converted to fit the alternate geometry.

◆ ConvertPatchToNurbs()

FbxNurbs* ConvertPatchToNurbs ( FbxPatch pPatch)

Convert from patch to nurb.

Parameters
pPatchPointer to the patch to convert.
Returns
Created nurb or NULL if the conversion fails.
Remarks
The patch must be of type eBSpline, eBezier or eLinear.

◆ ConvertPatchToNurbsInPlace()

bool ConvertPatchToNurbsInPlace ( FbxNode pNode)

Convert a patch contained in a node to a nurb.

Use this function to preserve the patch's skins and shapes animation channels.

Parameters
pNodePointer to the node containing the patch.
Returns
true on success, false if the node attribute is not a patch.
Remarks
The patch must be of type eBSpline, eBezier or eLinear.

◆ ConvertPatchToNurbsSurface()

FbxNurbsSurface* ConvertPatchToNurbsSurface ( FbxPatch pPatch)

Convert a patch to nurb surface.

Parameters
pPatchPointer to the patch to convert.
Returns
Created nurb surface or NULL if conversion fails.
Remarks
The patch must be of type eBSpline, eBezier or eLinear.

◆ ConvertPatchToNurbsSurfaceInPlace()

bool ConvertPatchToNurbsSurfaceInPlace ( FbxNode pNode)

Convert a patch contained in a node to a nurb surface.

Use this function to preserve the patch's skins and shapes animation channels.

Parameters
pNodePointer to the node containing the patch.
Returns
true on success, false if the node attribute is not a patch.
Remarks
The patch must be of type eBSpline, eBezier or eLinear.

◆ ConvertNurbsToNurbsSurface()

FbxNurbsSurface* ConvertNurbsToNurbsSurface ( FbxNurbs pNurbs)

Convert a FbxNurbs to a FbxNurbsSurface.

Parameters
pNurbsPointer to the original nurb
Returns
A FbxNurbsSurface that is equivalent to the original nurb.

◆ ConvertNurbsSurfaceToNurbs()

FbxNurbs* ConvertNurbsSurfaceToNurbs ( FbxNurbsSurface pNurbs)

Convert a FbxNurbsSurface to a FbxNurbs.

Parameters
pNurbsPointer to the original nurbs surface
Returns
A FbxNurbs that is equivalent to the original nurbs surface.

◆ ConvertNurbsToNurbsSurfaceInPlace()

bool ConvertNurbsToNurbsSurfaceInPlace ( FbxNode pNode)

Convert a nurb, contained in a node, to a nurbs surface.

Use this function to preserve the nurb's skins and shapes animation channels.

Parameters
pNodePointer to the node containing the nurb.
Returns
true on success, false otherwise

◆ ConvertNurbsSurfaceToNurbsInPlace()

bool ConvertNurbsSurfaceToNurbsInPlace ( FbxNode pNode)

Convert a nurb contained in a node to a nurbs surface.

Use this function to preserve the nurb's skins and shapes animation channels.

Parameters
pNodePointer to the node containing the nurbs surface.
Returns
true on success, false otherwise

◆ FlipNurbs()

FbxNurbs* FlipNurbs ( FbxNurbs pNurbs,
bool  pSwapUV,
bool  pSwapClusters 
)

Flip UV and/or skin clusters of a nurb.

Parameters
pNurbsPointer to the Source nurb.
pSwapUVSet to true to swap the UVs.
pSwapClustersSet to true to swap the control point indices of clusters.
Returns
A flipped FbxNurbs, or NULL if the function fails.

◆ FlipNurbsSurface()

FbxNurbsSurface* FlipNurbsSurface ( FbxNurbsSurface pNurbs,
bool  pSwapUV,
bool  pSwapClusters 
)

Flip UV and/or skin clusters of a nurb surface.

Parameters
pNurbsPointer to the Source nurb surface.
pSwapUVSet to true to swap the UVs.
pSwapClustersSet to true to swap the control point indices of clusters.
Returns
A flipped FbxNurbsSurface, or NULL if the function fails.

◆ EmulateNormalsByPolygonVertex()

bool EmulateNormalsByPolygonVertex ( FbxMesh pMesh)

Emulate normals by polygon vertex mode for a mesh.

Parameters
pMeshPointer to the mesh object.
Returns
true on success, false if the number of normals in the mesh and in its associated shapes don't match the number of polygon vertices.
Remarks
For applications that only supports normals by control points, this function duplicates control points to equal the number of polygon vertices. skins and shapes are also converted. As preconditions:
  1. polygons must have been created
  2. the number of normals in the mesh and in its associated shapes must match the number of polygon vertices.

◆ ComputeEdgeSmoothingFromNormals()

bool ComputeEdgeSmoothingFromNormals ( FbxMesh pMesh) const

Create edge smoothing information from polygon-vertex mapped normals.

Existing smoothing information is removed and edge data is created if none exists on the mesh.

Parameters
pMeshThe mesh used to generate edge smoothing.
Returns
true on success, false otherwise.
Remarks
The edge smoothing data is placed on Layer 0 of the mesh. Normals do not need to be on Layer 0, since the first layer with per polygon vertex normals is used.

◆ ComputePolygonSmoothingFromEdgeSmoothing()

bool ComputePolygonSmoothingFromEdgeSmoothing ( FbxMesh pMesh,
int  pIndex = 0 
) const

Convert edge smoothing to polygon smoothing group.

Existing smoothing information is replaced.

Parameters
pMeshThe mesh that contains the smoothing to be converted.
pIndexThe index of the layer smoothing to be converted.
Returns
true on success, false otherwise.
Remarks
The smoothing group is bitwise. Each bit of the integer represents one smoothing group. Therefore, there is a maximum of 32 smoothing groups.

◆ ComputeEdgeSmoothingFromPolygonSmoothing()

bool ComputeEdgeSmoothingFromPolygonSmoothing ( FbxMesh pMesh,
int  pIndex = 0 
) const

Convert polygon smoothing group to edge smoothing.

Existing smoothing information is replaced.

Parameters
pMeshThe mesh that contains the smoothing to be converted.
pIndexThe index of the layer smoothing to be converted
Returns
true on success, false otherwise.

◆ SplitMeshesPerMaterial()

bool SplitMeshesPerMaterial ( FbxScene pScene,
bool  pReplace 
)

Split all the mesh in the scene per material.

Parameters
pSceneThe scene to iterate through to split meshes.
pReplaceIf true, replace the original mesh with new ones and delete the original meshes, but only if they got split into multiple meshes, otherwise they are left untouched.
Returns
true if all splitable mesh were successfully split, false otherwise.
Remarks
The function will still iterate through all meshes regardless if one fails to split, but will return false in that case.

◆ SplitMeshPerMaterial()

bool SplitMeshPerMaterial ( FbxMesh pMesh,
bool  pReplace 
)

Split mesh per material.

Parameters
pMeshThe mesh that will be split if it has multiple materials assigned.
pReplaceIf true, replace the original mesh with new one and delete the original mesh, but only if they got split into multiple meshes, otherwise left untouched.
Returns
true on success, false otherwise.
Remarks
The function will fail if the mapped material is not per face (FbxLayerElement::eByPolygon) or if a material is multi-layered. It will create as many meshes as there are materials applied to it. If one mesh have some polygons with material A, some polygons with material B, and some polygons with NO material, 3 meshes distinct will be created. The newly created meshes will be automatically attached to the same FbxNode that holds the original FbxMesh. If the original mesh have tangents, they will be regenerated on the new meshes.

◆ RecenterSceneToWorldCenter()

bool RecenterSceneToWorldCenter ( FbxScene pScene,
FbxDouble  pThreshold 
)

Re-parent nodes at root node level under a new node to re-center them at world center.

Basically, this function calculates the scene bounding box in world coordinates, and test if the center of that bounding box distance from the world center is larger or equal than the threshold. If true, a new node with the proper negative offset position will become the new parent of all nodes at root node level.

Parameters
pSceneThe scene to process.
pThresholdThreshold at which all nodes will be re-centered.
Returns
true if any nodes were re-centered, otherwise false.

◆ MergeMeshes()

FbxNode* MergeMeshes ( FbxArray< FbxNode *> &  pMeshNodes,
const char *  pNodeName,
FbxScene pScene 
)

Merge multiple meshes to one mesh.

The method will merge: a) mesh vertex; b) mesh polygon; c) mesh edge; d) all mesh elements; only the layer 0 elements is merged. e) if there are skins for old mesh, merge these skins. The new skin clusters link to old skeletons.

Parameters
pMeshNodesFBX nodes that hold multiple meshes. These meshes will be merged.
pNodeNameName of new mesh node.
pSceneThe scene that will contain the new mesh node.
Returns
The new mesh node if merge successfully, otherwise NULL is returned.
Remarks
This method creates a new mesh, leaving the source mesh unchanged. The transform of new mesh node is: translate (0, 0, 0), rotation (0, 0, 0), scale (1, 1, 1). For layer element material, normal, smoothing, UV set, vertex color, binormal, tangent and polygon group, if any mesh misses these element, the merge for this kind of element is skipped. For layer element crease, hole, visibility and user data, if any mesh has such element, the kind of element will be merged. The missing element will be filled with default values. For meshes with skin binding, if the pose of frame 0 is different with bind pose, the new mesh will be distorted.

◆ RemoveBadPolygonsFromMeshes()

void RemoveBadPolygonsFromMeshes ( FbxScene pScene,
FbxArray< FbxNode *> *  pAffectedNodes = ((void *) 0) 
)

Cleanup or remove degenerated meshes.

Parameters
pSceneThe scene to process.
pAffectedNodesThe list of nodes that have been affected by this operation.
Remarks
If the cleaned-up mesh becomes invalid, it is removed entirely.

The documentation for this class was generated from the following file: