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
00042 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <fbxfilesdk/components/kbaselib/kaydara.h>
00044
00045 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00046
00047 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00048
00049 class KFbxNode;
00050 class KFbxLayerContainer;
00051 class KFbxGeometryBase;
00052 class KFbxGeometry;
00053 class KFbxMesh;
00054 class KFbxPatch;
00055 class KFbxNurb;
00056 class KFbxCluster;
00057 class KFbxSdkManager;
00058 class KFBXSurfaceEvaluator;
00059 class KFbxWeightedMapping;
00060 class KFbxVector4;
00061 class KFbxNurbsSurface;
00062 class KFbxNurbsCurve;
00063
00064 class KFbxShape;
00065 class KFbxScene;
00066 class KFbxVector2;
00067 class KString;
00072 class KFBX_DLL KFbxGeometryConverter
00073 {
00074 public:
00075 KFbxGeometryConverter(KFbxSdkManager* pManager);
00076 ~KFbxGeometryConverter();
00077
00082
00088 KFbxMesh* TriangulateMesh(KFbxMesh const* pMesh);
00089
00095 KFbxMesh* TriangulatePatch(KFbxPatch const* pPatch);
00096
00102 KFbxMesh* TriangulateNurb(KFbxNurb const* pNurb);
00103
00110 bool TriangulateInPlace(KFbxNode* pNode);
00111
00121 bool AddAlternateGeometry(
00122 KFbxNode* pNode,
00123 KFbxGeometry* pSrcGeom,
00124 KFbxGeometry* pAltGeom,
00125 KFbxWeightedMapping* pSrcToAltWeightedMapping,
00126 bool pConvertDeformations
00127 );
00128
00136 bool ConvertGeometryAnimation(
00137 KFbxNode* pNode,
00138 KFbxGeometry* pSrcGeom,
00139 KFbxGeometry* pDstGeom
00140 );
00141
00150 bool ComputeGeometryControlPointsWeightedMapping(
00151 KFbxGeometry* pSrcGeom,
00152 KFbxGeometry* pDstGeom,
00153 KFbxWeightedMapping* pSrcToDstWeightedMapping,
00154 bool pSwapUV = false
00155 );
00156
00158
00163
00169 KFbxNurb* ConvertPatchToNurb(KFbxPatch *pPatch);
00170
00176 bool ConvertPatchToNurbInPlace(KFbxNode* pNode);
00177
00183 KFbxNurbsSurface* ConvertPatchToNurbsSurface(KFbxPatch *pPatch);
00184
00190 bool ConvertPatchToNurbsSurfaceInPlace(KFbxNode* pNode);
00191
00196 KFbxNurbsSurface* ConvertNurbToNurbsSurface( KFbxNurb* pNurb );
00197
00202 KFbxNurb* ConvertNurbsSurfaceToNurb( KFbxNurbsSurface* pNurb );
00203
00208 bool ConvertNurbToNurbsSurfaceInPlace(KFbxNode* pNode);
00209
00214 bool ConvertNurbsSurfaceToNurbInPlace(KFbxNode* pNode);
00215
00217
00222
00229 KFbxNurb* FlipNurb(KFbxNurb* pNurb, bool pSwapUV, bool pSwapClusters);
00230
00237 KFbxNurbsSurface* FlipNurbsSurface(KFbxNurbsSurface* pNurb, bool pSwapUV, bool pSwapClusters);
00238
00240
00245
00259 bool EmulateNormalsByPolygonVertex(KFbxMesh* pMesh);
00260
00270 bool ComputeEdgeSmoothingFromNormals( KFbxMesh* pMesh ) const;
00271
00281 bool ComputePolygonSmoothingFromEdgeSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00282
00290 bool ComputeEdgeSmoothingFromPolygonSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00291
00293
00294
00296
00297
00298
00299
00300
00301
00303
00304 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00305
00306 public:
00307
00315 bool AddTriangulatedMeshGeometry(KFbxNode* pNode, int pUVStepCoeff);
00316
00321
00336 bool SplitMeshPerMaterial(KFbxMesh* pMesh);
00337
00339
00340
00341
00342
00343 bool SplitMeshesPerMaterial(KFbxScene* pScene);
00344
00345
00346 bool CreateAndCopyLayerElement(KFbxMesh *pNewMesh, KFbxMesh *pRefMesh);
00347
00348
00349 bool SetUVsAndVertexColor(KFbxMesh *pNewMesh, KFbxMesh *pMesh, int pPolygonIndex, int pPolyPointIndex, int pLoopIndex, bool pIsSearched);
00350
00351
00352 protected:
00353
00354 bool ComputePatchToMeshControlPointsWeightedMapping
00355 (
00356 KFbxPatch* pSrcPatch,
00357 KFbxMesh* pDstMesh,
00358 KFbxWeightedMapping* pMapping,
00359 bool pSwapUV = false
00360 );
00361 bool ComputeNurbToMeshControlPointsWeightedMapping
00362 (
00363 KFbxNurbsSurface* pSrcNurb,
00364 KFbxMesh* pDstMesh,
00365 KFbxWeightedMapping* pMapping,
00366 bool pRescaleUVs = false,
00367 bool pSwapUV = false
00368 );
00369
00370 void InitializeWeightInControlPoints(KFbxGeometryBase* pGeometry);
00371 void InitializeWeightInNormals(KFbxLayerContainer* pLayerContainer);
00372 void TriangulateContinuousSurface
00373 (
00374 KFbxMesh* pMesh,
00375 KFBXSurfaceEvaluator* pSurface,
00376 kUInt pPointCountX,
00377 kUInt pPointCountY,
00378 bool ClockWise = false
00379 );
00380 void CheckForZeroWeightInShape(KFbxGeometry *pGeometry);
00381 KFbxMesh* CreateMeshFromParametricSurface(KFbxGeometry const* pGeometry);
00382 KFbxNurb* CreateNurbFromPatch(KFbxPatch* pPatch);
00383 KFbxNurbsSurface* CreateNurbsSurfaceFromPatch(KFbxPatch* pPatch);
00384
00385 void ConvertShapes(KFbxGeometry const* pSource,
00386 KFbxGeometry* pDestination,
00387 KFBXSurfaceEvaluator* pEvaluator,
00388 int pUCount,
00389 int pVCount);
00390 void ConvertShapes(KFbxGeometry const* pSource,
00391 KFbxGeometry* pDestination,
00392 KFbxWeightedMapping* pSourceToDestinationMapping);
00393 void ConvertClusters(KFbxGeometry const* pSource,
00394 KFbxGeometry* pDestination,
00395 KFbxWeightedMapping* pSourceToDestinationMapping);
00396 void ConvertClusters(KArrayTemplate<KFbxCluster*> const& pSourceClusters,
00397 int pSourceControlPointsCount,
00398 KArrayTemplate<KFbxCluster*>& pDestinationClusters,
00399 int pDestinationControlPointsCount,
00400 KFbxWeightedMapping* pSourceToDestinationMapping);
00401 void BuildClusterToSourceMapping(KArrayTemplate<KFbxCluster*> const& pSourceClusters,
00402 KFbxWeightedMapping* pClusterToSourceMapping);
00403 void CheckClusterToSourceMapping(KFbxWeightedMapping* pClusterToSourceMapping);
00404 void ConvertCluster(int pSourceClusterIndex,
00405 KFbxWeightedMapping* pClusterToSourceMapping,
00406 KFbxWeightedMapping* pSourceToDestinationMapping,
00407 KFbxCluster* pDestinationCluster);
00408 void DuplicateControlPoints(KArrayTemplate<KFbxVector4>& pControlPoints,
00409 KArrayTemplate<int>& pPolygonVertices);
00410 void UpdatePolygon(KFbxMesh *pNewMesh,
00411 KFbxMesh const *pRefMesh,
00412 int pPolygonIndex,
00413 int* pNewIndex,
00414 int &pVerticeIndexMeshTriangulated,
00415 int &pPolygonIndexMeshTriangulated);
00416 void ClearPolygon(KFbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0);
00417
00418 template <class T1, class T2>
00419 void ConvertNurbs( T1* pNewNurb, T2* pOldNurb );
00420
00421 bool CopyAnimationCurves(KFbxNode* pNode, KFbxGeometry* pNewGeometry );
00422
00423 bool FlipNurbsCurve( KFbxNurbsCurve* pCurve ) const;
00424
00425 void FlipControlPoints( KFbxGeometryBase* pPoints, int pUCount, int pVCount ) const;
00426
00427 bool ConvertMaterialReferenceMode( KFbxMesh* pMeshRef ) const;
00428
00429 void RevertMaterialReferenceModeConversion( KFbxMesh* pMeshRef ) const;
00430
00431 KFbxSdkManager* mManager;
00432
00433 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00434
00435 };
00436
00437 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00438
00439 #endif // FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00440