Team Fortress 2 Source Code as on 22/4/2020
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.

130 lines
4.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. //===================================================================
  9. // Useful macros
  10. //
  11. #define CONSTRUCTOR
  12. #define DESTRUCTOR
  13. #define EXPORT_THIS __declspec(dllexport)
  14. #define DEFAULT_EXT _T("vvw")
  15. #define FStrEq(sz1, sz2) (strcmp((sz1), (sz2)) == 0)
  16. //===================================================================
  17. // Class that implements the scene-export.
  18. //
  19. class VWeightImportClass : public SceneImport
  20. {
  21. // friend BOOL CALLBACK ImportOptionsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  22. // friend class DumpModelTEP;
  23. // friend class DumpDeformsTEP;
  24. public:
  25. CONSTRUCTOR VWeightImportClass (void);
  26. DESTRUCTOR ~VWeightImportClass (void);
  27. // Required by classes derived from SceneExport
  28. virtual int ExtCount (void) { return 1; }
  29. virtual const TCHAR* Ext (int i) { return DEFAULT_EXT; }
  30. virtual const TCHAR* LongDesc (void) { return _T("Valve Skeletal Model Exporter for 3D Studio Max"); }
  31. virtual const TCHAR* ShortDesc (void) { return _T("Valve VVW"); }
  32. virtual const TCHAR* AuthorName (void) { return _T("Valve, LLC"); }
  33. virtual const TCHAR* CopyrightMessage(void) { return _T("Copyright (c) 1998, Valve LLC"); }
  34. virtual const TCHAR* OtherMessage1 (void) { return _T(""); }
  35. virtual const TCHAR* OtherMessage2 (void) { return _T(""); }
  36. virtual unsigned int Version (void) { return 201; }
  37. virtual void ShowAbout (HWND hWnd) { return; }
  38. // virtual int DoExport (const TCHAR *name, ExpInterface *ei, Interface *i);
  39. virtual int DoImport(const TCHAR *name,ImpInterface *ii,Interface *i, BOOL suppressPrompts=FALSE); // Export file
  40. MaxNode m_SrcMaxNode[512]; // array of nodes
  41. long m_cSrcMaxNodes; // # of nodes
  42. MaxVertWeight *m_SrcMaxVertex[10000];
  43. long m_cSrcMaxVertex;
  44. MaxNode m_MaxNode[512]; // array of nodes
  45. long m_cMaxNodes; // # of nodes
  46. int m_iToSrc[512]; // translate src nodes to local bones
  47. // Animation metrics (gleaned from 3dsMax and cached for convenience)
  48. Interval m_intervalOfAnimation;
  49. TimeValue m_tvStart;
  50. TimeValue m_tvEnd;
  51. int m_tpf; // ticks-per-frame
  52. private:
  53. void CollectNodes( INode *pnode );
  54. void NodeEnum( INode *node );
  55. int UpdateModel( INode *node );
  56. void CollectWeights(int iVertex, MaxVertWeight *pweight);
  57. void RemapSrcWeights( void );
  58. IPhyContextExport *m_mcExport;
  59. IPhysiqueExport *m_phyExport;
  60. Modifier *m_phyMod;
  61. Modifier *m_bonesProMod;
  62. BonesPro_WeightArray *m_wa;
  63. };
  64. //===================================================================
  65. // Basically just a ClassFactory for communicating with 3DSMAX.
  66. //
  67. class VWeightImportClassDesc : public ClassDesc
  68. {
  69. public:
  70. int IsPublic (void) { return TRUE; }
  71. void * Create (BOOL loading=FALSE) { return new VWeightImportClass; }
  72. const TCHAR * ClassName (void) { return _T("VWeightImport"); }
  73. SClass_ID SuperClassID (void) { return SCENE_IMPORT_CLASS_ID; }
  74. Class_ID ClassID (void) { return Class_ID(0x554b1092, 0x206a444f); }
  75. const TCHAR * Category (void) { return _T(""); }
  76. };
  77. //===================================================================
  78. // Tree Enumeration Callback
  79. // Collects the nodes in the tree into the global array
  80. //
  81. class UpdateNodesTEP : public ITreeEnumProc
  82. {
  83. public:
  84. virtual int callback(INode *node);
  85. VWeightImportClass *m_phec;
  86. };
  87. //===================================================================
  88. // Tree Enumeration Callback
  89. // Dumps the triangle meshes to a file.
  90. //
  91. class UpdateModelTEP : public ITreeEnumProc
  92. {
  93. public:
  94. virtual int callback(INode *node);
  95. void cleanup(void);
  96. // FILE *m_pfile; // write to this file
  97. TimeValue m_tvToDump; // dump snapshot at this frame time
  98. VWeightImportClass *m_phec;
  99. IPhyContextExport *m_mcExport;
  100. IPhysiqueExport *m_phyExport;
  101. Modifier *m_phyMod;
  102. Modifier *m_bonesProMod;
  103. BonesPro_WeightArray *m_wa;
  104. private:
  105. void CollectWeights( int iVertex, MaxVertWeight *pweight );
  106. };