meshcon.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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/meshcon.cpp 34 10/27/00 4:12p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G Math Library *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/meshcon.cpp $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 10/27/00 10:39a $*
  30. * *
  31. * $Revision:: 34 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * MeshConnectionsClass::MeshConnectionsClass -- Constructor *
  36. * MeshConnectionsClass::~MeshConnectionsClass -- Destructor *
  37. * MeshConnectionsClass::Get_Aggregate_Data -- name and bone for the given aggregate *
  38. * MeshConnectionsClass::Get_Proxy_Data -- name and transform for the specified proxy object *
  39. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  40. #include "meshcon.h"
  41. #include "util.h"
  42. #include "SnapPoints.h"
  43. #include "w3dappdata.h"
  44. #include "geometryexporttask.h"
  45. #include "geometryexportcontext.h"
  46. /***********************************************************************************************
  47. * MeshConnectionsClass::MeshConnectionsClass -- Constructor *
  48. * *
  49. * INPUT: *
  50. * *
  51. * OUTPUT: *
  52. * *
  53. * WARNINGS: *
  54. * *
  55. * HISTORY: *
  56. * 10/19/2000 gth : New version which uses the GeometryExportTasks *
  57. *=============================================================================================*/
  58. MeshConnectionsClass::MeshConnectionsClass
  59. (
  60. DynamicVectorClass<GeometryExportTaskClass *> sub_object_list,
  61. GeometryExportContextClass & context
  62. ) :
  63. CurTime(context.CurTime),
  64. Origin(context.Origin)
  65. {
  66. unsigned int i;
  67. assert(Origin != NULL);
  68. /*
  69. ** Set the name, count the sub-objects and aggregates
  70. */
  71. Set_W3D_Name(Name,context.ModelName);
  72. /*
  73. ** For each sub-object, record the bone it is attached to and its name
  74. */
  75. int count = sub_object_list.Count();
  76. for (i=0; i<count; i++) {
  77. ConnectionStruct con;
  78. sub_object_list[i]->Get_Full_Name(con.ObjectName,sizeof(con.ObjectName));
  79. con.BoneIndex = sub_object_list[i]->Get_Bone_Index();
  80. con.MeshINode = sub_object_list[i]->Get_Object_Node();
  81. if (sub_object_list[i]->Is_Aggregate()) {
  82. Aggregates.Add(con);
  83. } else if (sub_object_list[i]->Is_Proxy()) {
  84. ProxyObjects.Add(con);
  85. } else {
  86. SubObjects.Add(con);
  87. }
  88. }
  89. }
  90. /***********************************************************************************************
  91. * MeshConnectionsClass::~MeshConnectionsClass -- Destructor *
  92. * *
  93. * INPUT: *
  94. * *
  95. * OUTPUT: *
  96. * *
  97. * WARNINGS: *
  98. * *
  99. * HISTORY: *
  100. * 07/24/1997 GH : Created. *
  101. *=============================================================================================*/
  102. MeshConnectionsClass::~MeshConnectionsClass(void)
  103. {
  104. }
  105. /***********************************************************************************************
  106. * MeshConnectionsClass::Get_Sub_Object_Data -- Returns the name and bone index for a given obj*
  107. * *
  108. * INPUT: *
  109. * *
  110. * OUTPUT: *
  111. * *
  112. * WARNINGS: *
  113. * *
  114. * HISTORY: *
  115. * 9/14/1999 AJA : Created. *
  116. *=============================================================================================*/
  117. bool MeshConnectionsClass::Get_Sub_Object_Data (int mesh_idx, char **out_name, int *out_boneindex,
  118. INode **out_inode)
  119. {
  120. if (mesh_idx >= SubObjects.Count()) return false;
  121. if (out_name)
  122. *out_name = SubObjects[mesh_idx].ObjectName;
  123. if (out_boneindex)
  124. *out_boneindex = SubObjects[mesh_idx].BoneIndex;
  125. if (out_inode)
  126. *out_inode = SubObjects[mesh_idx].MeshINode;
  127. return true;
  128. }
  129. /***********************************************************************************************
  130. * MeshConnectionsClass::Get_Aggregate_Data -- name and bone for the given aggregate *
  131. * *
  132. * INPUT: *
  133. * *
  134. * OUTPUT: *
  135. * *
  136. * WARNINGS: *
  137. * *
  138. * HISTORY: *
  139. * 10/25/2000 gth : Created. *
  140. *=============================================================================================*/
  141. bool MeshConnectionsClass::Get_Aggregate_Data(int mesh_idx, char **out_name, int *out_boneindex,
  142. INode **out_inode)
  143. {
  144. if (mesh_idx >= Aggregates.Count()) return false;
  145. if (out_name)
  146. *out_name = Aggregates[mesh_idx].ObjectName;
  147. if (out_boneindex)
  148. *out_boneindex = Aggregates[mesh_idx].BoneIndex;
  149. if (out_inode)
  150. *out_inode = Aggregates[mesh_idx].MeshINode;
  151. return true;
  152. }
  153. /***********************************************************************************************
  154. * MeshConnectionsClass::Get_Proxy_Data -- name and transform for the specified proxy object *
  155. * *
  156. * INPUT: *
  157. * *
  158. * OUTPUT: *
  159. * *
  160. * WARNINGS: *
  161. * *
  162. * HISTORY: *
  163. * 10/26/2000 gth : Created. *
  164. *=============================================================================================*/
  165. bool MeshConnectionsClass::Get_Proxy_Data(int index, char **out_name, int *out_boneindex,
  166. INode **out_inode)
  167. {
  168. if (index >= ProxyObjects.Count()) return false;
  169. if (out_name)
  170. *out_name = ProxyObjects[index].ObjectName;
  171. if (out_boneindex)
  172. *out_boneindex = ProxyObjects[index].BoneIndex;
  173. if (out_inode)
  174. *out_inode = ProxyObjects[index].MeshINode;
  175. return true;
  176. }