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.

172 lines
5.5 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("vta")
  15. #define FStrEq(sz1, sz2) (strcmp((sz1), (sz2)) == 0)
  16. //===================================================================
  17. // Class that implements the scene-export.
  18. //
  19. class VtaExportClass : public SceneExport
  20. {
  21. friend BOOL CALLBACK ExportOptionsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  22. friend class DumpModelTEP;
  23. friend class DumpDeformsTEP;
  24. public:
  25. CONSTRUCTOR VtaExportClass (void);
  26. DESTRUCTOR ~VtaExportClass (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 VTA"); }
  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 100; }
  37. virtual void ShowAbout (HWND hWnd) { return; }
  38. // virtual int DoExport (const TCHAR *name, ExpInterface *ei, Interface *i);
  39. virtual int DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts=FALSE,DWORD options=0); // Export file
  40. // Integer constants for this class
  41. enum
  42. {
  43. MAX_NAME_CHARS = 70,
  44. UNDESIRABLE_NODE_MARKER = -7777
  45. };
  46. // For keeping info about each (non-ignored) 3dsMax node in the tree
  47. typedef struct
  48. {
  49. char szNodeName[MAX_NAME_CHARS]; // usefull for lookups
  50. Matrix3 mat3NodeTM; // node's transformation matrix (at time zero)
  51. Matrix3 mat3ObjectTM; // object-offset transformation matrix (at time zero)
  52. int imaxnodeParent; // cached index of parent node
  53. float xRotFirstFrame; // 1st frame's X rotation
  54. float yRotFirstFrame; // 1st frame's Y rotation
  55. float zRotFirstFrame; // 1st frame's Z rotation
  56. } MaxNode;
  57. MaxNode *m_rgmaxnode; // array of nodes
  58. long m_imaxnodeMac; // # of nodes
  59. // Animation metrics (gleaned from 3dsMax and cached for convenience)
  60. Interval m_intervalOfAnimation;
  61. TimeValue m_tvStart;
  62. TimeValue m_tvEnd;
  63. int m_tpf; // ticks-per-frame
  64. private:
  65. BOOL CollectNodes (ExpInterface *expiface);
  66. BOOL DumpBones (FILE *pFile, ExpInterface *pexpiface);
  67. BOOL DumpRotations (FILE *pFile, ExpInterface *pexpiface);
  68. BOOL DumpModel (FILE *pFile, ExpInterface *pexpiface);
  69. BOOL DumpDeforms (FILE *pFile, ExpInterface *pexpiface);
  70. };
  71. //===================================================================
  72. // Basically just a ClassFactory for communicating with 3DSMAX.
  73. //
  74. class VtaExportClassDesc : public ClassDesc
  75. {
  76. public:
  77. int IsPublic (void) { return TRUE; }
  78. void * Create (BOOL loading=FALSE) { return new VtaExportClass; }
  79. const TCHAR * ClassName (void) { return _T("VtaExport"); }
  80. SClass_ID SuperClassID (void) { return SCENE_EXPORT_CLASS_ID; }
  81. Class_ID ClassID (void) { return Class_ID(0x5616745e, 0x65643ba5); }
  82. const TCHAR * Category (void) { return _T(""); }
  83. };
  84. //===================================================================
  85. // Tree Enumeration Callback
  86. // Just counts the nodes in the node tree
  87. //
  88. class CountNodesTEP : public ITreeEnumProc
  89. {
  90. public:
  91. virtual int callback(INode *node);
  92. int m_cNodes; // running count of nodes
  93. };
  94. //===================================================================
  95. // Tree Enumeration Callback
  96. // Collects the nodes in the tree into the global array
  97. //
  98. class CollectNodesTEP : public ITreeEnumProc
  99. {
  100. public:
  101. virtual int callback(INode *node);
  102. VtaExportClass *m_phec;
  103. };
  104. //===================================================================
  105. // Tree Enumeration Callback
  106. // Dumps the bone offsets to a file.
  107. //
  108. class DumpNodesTEP : public ITreeEnumProc
  109. {
  110. public:
  111. virtual int callback(INode *node);
  112. FILE *m_pfile; // write to this file
  113. VtaExportClass *m_phec;
  114. };
  115. //===================================================================
  116. // Tree Enumeration Callback
  117. // Dumps the per-frame bone rotations to a file.
  118. //
  119. class DumpFrameRotationsTEP : public ITreeEnumProc
  120. {
  121. public:
  122. virtual int callback(INode *node);
  123. void cleanup(void);
  124. FILE *m_pfile; // write to this file
  125. TimeValue m_tvToDump; // dump snapshot at this frame time
  126. VtaExportClass *m_phec;
  127. };
  128. //===================================================================
  129. // Tree Enumeration Callback
  130. // Dumps the triangle meshes to a file.
  131. //
  132. class DumpModelTEP : public ITreeEnumProc
  133. {
  134. public:
  135. ~DumpModelTEP();
  136. virtual int callback(INode *node);
  137. FILE *m_pfile; // write to this file
  138. TimeValue m_tvBase; // reference dump snapshot at this frame time
  139. TimeValue m_tvToDump; // delta dump snapshot at this frame time
  140. VtaExportClass *m_phec;
  141. int m_baseVertCount;
  142. Point3 *m_baseVert;
  143. private:
  144. // int InodeOfPhyVectex( int iVertex0 );
  145. Point3 Pt3GetRVertexNormal(RVertex *prvertex, DWORD smGroupFace);
  146. };