MeshDeformSaveSet.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. /* $Header: /Commando/Code/Tools/max2w3d/MeshDeformSaveSet.cpp 2 6/16/99 6:56p Patrick $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G 3D engine *
  24. * *
  25. * File Name : MeshDeformSaveSet.CPP
  26. * *
  27. * Programmer : Patrick Smith *
  28. * *
  29. * Start Date : 05/28/99 *
  30. * *
  31. * Last Update :
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #include "MeshDeformSaveSet.H"
  37. #include "Util.H"
  38. ////////////////////////////////////////////////////////////////////////
  39. //
  40. // Reset
  41. //
  42. ////////////////////////////////////////////////////////////////////////
  43. void
  44. MeshDeformSaveSetClass::Reset (void)
  45. {
  46. //
  47. // Free all the keyframe pointers in our list
  48. //
  49. for (int index = 0; index < m_DeformData.Count (); index ++) {
  50. SAFE_DELETE (m_DeformData[index]);
  51. }
  52. m_DeformData.Delete_All ();
  53. m_CurrentKeyFrame = NULL;
  54. return ;
  55. }
  56. ////////////////////////////////////////////////////////////////////////
  57. //
  58. // Begin_Keyframe
  59. //
  60. ////////////////////////////////////////////////////////////////////////
  61. void
  62. MeshDeformSaveSetClass::Begin_Keyframe (float state)
  63. {
  64. //
  65. // Allocate a new keyframe structure
  66. //
  67. m_CurrentKeyFrame = new KEYFRAME;
  68. m_CurrentKeyFrame->state = state;
  69. //
  70. // Add this new keyframe to the end of our list
  71. //
  72. m_DeformData.Add (m_CurrentKeyFrame);
  73. return ;
  74. }
  75. ////////////////////////////////////////////////////////////////////////
  76. //
  77. // End_Keyframe
  78. //
  79. ////////////////////////////////////////////////////////////////////////
  80. void
  81. MeshDeformSaveSetClass::End_Keyframe (void)
  82. {
  83. m_CurrentKeyFrame = NULL;
  84. return ;
  85. }
  86. ////////////////////////////////////////////////////////////////////////
  87. //
  88. // Add_Vert
  89. //
  90. ////////////////////////////////////////////////////////////////////////
  91. void
  92. MeshDeformSaveSetClass::Add_Vert
  93. (
  94. UINT vert_index,
  95. const Point3 & position,
  96. const VertColor & color
  97. )
  98. {
  99. // State OK?
  100. assert (m_CurrentKeyFrame != NULL);
  101. if (m_CurrentKeyFrame != NULL) {
  102. //
  103. // Create a structure that will hold the
  104. // vertex information.
  105. //
  106. DEFORM_DATA data;
  107. data.vert_index = vert_index;
  108. data.position = position;
  109. data.color = color;
  110. //
  111. // Add this vertex information to the keyframe list
  112. //
  113. m_CurrentKeyFrame->deform_list.Add (data);
  114. }
  115. return ;
  116. }
  117. ////////////////////////////////////////////////////////////////////////
  118. //
  119. // Replace_Deform_Data
  120. //
  121. ////////////////////////////////////////////////////////////////////////
  122. void
  123. MeshDeformSaveSetClass::Replace_Deform_Data
  124. (
  125. int keyframe_index,
  126. DynamicVectorClass<DEFORM_DATA> &list
  127. )
  128. {
  129. KEYFRAME *key_frame = m_DeformData[keyframe_index];
  130. if (key_frame != NULL) {
  131. //
  132. // Replace the vertex deformation list for the keyframe
  133. //
  134. key_frame->deform_list.Delete_All ();
  135. key_frame->deform_list = list;
  136. }
  137. return ;
  138. }
  139. ////////////////////////////////////////////////////////////////////////
  140. //
  141. // Get_Deform_Count
  142. //
  143. ////////////////////////////////////////////////////////////////////////
  144. /*int
  145. MeshDeformSaveSetClass::Get_Deform_Count (void) const
  146. {
  147. //
  148. // Count up all the deform entries for all the keyframes
  149. //
  150. int count = 0;
  151. for (int index = 0; index < m_DeformData.Count (); index ++) {
  152. KEYFRAME *key_frame = m_DeformData[index];
  153. if (key_frame != NULL) {
  154. count += key_frame->deform_list.Count ();
  155. }
  156. }
  157. return count;
  158. }*/