MeshDeformData.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. ** Command & Conquer Generals(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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando / G 3D engine *
  23. * *
  24. * File Name : MeshDeformData.h *
  25. * *
  26. * Programmer : Patrick Smith *
  27. * *
  28. * Start Date : 04/26/99 *
  29. * *
  30. * Last Update :
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef __MESH_DEFORM_DATA_H
  36. #define __MESH_DEFORM_DATA_H
  37. #include <Max.h>
  38. #include "Vector.H"
  39. #include "MeshDeformSet.H"
  40. ///////////////////////////////////////////////////////////////////////////
  41. //
  42. // Typedefs
  43. //
  44. ///////////////////////////////////////////////////////////////////////////
  45. typedef DynamicVectorClass<MeshDeformSetClass *> SETS_LIST;
  46. ///////////////////////////////////////////////////////////////////////////
  47. //
  48. // MeshDeformModData
  49. //
  50. ///////////////////////////////////////////////////////////////////////////
  51. class MeshDeformModData : public LocalModData
  52. {
  53. public:
  54. //////////////////////////////////////////////////////////////////////
  55. // Public constructors/destructors
  56. //////////////////////////////////////////////////////////////////////
  57. MeshDeformModData (void)
  58. : m_CurrentSet (0) { }
  59. virtual ~MeshDeformModData (void);
  60. //////////////////////////////////////////////////////////////////////
  61. // Public methods
  62. //////////////////////////////////////////////////////////////////////
  63. virtual LocalModData * Clone (void) { return new MeshDeformModData; }
  64. void Record_Mesh_State (TriObject &tri_obj, float state, bool update_all);
  65. // Inline accessors
  66. Mesh * Peek_Mesh (void) const { return m_SetsList[m_CurrentSet]->Peek_Mesh (); }
  67. const Point3 * Peek_Orig_Vertex_Array (void) const { return m_SetsList[m_CurrentSet]->Peek_Orig_Vertex_Array (); }
  68. Point3 * Peek_Vertex_OPStart_Array (void) const { return m_SetsList[m_CurrentSet]->Peek_Vertex_OPStart_Array (); }
  69. VertColor * Peek_Vertex_Colors (void) const { return m_SetsList[m_CurrentSet]->Peek_Vertex_Colors (); }
  70. // Auto apply
  71. bool Is_Auto_Apply (void) const { return m_SetsList[m_CurrentSet]->Does_Set_Auto_Apply (); }
  72. void Auto_Apply (bool auto_apply = true) { m_SetsList[m_CurrentSet]->Auto_Apply (auto_apply); }
  73. // Data modifiers
  74. void Update_Current_Data (void) { m_SetsList[m_CurrentSet]->Update_Current_Data (); }
  75. void Set_Vertex_Position (int index, const Point3 &value) { m_SetsList[m_CurrentSet]->Set_Vertex_Position (index, value); }
  76. void Set_Vertex_Color (int index, int color_index, const VertColor &value) { m_SetsList[m_CurrentSet]->Set_Vertex_Color (index, color_index, value); }
  77. // Set managment
  78. void Set_Max_Deform_Sets (int max);
  79. void Set_Current_Set (int set_index) { m_CurrentSet = set_index; }
  80. int Get_Current_Set (void) const { return m_CurrentSet; }
  81. void Select_Set (int set_index) { m_SetsList[set_index]->Select_Members (); }
  82. void Update_Set (int set_index, DEFORM_CHANNELS flags) { m_SetsList[set_index]->Update_Members (flags); }
  83. void Restore_Set (int set_index = -1);
  84. MeshDeformSetClass & Peek_Set (int index) { return *(m_SetsList[index]); }
  85. int Get_Set_Count (void) const { return m_SetsList.Count (); }
  86. // Persistent storage
  87. IOResult Save (ISave *save_obj);
  88. IOResult Load (ILoad *load_obj);
  89. protected:
  90. //////////////////////////////////////////////////////////////////////
  91. // Protected methods
  92. //////////////////////////////////////////////////////////////////////
  93. void Resize_Vertex_Array (int count, int color_count);
  94. void Copy_Vertex_Array (Mesh &mesh);
  95. void Free_Sets_List (void);
  96. void Util_Restore_Set (int set_index);
  97. private:
  98. //////////////////////////////////////////////////////////////////////
  99. // Private member data
  100. //////////////////////////////////////////////////////////////////////
  101. // Set managment
  102. int m_CurrentSet;
  103. SETS_LIST m_SetsList;
  104. };
  105. #endif //__MESH_DEFORM_DATA_H