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 - 2010 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 KFbxSdkManager;
00048 class KFbxScene;
00049 class KFbxNode;
00050 class KFbxNodeAttribute;
00051 class KFbxGeometryBase;
00052 class KFbxMesh;
00053 class KFbxPatch;
00054 class KFbxNurb;
00055 class KFbxNurbsCurve;
00056 class KFbxNurbsSurface;
00057 class KFbxGeometry;
00058 class KFbxCluster;
00059 class KFbxWeightedMapping;
00060 class KFbxLayerContainer;
00061 class KFBXSurfaceEvaluator;
00062 class KFbxVector4;
00063 
00070 class KFBX_DLL KFbxGeometryConverter
00071 {
00072 public:
00073     KFbxGeometryConverter(KFbxSdkManager* pManager);
00074     ~KFbxGeometryConverter();
00075 
00085         KFbxMesh* TriangulateMesh(KFbxMesh const* pMesh);
00086 
00093         KFbxMesh* TriangulatePatch(KFbxPatch const* pPatch);
00094 
00101         KFbxMesh* TriangulateNurb(KFbxNurb const* pNurb);
00102 
00109         bool TriangulateInPlace(KFbxNode* pNode);
00110 
00122         bool AddAlternateGeometry(KFbxNode* pNode, KFbxGeometry* pSrcGeom, KFbxGeometry* pAltGeom, KFbxWeightedMapping* pSrcToAltWeightedMapping, bool pConvertDeformations);
00123 
00133         bool ConvertGeometryAnimation(KFbxNode* pNode, KFbxGeometry* pSrcGeom, KFbxGeometry* pDstGeom);
00134 
00143         bool ComputeGeometryControlPointsWeightedMapping(KFbxGeometry* pSrcGeom, KFbxGeometry* pDstGeom, KFbxWeightedMapping* pSrcToDstWeightedMapping, bool pSwapUV=false);
00145 
00155         KFbxNurb* ConvertPatchToNurb(KFbxPatch *pPatch);
00156 
00163         bool ConvertPatchToNurbInPlace(KFbxNode* pNode);
00164 
00170         KFbxNurbsSurface* ConvertPatchToNurbsSurface(KFbxPatch *pPatch);
00171 
00178         bool ConvertPatchToNurbsSurfaceInPlace(KFbxNode* pNode);
00179 
00184         KFbxNurbsSurface* ConvertNurbToNurbsSurface( KFbxNurb* pNurb );
00185 
00190         KFbxNurb* ConvertNurbsSurfaceToNurb( KFbxNurbsSurface* pNurb );
00191 
00197         bool ConvertNurbToNurbsSurfaceInPlace(KFbxNode* pNode);
00198 
00204         bool ConvertNurbsSurfaceToNurbInPlace(KFbxNode* pNode);
00206 
00217         KFbxNurb* FlipNurb(KFbxNurb* pNurb, bool pSwapUV, bool pSwapClusters);
00218 
00225         KFbxNurbsSurface* FlipNurbsSurface(KFbxNurbsSurface* pNurb, bool pSwapUV, bool pSwapClusters);
00227 
00245         bool EmulateNormalsByPolygonVertex(KFbxMesh* pMesh);
00246 
00256         bool ComputeEdgeSmoothingFromNormals( KFbxMesh* pMesh ) const;
00257 
00267         bool ComputePolygonSmoothingFromEdgeSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00268 
00276         bool ComputeEdgeSmoothingFromPolygonSmoothing( KFbxMesh* pMesh, int pIndex=0 ) const;
00278 
00280 //
00281 //  WARNING!
00282 //
00283 //    Anything beyond these lines may not be documented accurately and is 
00284 //     subject to change without notice.
00285 //
00287 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00288 public:
00295     void ReplaceNodeAttribute(KFbxNode* pNode, KFbxNodeAttribute* pNewNodeAttr);
00296 
00305     bool AddTriangulatedMeshGeometry(KFbxNode* pNode, int pUVStepCoeff);
00306 
00320     bool SplitMeshPerMaterial(KFbxMesh* pMesh);
00321 
00326     bool SplitMeshesPerMaterial(KFbxScene* pScene);
00327 
00333     bool CreateAndCopyLayerElement(KFbxMesh *pNewMesh, KFbxMesh *pRefMesh);
00334 
00340     bool SetLayerElements(KFbxMesh *pNewMesh, KFbxMesh *pMesh, int pPolygonIndex, int pPolyPointIndex, int pLoopIndex, bool pIsSearched, bool pIsEndPolygon);
00341 
00348     KFbxMesh* TriangulateMeshAdvance(KFbxMesh const* pMesh, bool& pStatus);
00349 
00362     K_DEPRECATED int TriangulatePolygon(KFbxMesh *pNewMesh, KFbxVector4 *pControlPoints, int* pVertexIndices, int * pPolyVertexIndices, int pStartVertexIndex, KFbxVector4& pNormal, int pMaterialIndex, int pPolygonSize, int polygonIndex);
00363 
00364 protected:
00365     bool ComputePatchToMeshControlPointsWeightedMapping(KFbxPatch* pSrcPatch, KFbxMesh* pDstMesh, KFbxWeightedMapping* pMapping, bool pSwapUV=false);
00366     bool ComputeNurbToMeshControlPointsWeightedMapping(KFbxNurbsSurface* pSrcNurb, KFbxMesh* pDstMesh, KFbxWeightedMapping* pMapping, bool pRescaleUVs=false, bool pSwapUV=false);
00367 
00368     void InitializeWeightInControlPoints(KFbxGeometryBase* pGeometry);
00369     void InitializeWeightInNormals(KFbxLayerContainer* pLayerContainer);
00370     void TriangulateContinuousSurface(KFbxMesh* pMesh, KFBXSurfaceEvaluator* pSurface, kUInt pPointCountX, kUInt pPointCountY, bool ClockWise=false);
00371     void CheckForZeroWeightInShape(KFbxGeometry *pGeometry);
00372     KFbxMesh* CreateMeshFromParametricSurface(KFbxGeometry const* pGeometry);
00373     KFbxNurb* CreateNurbFromPatch(KFbxPatch* pPatch);
00374     KFbxNurbsSurface* CreateNurbsSurfaceFromPatch(KFbxPatch* pPatch);
00375 
00376     void ConvertShapes(KFbxGeometry const* pSource, KFbxGeometry* pDestination, KFBXSurfaceEvaluator* pEvaluator, int pUCount, int pVCount);
00377     void ConvertShapes(KFbxGeometry const* pSource, KFbxGeometry* pDestination, KFbxWeightedMapping* pSourceToDestinationMapping);
00378     void ConvertClusters(KFbxGeometry const* pSource, KFbxGeometry* pDestination, KFbxWeightedMapping* pSourceToDestinationMapping);
00379     void ConvertClusters(KArrayTemplate<KFbxCluster*> const& pSourceClusters, int pSourceControlPointsCount, KArrayTemplate<KFbxCluster*>& pDestinationClusters, int pDestinationControlPointsCount, KFbxWeightedMapping* pSourceToDestinationMapping);
00380     void BuildClusterToSourceMapping(KArrayTemplate<KFbxCluster*> const& pSourceClusters, KFbxWeightedMapping* pClusterToSourceMapping);
00381     void CheckClusterToSourceMapping(KFbxWeightedMapping* pClusterToSourceMapping);
00382     void ConvertCluster(int pSourceClusterIndex, KFbxWeightedMapping* pClusterToSourceMapping, KFbxWeightedMapping* pSourceToDestinationMapping, KFbxCluster* pDestinationCluster);
00383     void DuplicateControlPoints(KArrayTemplate<KFbxVector4>& pControlPoints, KArrayTemplate<int>& pPolygonVertices);
00384     void UpdatePolygon(KFbxMesh *pNewMesh, KFbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated);
00385     void UpdatePolygon(KFbxMesh *pNewMesh, KFbxMesh const *pRefMesh, int pPolygonIndex, int* pNewIndex, int &pVerticeIndexMeshTriangulated, int &pPolygonIndexMeshTriangulated, int pTriangleNum);
00386     void ResizePolygon(KFbxMesh *pNewMesh, int pNewCountVertices = 0, int pNewCountPolygons =0, bool pClearFlag = true);
00387 
00388     template <class T1, class T2> void ConvertNurbs(T1* pNewNurb, T2* pOldNurb);
00389 
00390     bool CopyAnimationCurves(KFbxNode* pNode, KFbxGeometry* pNewGeometry);
00391     bool FlipNurbsCurve(KFbxNurbsCurve* pCurve) const;
00392     void FlipControlPoints(KFbxGeometryBase* pPoints, int pUCount, int pVCount) const;
00393     bool ConvertMaterialReferenceMode(KFbxMesh* pMeshRef) const;
00394     void RevertMaterialReferenceModeConversion(KFbxMesh* pMeshRef) const;
00395 
00396     KFbxSdkManager* mManager;
00397 
00398 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00399 };
00400 
00401 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00402 
00403 #endif // FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRYCONVERTER_H
00404