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.

105 lines
3.9 KiB

  1. //======= Copyright � 1996-2008, Valve Corporation, All rights reserved. ======
  2. //
  3. // Purpose: MDL Import class for Maya
  4. //
  5. //=============================================================================
  6. #ifndef MDLIMPORT_H
  7. #define MDLIMPORT_H
  8. // Maya includes
  9. #include <maya/MDagPathArray.h>
  10. #include <maya/MMatrix.h>
  11. #include <maya/MObjectArray.h>
  12. #include <maya/MSelectionList.h>
  13. // Valve includes
  14. #include "datacache/imdlcache.h"
  15. #include "ValveMaya/Undo.h"
  16. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. struct mstudioboneweight_t;
  20. namespace ValveMaya
  21. {
  22. //-----------------------------------------------------------------------------
  23. //
  24. //-----------------------------------------------------------------------------
  25. class CMDLImport
  26. {
  27. public:
  28. CMDLImport();
  29. CMDLImport( ValveMaya::CUndo &undo );
  30. MStatus DoIt( const char *pFilename, MSelectionList &createdNodes );
  31. MStatus DoIt( const char *pFilename );
  32. bool m_bOptMeshOnly : 1; // Only import meshes
  33. bool m_bOptSingleMesh : 1; // Merge all meshes in a MDL into a single Maya mesh
  34. bool m_bOptVstInfo : 1; // Group everything under a vstInfo node
  35. bool m_bOptImportSkeleton : 1; // Import the skeleton
  36. bool m_bOptImportMesh : 1; // Import the mesh
  37. bool m_bOptEngineSpace : 1; // Import data in engine space
  38. bool m_bOptNormals : 1; // Set normals on mesh
  39. bool m_bOptEdgeHardness : 1; // Set edge hard/softness data
  40. bool m_bOptSkinMeshes : 1; // Apply bone weights to meshes
  41. int m_nOptLod; // Import the specified LOD only, -2 means root LOD, -1 means all LODs, otherwise the LOD that matches, or all if no match
  42. int m_nOptSkin; // Import the specified Skin only, -1 means all skins, otherwise the skin that matches or all if no match
  43. MStringArray m_optRemovePrefix; // A list of prefixes to remove on import
  44. protected:
  45. void Init();
  46. static MDLHandle_t GetMDLHandle( const char *pFilename );
  47. MObject CreateVstInfo( const char *pModelName, MSelectionList &createdNodes );
  48. static MStatus AddDagMObject( const MObject &dagObj, MSelectionList &createdNodes );
  49. void ImportBones( MDLHandle_t mdlHandle, const MObject &parentObj, MDagPathArray &mayaBones, MSelectionList &createdNodes );
  50. static MStatus ApplyCompDefaultShader( MObject &geoObj, ValveMaya::CUndo &undo );
  51. static MObject FindOrCreateFileObj( ValveMaya::CUndo &undo, const MString &materialPath, MSelectionList &createdNodes );
  52. MStatus AssignShadingGroup(
  53. ValveMaya::CUndo &undo,
  54. const MDagPath &meshDagPath,
  55. MIntArray &faceList,
  56. const MStringArray &materialPaths,
  57. MSelectionList &createdList ) const;
  58. void SkinMesh( MDagPath &meshDagPath, const MDagPathArray &mayaBones, const CUtlVector< const mstudioboneweight_t * > &tmpVertexBoneWeightArray );
  59. void ImportMeshes( MDLHandle_t mdlHandle, MObject parentObj, const MDagPathArray &mayaBones, MSelectionList &createdNodes );
  60. void ReorientMdl( MDLHandle_t mdlHandle, MObject &vstInfoObj, const MDagPathArray &mayaBones );
  61. static void InitBones( Vector p[ MAXSTUDIOBONES ], QuaternionAligned q[ MAXSTUDIOBONES ], studiohdr_t *pHdr );
  62. static void TransformBones( Vector p[ MAXSTUDIOBONES ], QuaternionAligned q[ MAXSTUDIOBONES ], studiohdr_t *pHdr );
  63. static void ComputeSequenceBones( Vector p[ MAXSTUDIOBONES ], QuaternionAligned q[ MAXSTUDIOBONES ], studiohdr_t *pHdr, int nSequence = 0, float flTime = 0.0f );
  64. bool ComputeMdlToMayaMatrix( MMatrix &mMdlToMaya, studiohdr_t* pHdr ) const;
  65. void TransformPointArray( MFloatPointArray &vertexArray, const MMatrix &mMatrix ) const;
  66. void TransformNormalArray( MVectorArray &normalArray, const MMatrix &mMatrix ) const;
  67. MString GetBoneName( MString boneName ) const;
  68. ValveMaya::CUndo &m_undo;
  69. ValveMaya::CUndo m_tmpUndo;
  70. };
  71. }
  72. #endif // MDLIMPORT_H