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 #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     //  WARNING!
00307     //
00308     //    Anything beyond these lines may not be documented accurately and is 
00309     //     subject to change without notice.
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