00001
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042
00043 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00044
00045 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00046
00047 class KFbxNode;
00048 class KFbxLayerContainer;
00049 class KFbxGeometryBase;
00050 class KFbxGeometry;
00051 class KFbxMesh;
00052 class KFbxPatch;
00053 class KFbxNurb;
00054 class KFbxCluster;
00055 class KFbxSdkManager;
00056 class KFBXSurfaceEvaluator;
00057 class KFbxWeightedMapping;
00058 class KFbxVector4;
00059 class KFbxNurbsSurface;
00060 class KFbxNurbsCurve;
00061
00062 class KFbxShape;
00063 class KFbxScene;
00064 class KFbxVector2;
00065 class KString;
00072 class KFBX_DLL KFbxGeometryConverter
00073 {
00074 public:
00075 KFbxGeometryConverter(KFbxSdkManager* pManager);
00076 ~KFbxGeometryConverter();
00077
00087 KFbxMesh* TriangulateMesh(KFbxMesh const* pMesh);
00088
00095 KFbxMesh* TriangulatePatch(KFbxPatch const* pPatch);
00096
00103 KFbxMesh* TriangulateNurb(KFbxNurb const* pNurb);
00104
00111 bool TriangulateInPlace(KFbxNode* pNode);
00112
00124 bool AddAlternateGeometry(
00125 KFbxNode* pNode,
00126 KFbxGeometry* pSrcGeom,
00127 KFbxGeometry* pAltGeom,
00128 KFbxWeightedMapping* pSrcToAltWeightedMapping,
00129 bool pConvertDeformations
00130 );
00131
00141 bool ConvertGeometryAnimation(
00142 KFbxNode* pNode,
00143 KFbxGeometry* pSrcGeom,
00144 KFbxGeometry* pDstGeom
00145 );
00146
00155 bool ComputeGeometryControlPointsWeightedMapping(
00156 KFbxGeometry* pSrcGeom,
00157 KFbxGeometry* pDstGeom,
00158 KFbxWeightedMapping* pSrcToDstWeightedMapping,
00159 bool pSwapUV = false
00160 );
00161
00163
00168
00174 KFbxNurb* ConvertPatchToNurb(KFbxPatch *pPatch);
00175
00182 bool ConvertPatchToNurbInPlace(KFbxNode* pNode);
00183
00189 KFbxNurbsSurface* ConvertPatchToNurbsSurface(KFbxPatch *pPatch);
00190
00197 bool ConvertPatchToNurbsSurfaceInPlace(KFbxNode* pNode);
00198
00203 KFbxNurbsSurface* ConvertNurbToNurbsSurface( KFbxNurb* pNurb );
00204
00209 KFbxNurb* ConvertNurbsSurfaceToNurb( KFbxNurbsSurface* pNurb );
00210
00216 bool ConvertNurbToNurbsSurfaceInPlace(KFbxNode* pNode);
00217
00223 bool ConvertNurbsSurfaceToNurbInPlace(KFbxNode* pNode);
00224
00226
00231
00238 KFbxNurb* FlipNurb(KFbxNurb* pNurb, bool pSwapUV, bool pSwapClusters);
00239
00246 KFbxNurbsSurface* FlipNurbsSurface(KFbxNurbsSurface* pNurb, bool pSwapUV, bool pSwapClusters);
00247
00249
00254
00268 bool EmulateNormalsByPolygonVertex(KFbxMesh* pMesh);
00269
00279 bool ComputeEdgeSmoothingFromNormals( KFbxMesh* pMesh ) const;
00280
00290 bool ComputePolygonSmoothingFromEdgeSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00291
00299 bool ComputeEdgeSmoothingFromPolygonSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00300
00302
00303
00305
00306
00307
00308
00309
00310
00312
00313 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00314
00315 public:
00316
00325 bool AddTriangulatedMeshGeometry(KFbxNode* pNode, int pUVStepCoeff);
00326
00331
00345 bool SplitMeshPerMaterial(KFbxMesh* pMesh);
00346
00348
00353 bool SplitMeshesPerMaterial(KFbxScene* pScene);
00354
00360 bool CreateAndCopyLayerElement(KFbxMesh *pNewMesh, KFbxMesh *pRefMesh);
00361
00367 bool SetLayerElements(KFbxMesh *pNewMesh, KFbxMesh *pMesh, int pPolygonIndex, int pPolyPointIndex, int pLoopIndex, bool pIsSearched, bool pIsEndPolygon);
00368
00375 KFbxMesh* TriangulateMeshAdvance(KFbxMesh const* pMesh, bool& pStatus);
00376
00389 int TriangulatePolygon(KFbxMesh *pNewMesh, KFbxVector4 *pControlPoints, int* pVertexIndices, int * pPolyVertexIndices, int pStartVertexIndex, KFbxVector4& pNormal, int pMaterialIndex, int pPolygonSize, int polygonIndex);
00390
00391
00392 protected:
00393
00394 bool ComputePatchToMeshControlPointsWeightedMapping
00395 (
00396 KFbxPatch* pSrcPatch,
00397 KFbxMesh* pDstMesh,
00398 KFbxWeightedMapping* pMapping,
00399 bool pSwapUV = false
00400 );
00401 bool ComputeNurbToMeshControlPointsWeightedMapping
00402 (
00403 KFbxNurbsSurface* pSrcNurb,
00404 KFbxMesh* pDstMesh,
00405 KFbxWeightedMapping* pMapping,
00406 bool pRescaleUVs = false,
00407 bool pSwapUV = false
00408 );
00409
00410 void InitializeWeightInControlPoints(KFbxGeometryBase* pGeometry);
00411 void InitializeWeightInNormals(KFbxLayerContainer* pLayerContainer);
00412 void TriangulateContinuousSurface
00413 (
00414 KFbxMesh* pMesh,
00415 KFBXSurfaceEvaluator* pSurface,
00416 kUInt pPointCountX,
00417 kUInt pPointCountY,
00418 bool ClockWise = false
00419 );
00420 void CheckForZeroWeightInShape(KFbxGeometry *pGeometry);
00421 KFbxMesh* CreateMeshFromParametricSurface(KFbxGeometry const* pGeometry);
00422 KFbxNurb* CreateNurbFromPatch(KFbxPatch* pPatch);
00423 KFbxNurbsSurface* CreateNurbsSurfaceFromPatch(KFbxPatch* pPatch);
00424
00425 void ConvertShapes(KFbxGeometry const* pSource,
00426 KFbxGeometry* pDestination,
00427 KFBXSurfaceEvaluator* pEvaluator,
00428 int pUCount,
00429 int pVCount);
00430 void ConvertShapes(KFbxGeometry const* pSource,
00431 KFbxGeometry* pDestination,
00432 KFbxWeightedMapping* pSourceToDestinationMapping);
00433 void ConvertClusters(KFbxGeometry const* pSource,
00434 KFbxGeometry* pDestination,
00435 KFbxWeightedMapping* pSourceToDestinationMapping);
00436 void ConvertClusters(KArrayTemplate<KFbxCluster*> const& pSourceClusters,
00437 int pSourceControlPointsCount,
00438 KArrayTemplate<KFbxCluster*>& pDestinationClusters,
00439 int pDestinationControlPointsCount,
00440 KFbxWeightedMapping* pSourceToDestinationMapping);
00441 void BuildClusterToSourceMapping(KArrayTemplate<KFbxCluster*> const& pSourceClusters,
00442 KFbxWeightedMapping* pClusterToSourceMapping);
00443 void CheckClusterToSourceMapping(KFbxWeightedMapping* pClusterToSourceMapping);
00444 void ConvertCluster(int pSourceClusterIndex,
00445 KFbxWeightedMapping* pClusterToSourceMapping,
00446 KFbxWeightedMapping* pSourceToDestinationMapping,
00447 KFbxCluster* pDestinationCluster);
00448 void DuplicateControlPoints(KArrayTemplate<KFbxVector4>& pControlPoints,
00449 KArrayTemplate<int>& pPolygonVertices);
00450 void UpdatePolygon(KFbxMesh *pNewMesh, KFbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated);
00451 void UpdatePolygon(KFbxMesh *pNewMesh, KFbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated, int pTriangleNum);
00452 void ResizePolygon(KFbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0, bool pClearFlag = true);
00453
00454 template <class T1, class T2>
00455 void ConvertNurbs( T1* pNewNurb, T2* pOldNurb );
00456
00457 bool CopyAnimationCurves(KFbxNode* pNode, KFbxGeometry* pNewGeometry );
00458
00459 bool FlipNurbsCurve( KFbxNurbsCurve* pCurve ) const;
00460
00461 void FlipControlPoints( KFbxGeometryBase* pPoints, int pUCount, int pVCount ) const;
00462
00463 bool ConvertMaterialReferenceMode( KFbxMesh* pMeshRef ) const;
00464
00465 void RevertMaterialReferenceModeConversion( KFbxMesh* pMeshRef ) const;
00466
00467 KFbxSdkManager* mManager;
00468
00469 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00470
00471 };
00472
00473 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00474
00475 #endif // FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00476