geometryexporttask.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Max2W3d *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/max2w3d/geometryexporttask.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 10/27/00 5:00p $*
  31. * *
  32. * $Revision:: 6 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef GEOMETRYEXPORTTASK_H
  38. #define GEOMETRYEXPORTTASK_H
  39. #include <string.h>
  40. #include <Max.h>
  41. #include "w3d_file.h"
  42. #include "vector.h"
  43. class GeometryExportContextClass;
  44. /**
  45. ** GeometryExportTaskClass
  46. ** This abstract base class defines the interface for a geometry export task.
  47. ** Derived classes will encapsulate the job of exporting meshes, collision
  48. ** boxes, dazzles, etc. The factory function Create_Task will create the
  49. ** appropriate task for a given INode.
  50. */
  51. class GeometryExportTaskClass
  52. {
  53. public:
  54. GeometryExportTaskClass(INode * node,GeometryExportContextClass & context);
  55. GeometryExportTaskClass(const GeometryExportTaskClass & that);
  56. virtual ~GeometryExportTaskClass(void);
  57. virtual void Export_Geometry(GeometryExportContextClass & context) = 0;
  58. /*
  59. ** Accessors
  60. */
  61. char * Get_Name(void) { return Name; }
  62. char * Get_Container_Name(void) { return ContainerName; }
  63. void Get_Full_Name(char * buffer,int size);
  64. int Get_Bone_Index(void) { return BoneIndex; }
  65. INode * Get_Object_Node(void) { return Node; }
  66. Matrix3 Get_Export_Transform(void) { return ExportSpace; }
  67. void Set_Name(char * name) { strncpy(Name,name,sizeof(Name)); }
  68. void Set_Container_Name(char * name) { strncpy(ContainerName,name,sizeof(ContainerName)); }
  69. /*
  70. ** Unique Name generation. During optimization, new meshes may get created. When this happens,
  71. ** we have to create a unique name for each one. The name will be generated from the original
  72. ** mesh's name, the index passed in, and the LOD level of the original mesh.
  73. */
  74. void Generate_Name(char * root,int index,GeometryExportContextClass & context);
  75. /*
  76. ** Get vertex normal. This function should return the normal of a vertex at the
  77. ** specified x,y,z and smoothing_group if one exists. It is used in the algorithm which
  78. ** smooths the vertex normals on the boundaries of meshes.
  79. */
  80. virtual Point3 Get_Shared_Vertex_Normal(const Point3 & world_space_point,int smgroup) { return Point3(0,0,0); }
  81. /*
  82. ** Aggregate Model Detection. An "aggregate" is an external W3D model that we are requesting
  83. ** to be attached to a bone in the model being exported. In order for our LOD system to work
  84. ** properly, some special handling of aggregates is required (they must be added into the model
  85. ** as "additional models" rather than being placed in the normal LOD arrays). This virtual
  86. ** can be used to detect "aggregate" models.
  87. */
  88. virtual bool Is_Aggregate(void) { return false; }
  89. /*
  90. ** Proxy Detection. A "proxy" is a reference (by name) to an external game object that should
  91. ** be instantiated at the specified transform. Like the aggregates, these had to unfortunately
  92. ** be handled with special cases and therefore have this virtual function devoted solely to them.
  93. */
  94. virtual bool Is_Proxy(void) { return false; }
  95. /*
  96. ** Virtual Constructor
  97. */
  98. static GeometryExportTaskClass * Create_Task(INode * node,GeometryExportContextClass & context);
  99. /*
  100. ** Pre-Export Optimization of a set of geometry export tasks. This does things like
  101. ** separating multi-material meshes, combining small meshes which are nearby and use the
  102. ** same material, etc.
  103. */
  104. static void Optimize_Geometry( DynamicVectorClass<GeometryExportTaskClass *> & tasks,
  105. GeometryExportContextClass & context );
  106. protected:
  107. /*
  108. ** Internal RTTI
  109. */
  110. enum
  111. {
  112. MESH = 0,
  113. COLLISIONBOX,
  114. DAZZLE,
  115. NULLOBJ,
  116. AGGREGATE,
  117. PROXY,
  118. };
  119. virtual int Get_Geometry_Type(void) = 0;
  120. protected:
  121. char Name[W3D_NAME_LEN];
  122. char ContainerName[W3D_NAME_LEN];
  123. int BoneIndex;
  124. Matrix3 ExportSpace;
  125. TimeValue CurTime;
  126. INode * Node;
  127. };
  128. #endif //GEOMETRYEXPORTTASK_H