Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
3.3 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ==========
  2. //
  3. // Autodesk FBX <-> Valve DMX
  4. //
  5. //=============================================================================
  6. #ifndef DMFBXSERIALIZER_H
  7. #define DMFBXSERIALIZER_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. // FBX includes
  12. #include <fbxsdk.h>
  13. // Valve includes
  14. #include "datamodel/idatamodel.h"
  15. #include "tier1/utlbuffer.h"
  16. #include "tier1/utlmap.h"
  17. #include "tier1/utlstring.h"
  18. #include "tier1/utlvector.h"
  19. //-----------------------------------------------------------------------------
  20. // Forward declarations
  21. //-----------------------------------------------------------------------------
  22. class CDmeCombinationOperator;
  23. class CDmeDag;
  24. class CDmeMesh;
  25. class CDmeModel;
  26. //-----------------------------------------------------------------------------
  27. // Serialization class for FBX files
  28. //-----------------------------------------------------------------------------
  29. class CDmFbxSerializer
  30. {
  31. public:
  32. CDmFbxSerializer();
  33. virtual ~CDmFbxSerializer();
  34. const char *GetName() const { return "fbx"; }
  35. const char *GetDescription() const { return "Autodesk� FBX�"; }
  36. // CDmFbxSerializer
  37. CDmElement *ReadFBX( const char *pszFilename );
  38. bool Verbose1() const { return m_nOptVerbosity >= 1; }
  39. bool Verbose2() const { return m_nOptVerbosity >= 2; }
  40. // UtlHashtable is non-functional in //ValveGames/main 5/16/2012
  41. typedef CUtlMap< FbxNode *, CDmeDag * > FbxToDmxMap_t;
  42. protected:
  43. FbxManager *CreateFbxManager();
  44. void DestroyFbxManager();
  45. FbxScene *LoadFbxScene( const char *pszFilename );
  46. void LoadModelAndSkeleton_R( FbxToDmxMap_t &fbxToDmxMap, CDmeModel *pDmeModel, CDmeDag *pDmeDagParent, FbxNode *pFbxNode, bool bAnimation, int nDepth ) const;
  47. CDmeDag *FbxNodeToDmeDag( CDmeDag *pDmeDagParent, FbxNode *pFbxNode, const char *pszDmeType ) const;
  48. CDmeMesh *FbxShapeToDmeMesh( CDmeDag *pDmeDag, FbxNode *pFbxNode ) const;
  49. bool FbxMeshToDmeFaceSets( CDmeDag *pDmeDag, CDmeMesh *pDmeMesh, FbxMesh *pFbxMesh, CUtlVector< int > &nPolygonToFaceSetMap ) const;
  50. void GetDmeMaterialPathFromFbxFileTexture( CUtlString &sMaterialPath, FbxFileTexture *pFileTexture ) const;
  51. void GetFbxMaterialNameAndPath( CUtlString &sMaterialName, CUtlString &sMaterialPath, FbxSurfaceMaterial *pFbxMat ) const;
  52. void SkinMeshes_R( const FbxToDmxMap_t &fbxToDmxMap, CDmeModel *pDmeModel, FbxNode *pFbxNode ) const;
  53. void SkinMesh( CDmeDag *pDmeDag, const FbxToDmxMap_t &fbxToDmxMap, CDmeModel *pDmeModel, FbxNode *pFbxNode ) const;
  54. void AddBlendShapes_R( const FbxToDmxMap_t &fbxToDmxMap, CDmElement *pDmeRoot, FbxNode *pFbxNode ) const;
  55. void AddBlendShape( CDmeDag *pDmeDag, const FbxToDmxMap_t &fbxToDmxMap, CDmElement *pDmeRoot, FbxNode *pFbxNode ) const;
  56. CDmeCombinationOperator *FindOrCreateComboOp( CDmElement *pDmeRoot ) const;
  57. bool FindOrCreateControl( CDmeCombinationOperator *pDmeComboOp, const char *pszName ) const;
  58. void GetName( CUtlString &sCleanName, const FbxNode *pFbxNode ) const;
  59. void CleanupName( CUtlString &sCleanName, const char *pszName ) const;
  60. void LoadAnimation( CDmElement *pDmeRoot, CDmeModel *pDmeModel, const FbxToDmxMap_t &fbxToDmxMap, FbxScene *pFbxScene, FbxNode *pFbxRootNode ) const;
  61. FbxManager *m_pFbxManager;
  62. public:
  63. int m_nOptVerbosity;
  64. bool m_bOptUnderscoreForCorrectors;
  65. bool m_bAnimation;
  66. };
  67. #endif // DMFBXSERIALIZER_H