kfbxgeometryconverter.h

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 - 2007 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 #include <kfbxplugins/kfbxobject.h>
00055 
00056 
00057 #include <fbxfilesdk_nsbegin.h>
00058 
00059 class KFbxNode;
00060 class KFbxLayerContainer;
00061 class KFbxGeometryBase;
00062 class KFbxGeometry;
00063 class KFbxMesh;
00064 class KFbxPatch;
00065 class KFbxNurb;
00066 class KFbxCluster;
00067 class KFbxSdkManager;
00068 class KFBXSurfaceEvaluator;
00069 class KFbxWeightedMapping;
00070 class KFbxVector4;
00071 class KFbxNurbsSurface;
00072 class KFbxNurbsCurve;
00073 
00078 class KFBX_DLL KFbxGeometryConverter : public KFbxObject
00079 {
00080     KFBXOBJECT_DECLARE(KFbxGeometryConverter);
00081 public:
00086 
00092     KFbxMesh* TriangulateMesh(KFbxMesh* pMesh);
00093 
00099     KFbxMesh* TriangulatePatch(KFbxPatch* pPatch);
00100 
00106     KFbxMesh* TriangulateNurb(KFbxNurb* pNurb);
00107 
00114     bool TriangulateInPlace(KFbxNode* pNode);
00115 
00125     bool AddAlternateGeometry(
00126         KFbxNode*            pNode, 
00127         KFbxGeometry*        pSrcGeom, 
00128         KFbxGeometry*        pAltGeom,
00129         KFbxWeightedMapping* pSrcToAltWeightedMapping,
00130         bool                 pConvertDeformations
00131     );
00132 
00140     bool ConvertGeometryAnimation(
00141         KFbxNode*            pNode, 
00142         KFbxGeometry*        pSrcGeom, 
00143         KFbxGeometry*        pDstGeom
00144     );
00145 
00153     bool ComputeGeometryControlPointsWeightedMapping(
00154         KFbxGeometry*        pSrcGeom, 
00155         KFbxGeometry*        pDstGeom, 
00156         KFbxWeightedMapping* pSrcToDstWeightedMapping,
00157         bool                 pSwapUV = false
00158     );
00159 
00161 
00166 
00172     KFbxNurb* ConvertPatchToNurb(KFbxPatch *pPatch);
00173 
00179     bool ConvertPatchToNurbInPlace(KFbxNode* pNode);
00180 
00186     KFbxNurbsSurface* ConvertPatchToNurbsSurface(KFbxPatch *pPatch);
00187 
00193     bool ConvertPatchToNurbsSurfaceInPlace(KFbxNode* pNode);
00194 
00199     KFbxNurbsSurface* ConvertNurbToNurbsSurface( KFbxNurb* pNurb );
00200 
00205     KFbxNurb* ConvertNurbsSurfaceToNurb( KFbxNurbsSurface* pNurb );
00206 
00211     bool ConvertNurbToNurbsSurfaceInPlace(KFbxNode* pNode);
00212 
00217     bool ConvertNurbsSurfaceToNurbInPlace(KFbxNode* pNode);
00218 
00220 
00225 
00232     KFbxNurb* FlipNurb(KFbxNurb* pNurb, bool pSwapUV, bool pSwapClusters);
00233 
00240     KFbxNurbsSurface* FlipNurbsSurface(KFbxNurbsSurface* pNurb, bool pSwapUV, bool pSwapClusters);
00241 
00243 
00248 
00262     bool EmulateNormalsByPolygonVertex(KFbxMesh* pMesh);
00263 
00273     bool ComputeEdgeSmoothingFromNormals( KFbxMesh* pMesh ) const;
00274 
00276 
00277 
00279 //
00280 //  WARNING!
00281 //
00282 //  Anything beyond these lines may not be documented accurately and is 
00283 //  subject to change without notice.
00284 //
00286 
00287 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00288 
00289 public:
00290 
00298     bool AddTriangulatedMeshGeometry(KFbxNode* pNode, int pUVStepCoeff);
00299     
00300 protected:
00301 
00302     KFbxGeometryConverter(KFbxSdkManager& pManager,char const *pName);
00303     ~KFbxGeometryConverter();
00304 
00305     bool ComputePatchToMeshControlPointsWeightedMapping
00306     (
00307         KFbxPatch*           pSrcPatch, 
00308         KFbxMesh*            pDstMesh, 
00309         KFbxWeightedMapping* pMapping,
00310         bool                 pSwapUV = false
00311     );
00312     bool ComputeNurbToMeshControlPointsWeightedMapping
00313     (
00314         KFbxNurbsSurface*    pSrcNurb, 
00315         KFbxMesh*            pDstMesh, 
00316         KFbxWeightedMapping* pMapping,
00317         bool                 pRescaleUVs = false,
00318         bool                 pSwapUV = false
00319     );
00320 
00321     void InitializeWeightInControlPoints(KFbxGeometryBase* pGeometry);
00322     void InitializeWeightInNormals(KFbxLayerContainer* pLayerContainer);
00323     void TriangulateContinuousSurface
00324     ( 
00325         KFbxMesh* pMesh, 
00326         KFBXSurfaceEvaluator* pSurface, 
00327         kUInt pPointCountX, 
00328         kUInt pPointCountY, 
00329         bool ClockWise = false
00330     );
00331     void CheckForZeroWeightInShape(KFbxGeometry *pGeometry);
00332     KFbxMesh* CreateMeshFromParametricSurface(KFbxGeometry* pGeometry);
00333     KFbxNurb* CreateNurbFromPatch(KFbxPatch* pPatch);
00334     KFbxNurbsSurface* CreateNurbsSurfaceFromPatch(KFbxPatch* pPatch);
00335 
00336     void ConvertShapes(KFbxGeometry* pSource, 
00337                        KFbxGeometry* pDestination, 
00338                        KFBXSurfaceEvaluator* pEvaluator, 
00339                        int pUCount, 
00340                        int pVCount);
00341     void ConvertShapes(KFbxGeometry* pSource,
00342                         KFbxGeometry* pDestination, 
00343                         KFbxWeightedMapping* pSourceToDestinationMapping);
00344     void ConvertClusters(KFbxGeometry* pSource, 
00345                       KFbxGeometry* pDestination, 
00346                       KFbxWeightedMapping* pSourceToDestinationMapping);
00347     void ConvertClusters(KArrayTemplate<KFbxCluster*>& pSourceClusters, 
00348                       int pSourceControlPointsCount,
00349                       KArrayTemplate<KFbxCluster*>& pDestinationClusters, 
00350                       int pDestinationControlPointsCount,
00351                       KFbxWeightedMapping* pSourceToDestinationMapping);
00352     void BuildClusterToSourceMapping(KArrayTemplate<KFbxCluster*>& pSourceClusters, 
00353                                   KFbxWeightedMapping* pClusterToSourceMapping);
00354     void CheckClusterToSourceMapping(KFbxWeightedMapping* pClusterToSourceMapping);
00355     void ConvertCluster(int pSourceClusterIndex, 
00356                      KFbxWeightedMapping* pClusterToSourceMapping,
00357                      KFbxWeightedMapping* pSourceToDestinationMapping,
00358                      KFbxCluster* pDestinationCluster);
00359     void DuplicateControlPoints(KArrayTemplate<KFbxVector4>& pControlPoints, 
00360                                 KArrayTemplate<int>& pPolygonVertices);
00361     void UpdatePolygon(KFbxMesh *pNewMesh, KFbxMesh *pRefMesh,
00362                                                 int pPolygonIndex, int* pNewIndex);
00363     void ClearPolygon(KFbxMesh *pNewMesh, int pNewCount = 0);
00364 
00365     template <class T1, class T2>
00366     void ConvertNurbs( T1* pNewNurb, T2* pOldNurb );
00367 
00368     bool CopyAnimationCurves(KFbxNode* pNode, KFbxGeometry* pNewGeometry );
00369 
00370     bool FlipNurbsCurve( KFbxNurbsCurve* pCurve ) const;
00371 
00372     void FlipControlPoints( KFbxGeometryBase* pPoints, int pUCount, int pVCount ) const;
00373 
00374     KFbxSdkManager* mManager;
00375 
00376 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00377 
00378 };
00379 
00380 #include <fbxfilesdk_nsend.h>
00381 
00382 #endif // #ifndef _FBXSDK_GEOMETRY_CONVERTER_H_
00383 
00384