FBX SDK Reference Guide: kfbxgeometryconverter.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_GEOMETRY_CONVERTER_H_
00005 #define _FBXSDK_GEOMETRY_CONVERTER_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 <kaydaradef.h>
00043 #ifndef KFBX_DLL 
00044     #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046 
00047 #include <kaydara.h>
00048 
00049 #include <klib/karrayul.h>
00050 
00051 #ifndef MB_FBXSDK
00052 #include <kbaselib_nsuse.h>
00053 #endif
00054 
00055 
00056 #include <fbxfilesdk_nsbegin.h>
00057 
00058 class KFbxNode;
00059 class KFbxLayerContainer;
00060 class KFbxGeometryBase;
00061 class KFbxGeometry;
00062 class KFbxMesh;
00063 class KFbxPatch;
00064 class KFbxNurb;
00065 class KFbxCluster;
00066 class KFbxSdkManager;
00067 class KFBXSurfaceEvaluator;
00068 class KFbxWeightedMapping;
00069 class KFbxVector4;
00070 class KFbxNurbsSurface;
00071 class KFbxNurbsCurve;
00072 
00077 class KFBX_DLL KFbxGeometryConverter
00078 {
00079 public:
00080     KFbxGeometryConverter(KFbxSdkManager* pManager);
00081     ~KFbxGeometryConverter();
00082 
00087 
00093     KFbxMesh* TriangulateMesh(KFbxMesh const* pMesh);
00094 
00100     KFbxMesh* TriangulatePatch(KFbxPatch const* pPatch);
00101 
00107     KFbxMesh* TriangulateNurb(KFbxNurb const* pNurb);
00108 
00115     bool TriangulateInPlace(KFbxNode* pNode);
00116 
00126     bool AddAlternateGeometry(
00127         KFbxNode*            pNode, 
00128         KFbxGeometry*        pSrcGeom, 
00129         KFbxGeometry*        pAltGeom,
00130         KFbxWeightedMapping* pSrcToAltWeightedMapping,
00131         bool                 pConvertDeformations
00132     );
00133 
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 
00181     bool ConvertPatchToNurbInPlace(KFbxNode* pNode);
00182 
00188     KFbxNurbsSurface* ConvertPatchToNurbsSurface(KFbxPatch *pPatch);
00189 
00195     bool ConvertPatchToNurbsSurfaceInPlace(KFbxNode* pNode);
00196 
00201     KFbxNurbsSurface* ConvertNurbToNurbsSurface( KFbxNurb* pNurb );
00202 
00207     KFbxNurb* ConvertNurbsSurfaceToNurb( KFbxNurbsSurface* pNurb );
00208 
00213     bool ConvertNurbToNurbsSurfaceInPlace(KFbxNode* pNode);
00214 
00219     bool ConvertNurbsSurfaceToNurbInPlace(KFbxNode* pNode);
00220 
00222 
00227 
00234     KFbxNurb* FlipNurb(KFbxNurb* pNurb, bool pSwapUV, bool pSwapClusters);
00235 
00242     KFbxNurbsSurface* FlipNurbsSurface(KFbxNurbsSurface* pNurb, bool pSwapUV, bool pSwapClusters);
00243 
00245 
00250 
00264     bool EmulateNormalsByPolygonVertex(KFbxMesh* pMesh);
00265 
00275     bool ComputeEdgeSmoothingFromNormals( KFbxMesh* pMesh ) const;
00276 
00286     bool ComputePolygonSmoothingFromEdgeSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00287     
00295     bool ComputeEdgeSmoothingFromPolygonSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00296 
00298 
00299 
00301 //
00302 //  WARNING!
00303 //
00304 //  Anything beyond these lines may not be documented accurately and is 
00305 //  subject to change without notice.
00306 //
00308 
00309 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00310 
00311 public:
00312 
00320     bool AddTriangulatedMeshGeometry(KFbxNode* pNode, int pUVStepCoeff);
00321     
00322 protected:
00323 
00324     bool ComputePatchToMeshControlPointsWeightedMapping
00325     (
00326         KFbxPatch*           pSrcPatch, 
00327         KFbxMesh*            pDstMesh, 
00328         KFbxWeightedMapping* pMapping,
00329         bool                 pSwapUV = false
00330     );
00331     bool ComputeNurbToMeshControlPointsWeightedMapping
00332     (
00333         KFbxNurbsSurface*    pSrcNurb, 
00334         KFbxMesh*            pDstMesh, 
00335         KFbxWeightedMapping* pMapping,
00336         bool                 pRescaleUVs = false,
00337         bool                 pSwapUV = false
00338     );
00339 
00340     void InitializeWeightInControlPoints(KFbxGeometryBase* pGeometry);
00341     void InitializeWeightInNormals(KFbxLayerContainer* pLayerContainer);
00342     void TriangulateContinuousSurface
00343     ( 
00344         KFbxMesh* pMesh, 
00345         KFBXSurfaceEvaluator* pSurface, 
00346         kUInt pPointCountX, 
00347         kUInt pPointCountY, 
00348         bool ClockWise = false
00349     );
00350     void CheckForZeroWeightInShape(KFbxGeometry *pGeometry);
00351     KFbxMesh* CreateMeshFromParametricSurface(KFbxGeometry const* pGeometry);
00352     KFbxNurb* CreateNurbFromPatch(KFbxPatch* pPatch);
00353     KFbxNurbsSurface* CreateNurbsSurfaceFromPatch(KFbxPatch* pPatch);
00354 
00355     void ConvertShapes(KFbxGeometry const* pSource, 
00356                        KFbxGeometry* pDestination, 
00357                        KFBXSurfaceEvaluator* pEvaluator, 
00358                        int pUCount, 
00359                        int pVCount);
00360     void ConvertShapes(KFbxGeometry const* pSource,
00361                         KFbxGeometry* pDestination, 
00362                         KFbxWeightedMapping* pSourceToDestinationMapping);
00363     void ConvertClusters(KFbxGeometry const* pSource, 
00364                       KFbxGeometry* pDestination, 
00365                       KFbxWeightedMapping* pSourceToDestinationMapping);
00366     void ConvertClusters(KArrayTemplate<KFbxCluster*> const& pSourceClusters, 
00367                       int pSourceControlPointsCount,
00368                       KArrayTemplate<KFbxCluster*>& pDestinationClusters, 
00369                       int pDestinationControlPointsCount,
00370                       KFbxWeightedMapping* pSourceToDestinationMapping);
00371     void BuildClusterToSourceMapping(KArrayTemplate<KFbxCluster*> const& pSourceClusters, 
00372                                   KFbxWeightedMapping* pClusterToSourceMapping);
00373     void CheckClusterToSourceMapping(KFbxWeightedMapping* pClusterToSourceMapping);
00374     void ConvertCluster(int pSourceClusterIndex, 
00375                      KFbxWeightedMapping* pClusterToSourceMapping,
00376                      KFbxWeightedMapping* pSourceToDestinationMapping,
00377                      KFbxCluster* pDestinationCluster);
00378     void DuplicateControlPoints(KArrayTemplate<KFbxVector4>& pControlPoints, 
00379                                 KArrayTemplate<int>& pPolygonVertices);
00380     void UpdatePolygon(KFbxMesh *pNewMesh, 
00381                         KFbxMesh  const *pRefMesh,
00382                         int pPolygonIndex, 
00383                         int* pNewIndex,
00384                         int &pVerticeIndexMeshTriangulated, 
00385                         int &pPolygonIndexMeshTriangulated);
00386     void ClearPolygon(KFbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0);
00387 
00388     template <class T1, class T2>
00389     void ConvertNurbs( T1* pNewNurb, T2* pOldNurb );
00390 
00391     bool CopyAnimationCurves(KFbxNode* pNode, KFbxGeometry* pNewGeometry );
00392 
00393     bool FlipNurbsCurve( KFbxNurbsCurve* pCurve ) const;
00394 
00395     void FlipControlPoints( KFbxGeometryBase* pPoints, int pUCount, int pVCount ) const;
00396 
00397     bool ConvertMaterialReferenceMode( KFbxMesh* pMeshRef ) const;
00398 
00399     void RevertMaterialReferenceModeConversion( KFbxMesh* pMeshRef ) const;
00400 
00401     KFbxSdkManager* mManager;
00402 
00403 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00404 
00405 };
00406 
00407 #include <fbxfilesdk_nsend.h>
00408 
00409 #endif // #ifndef _FBXSDK_GEOMETRY_CONVERTER_H_
00410 
00411