skindata.cpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. ** Command & Conquer Renegade(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/skindata.cpp 7 5/28/98 12:15p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - WWSkin *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/skindata.cpp $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 5/28/98 12:15p $*
  30. * *
  31. * $Revision:: 7 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * SkinDataClass::Save -- save the skindata in the MAX file *
  36. * SkinDataClass::Load -- load the skindata from a MAX file *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "skindata.h"
  39. /***********************************************************************************************
  40. * SkinDataClass::Save -- save the skindata in the MAX file *
  41. * *
  42. * INPUT: *
  43. * *
  44. * OUTPUT: *
  45. * *
  46. * WARNINGS: *
  47. * *
  48. * HISTORY: *
  49. * 10/26/1997 GH : Created. *
  50. *=============================================================================================*/
  51. IOResult SkinDataClass::Save(ISave *isave)
  52. {
  53. ULONG nb;
  54. /*
  55. ** save the flags
  56. */
  57. short flags = 0;
  58. if (Valid) flags |= 0x01;
  59. if (Held) flags |= 0x02;
  60. isave->BeginChunk(FLAGS_CHUNK);
  61. isave->Write(&flags,sizeof(flags),&nb);
  62. isave->EndChunk();
  63. /*
  64. ** Save the bit array of currently selected vertices
  65. */
  66. if (VertSel.NumberSet() > 0) {
  67. isave->BeginChunk(VERT_SEL_CHUNK);
  68. VertSel.Save(isave);
  69. isave->EndChunk();
  70. }
  71. /*
  72. ** Save the named selection sets of vertices
  73. */
  74. #if 0
  75. if (VertSelSets.Count() > 0) {
  76. isave->BeginChunk(INFLUENCE_DATA_CHUNK);
  77. VertSelSets.Save(isave);
  78. isave->EndChunk();
  79. }
  80. #endif
  81. /*
  82. ** Save the vertex influence data
  83. */
  84. if (VertData.Count() > 0) {
  85. isave->BeginChunk(INFLUENCE_DATA_CHUNK);
  86. isave->Write(VertData.Addr(0),VertData.Count() * sizeof(InfluenceStruct), &nb);
  87. isave->EndChunk();
  88. }
  89. return IO_OK;
  90. }
  91. /***********************************************************************************************
  92. * SkinDataClass::Load -- load the skindata from a MAX file *
  93. * *
  94. * INPUT: *
  95. * *
  96. * OUTPUT: *
  97. * *
  98. * WARNINGS: *
  99. * *
  100. * HISTORY: *
  101. * 10/26/1997 GH : Created. *
  102. *=============================================================================================*/
  103. IOResult SkinDataClass::Load(ILoad *iload)
  104. {
  105. ULONG nb;
  106. short flags;
  107. int n;
  108. IOResult res;
  109. while (IO_OK == (res=iload->OpenChunk())) {
  110. switch (iload->CurChunkID()) {
  111. case FLAGS_CHUNK:
  112. res = iload->Read(&flags,sizeof(flags),&nb);
  113. Valid = (flags & 0x01);
  114. Held = (flags & 0x02);
  115. break;
  116. case VERT_SEL_CHUNK:
  117. res = VertSel.Load(iload);
  118. break;
  119. case NAMED_SEL_SETS_CHUNK:
  120. res = VertSelSets.Load(iload);
  121. break;
  122. case INFLUENCE_DATA_CHUNK:
  123. n = iload->CurChunkLength() / sizeof(InfluenceStruct);
  124. VertData.SetCount(n);
  125. res = iload->Read(VertData.Addr(0),n*sizeof(InfluenceStruct),&nb);
  126. break;
  127. }
  128. iload->CloseChunk();
  129. if (res != IO_OK) {
  130. return res;
  131. }
  132. }
  133. /*
  134. ** ensure that the arrays are sized correctly
  135. */
  136. Invalidate();
  137. return IO_OK;
  138. }