skindata.h 4.7 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.h 6 10/28/97 6:08p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - WWSkin *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/skindata.h $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 10/21/97 2:04p $*
  30. * *
  31. * $Revision:: 6 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef SKINDATA_H
  37. #define SKINDATA_H
  38. #include "Max.h"
  39. #include "namedsel.h"
  40. /*
  41. ** InfluenceStruct - structure which stores the bone
  42. ** influence information for a single vertex.
  43. */
  44. struct InfluenceStruct
  45. {
  46. /*
  47. ** vertices can be influenced by up to two bones.
  48. */
  49. int BoneIdx[2];
  50. float BoneWeight[2];
  51. InfluenceStruct(void) { BoneIdx[0] = -1; BoneIdx[1] = -1; BoneWeight[0] = 1.0f; BoneWeight[1] = 0.0f; }
  52. void Set_Influence(int boneidx) {
  53. // TODO: make this actually let you set two bones with
  54. // weighting values. Need UI to furnish this info...
  55. BoneIdx[0] = boneidx;
  56. }
  57. };
  58. /*
  59. ** SkinDataClass - a class which contains the bone influence data
  60. ** for the modifier. One of these will be hung off of the
  61. ** ModContext...
  62. */
  63. class SkinDataClass : public LocalModData
  64. {
  65. public:
  66. SkinDataClass(void) { Held = FALSE; Valid = FALSE; }
  67. SkinDataClass(Mesh *mesh)
  68. {
  69. VertSel = mesh->vertSel;
  70. VertData.SetCount(mesh->getNumVerts());
  71. for (int i=0; i<VertData.Count(); i++) {
  72. VertData[i].BoneIdx[0] = VertData[i].BoneIdx[1] = -1;
  73. VertData[i].BoneWeight[0] = 1.0f;
  74. VertData[i].BoneWeight[1] = 0.0f;
  75. }
  76. Valid = TRUE;
  77. Held = FALSE;
  78. }
  79. void Invalidate() { Valid = FALSE; }
  80. BOOL IsValid() { return Valid; }
  81. void Validate(Mesh *mesh)
  82. {
  83. if (!Valid)
  84. {
  85. VertSel.SetSize(mesh->vertSel.GetSize(),1);
  86. VertData.SetCount(mesh->getNumVerts());
  87. Valid = TRUE;
  88. }
  89. }
  90. virtual LocalModData * Clone(void)
  91. {
  92. SkinDataClass * newdata = new SkinDataClass();
  93. newdata->VertSel = VertSel;
  94. newdata->VertData = VertData;
  95. return newdata;
  96. }
  97. void Add_Influence(int boneidx)
  98. {
  99. /*
  100. ** Make this INode influence all currently selected vertices
  101. */
  102. for (int i=0; i<VertData.Count(); i++) {
  103. if (VertSel[i]) {
  104. VertData[i].Set_Influence(boneidx);
  105. }
  106. }
  107. }
  108. IOResult Save(ISave *isave);
  109. IOResult Load(ILoad *iload);
  110. public:
  111. BOOL Valid;
  112. BOOL Held;
  113. /*
  114. ** Current selection
  115. */
  116. BitArray VertSel;
  117. /*
  118. ** Named selection sets
  119. */
  120. NamedSelSetList VertSelSets;
  121. /*
  122. ** Vertex influence data
  123. */
  124. Tab<InfluenceStruct> VertData;
  125. /*
  126. ** Load/Save chunk ID's
  127. */
  128. enum {
  129. FLAGS_CHUNK = 0x0000,
  130. VERT_SEL_CHUNK = 0x0010,
  131. NAMED_SEL_SETS_CHUNK = 0x0020,
  132. INFLUENCE_DATA_CHUNK = 0x0030
  133. };
  134. };
  135. #endif