FBX SDK Reference Guide: kfbxgeometryconverter.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2001 - 2008 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
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 //  WARNING!
00298 //
00299 //  Anything beyond these lines may not be documented accurately and is 
00300 //  subject to change without notice.
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     //Split Meshes Per Material
00342     //for each mesh in pScene
00343     bool SplitMeshesPerMaterial(KFbxScene* pScene);
00344     
00345     //create layerElement, and copy settings from  pRefMesh to pNewMesh
00346     bool CreateAndCopyLayerElement(KFbxMesh *pNewMesh, KFbxMesh *pRefMesh);
00347     
00348     //set UVs and Vertex Color, when building new mesh. 
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