kfbxgeometryconverter.h

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 (C) 2001 - 2009 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 
00087     KFbxMesh* TriangulateMesh(KFbxMesh const* pMesh);
00088 
00094     KFbxMesh* TriangulatePatch(KFbxPatch const* pPatch);
00095 
00101     KFbxMesh* TriangulateNurb(KFbxNurb const* pNurb);
00102 
00109     bool TriangulateInPlace(KFbxNode* pNode);
00110 
00120     bool AddAlternateGeometry(
00121         KFbxNode*             pNode, 
00122         KFbxGeometry*         pSrcGeom, 
00123         KFbxGeometry*         pAltGeom,
00124         KFbxWeightedMapping* pSrcToAltWeightedMapping,
00125         bool                 pConvertDeformations
00126         );
00127 
00135     bool ConvertGeometryAnimation(
00136         KFbxNode*             pNode, 
00137         KFbxGeometry*         pSrcGeom, 
00138         KFbxGeometry*         pDstGeom
00139         );
00140 
00149     bool ComputeGeometryControlPointsWeightedMapping(
00150         KFbxGeometry*         pSrcGeom, 
00151         KFbxGeometry*         pDstGeom, 
00152         KFbxWeightedMapping* pSrcToDstWeightedMapping,
00153         bool                 pSwapUV = false
00154         );
00155 
00157 
00162 
00168     KFbxNurb* ConvertPatchToNurb(KFbxPatch *pPatch);
00169 
00175     bool ConvertPatchToNurbInPlace(KFbxNode* pNode);
00176 
00182     KFbxNurbsSurface* ConvertPatchToNurbsSurface(KFbxPatch *pPatch);
00183 
00189     bool ConvertPatchToNurbsSurfaceInPlace(KFbxNode* pNode);
00190 
00195     KFbxNurbsSurface* ConvertNurbToNurbsSurface( KFbxNurb* pNurb );
00196 
00201     KFbxNurb* ConvertNurbsSurfaceToNurb( KFbxNurbsSurface* pNurb );
00202 
00207     bool ConvertNurbToNurbsSurfaceInPlace(KFbxNode* pNode);
00208 
00213     bool ConvertNurbsSurfaceToNurbInPlace(KFbxNode* pNode);
00214 
00216 
00221 
00228     KFbxNurb* FlipNurb(KFbxNurb* pNurb, bool pSwapUV, bool pSwapClusters);
00229 
00236     KFbxNurbsSurface* FlipNurbsSurface(KFbxNurbsSurface* pNurb, bool pSwapUV, bool pSwapClusters);
00237 
00239 
00244 
00258     bool EmulateNormalsByPolygonVertex(KFbxMesh* pMesh);
00259 
00269     bool ComputeEdgeSmoothingFromNormals( KFbxMesh* pMesh ) const;
00270 
00280     bool ComputePolygonSmoothingFromEdgeSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00281 
00289     bool ComputeEdgeSmoothingFromPolygonSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00290 
00292 
00293 
00295     //
00296     //  WARNING!
00297     //
00298     //    Anything beyond these lines may not be documented accurately and is 
00299     //     subject to change without notice.
00300     //
00302 
00303 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00304 
00305 public:
00306 
00314     bool AddTriangulatedMeshGeometry(KFbxNode* pNode, int pUVStepCoeff);
00315 
00320 
00334     bool SplitMeshPerMaterial(KFbxMesh* pMesh);
00335 
00337 
00342     bool SplitMeshesPerMaterial(KFbxScene* pScene);
00343 
00349     bool CreateAndCopyLayerElement(KFbxMesh *pNewMesh, KFbxMesh *pRefMesh);
00350 
00356     bool SetLayerElements(KFbxMesh *pNewMesh, KFbxMesh *pMesh, int pPolygonIndex, int pPolyPointIndex, int pLoopIndex, bool pIsSearched, bool pIsEndPolygon);
00357 
00364     KFbxMesh* TriangulateMesh2(KFbxMesh const* pMesh, bool& pStatus);
00365 
00378     int TriangulatePolygon(KFbxMesh *pNewMesh, KFbxVector4 *pControlPoints, int* pVertexIndices, int * pPolyVertexIndices, int pStartVertexIndex, KFbxVector4& pNormal, int pMaterialIndex, int pPolygonSize, int polygonIndex);
00379 
00380 
00381 protected:
00382 
00383     bool ComputePatchToMeshControlPointsWeightedMapping
00384         (
00385         KFbxPatch*             pSrcPatch, 
00386         KFbxMesh*             pDstMesh, 
00387         KFbxWeightedMapping* pMapping,
00388         bool                 pSwapUV = false
00389         );
00390     bool ComputeNurbToMeshControlPointsWeightedMapping
00391         (
00392         KFbxNurbsSurface*     pSrcNurb, 
00393         KFbxMesh*             pDstMesh, 
00394         KFbxWeightedMapping* pMapping,
00395         bool                 pRescaleUVs = false,
00396         bool                 pSwapUV = false
00397         );
00398 
00399     void InitializeWeightInControlPoints(KFbxGeometryBase* pGeometry);
00400     void InitializeWeightInNormals(KFbxLayerContainer* pLayerContainer);
00401     void TriangulateContinuousSurface
00402         ( 
00403         KFbxMesh* pMesh, 
00404         KFBXSurfaceEvaluator* pSurface, 
00405         kUInt pPointCountX, 
00406         kUInt pPointCountY, 
00407         bool ClockWise = false
00408         );
00409     void CheckForZeroWeightInShape(KFbxGeometry *pGeometry);
00410     KFbxMesh* CreateMeshFromParametricSurface(KFbxGeometry const* pGeometry);
00411     KFbxNurb* CreateNurbFromPatch(KFbxPatch* pPatch);
00412     KFbxNurbsSurface* CreateNurbsSurfaceFromPatch(KFbxPatch* pPatch);
00413 
00414     void ConvertShapes(KFbxGeometry const* pSource, 
00415         KFbxGeometry* pDestination, 
00416         KFBXSurfaceEvaluator* pEvaluator, 
00417         int pUCount, 
00418         int pVCount);
00419     void ConvertShapes(KFbxGeometry const* pSource,
00420         KFbxGeometry* pDestination, 
00421         KFbxWeightedMapping* pSourceToDestinationMapping);
00422     void ConvertClusters(KFbxGeometry const* pSource, 
00423         KFbxGeometry* pDestination, 
00424         KFbxWeightedMapping* pSourceToDestinationMapping);
00425     void ConvertClusters(KArrayTemplate<KFbxCluster*> const& pSourceClusters, 
00426         int pSourceControlPointsCount,
00427         KArrayTemplate<KFbxCluster*>& pDestinationClusters, 
00428         int pDestinationControlPointsCount,
00429         KFbxWeightedMapping* pSourceToDestinationMapping);
00430     void BuildClusterToSourceMapping(KArrayTemplate<KFbxCluster*> const& pSourceClusters, 
00431         KFbxWeightedMapping* pClusterToSourceMapping);
00432     void CheckClusterToSourceMapping(KFbxWeightedMapping* pClusterToSourceMapping);
00433     void ConvertCluster(int pSourceClusterIndex, 
00434         KFbxWeightedMapping* pClusterToSourceMapping,
00435         KFbxWeightedMapping* pSourceToDestinationMapping,
00436         KFbxCluster* pDestinationCluster);
00437     void DuplicateControlPoints(KArrayTemplate<KFbxVector4>& pControlPoints, 
00438         KArrayTemplate<int>& pPolygonVertices);
00439     void UpdatePolygon(KFbxMesh *pNewMesh, KFbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated);
00440     void UpdatePolygon(KFbxMesh *pNewMesh, KFbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated, bool pUseOriginal);
00441     void ResizePolygon(KFbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0, bool pClearFlag = true);
00442 
00443     template <class T1, class T2>
00444     void ConvertNurbs( T1* pNewNurb, T2* pOldNurb );
00445 
00446     bool CopyAnimationCurves(KFbxNode* pNode, KFbxGeometry* pNewGeometry );
00447 
00448     bool FlipNurbsCurve( KFbxNurbsCurve* pCurve ) const;
00449 
00450     void FlipControlPoints( KFbxGeometryBase* pPoints, int pUCount, int pVCount ) const;
00451 
00452     bool ConvertMaterialReferenceMode( KFbxMesh* pMeshRef ) const;
00453 
00454     void RevertMaterialReferenceModeConversion( KFbxMesh* pMeshRef ) const;
00455 
00456     KFbxSdkManager* mManager;
00457 
00458 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00459 
00460 };
00461 
00462 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00463 
00464 #endif // FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00465