nodefilt.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. /* $Header: /Commando/Code/Tools/max2w3d/nodefilt.cpp 9 1/16/98 10:34a Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G *
  24. * *
  25. * File Name : NODEFILT.CPP *
  26. * *
  27. * Programmer : Greg Hjelstrom *
  28. * *
  29. * Start Date : 06/09/97 *
  30. * *
  31. * Last Update : June 9, 1997 [GH] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * VisibleMeshINodeFilter::Accept_Node -- Accepts visible meshes *
  36. * AnimatedINodeFilter::Accept_Node -- Accepts animated INodes *
  37. * RootINodeFilter::Accept_Node -- Accepts root INodes *
  38. * VisibleHelperINodeFilter::Accept_Node -- Accepts visible helper objects *
  39. * VisibleMeshOrHelperINodeFilter::Accept_Node -- Accepts visible helper or mesh objects *
  40. * HelperINodeFilter::Accept_Node -- Accepts all helper inodes (including hidden) *
  41. * MeshINodeFilter::Accept_Node -- Accepts all mesh inodes (including hidden) *
  42. * VisibleSelectedINodeFilter::Accept_Node -- Accepts Visible and selected inodes *
  43. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  44. #include "nodefilt.h"
  45. #include <istdplug.h>
  46. /*
  47. ** The default node filter:
  48. */
  49. VisibleMeshINodeFilter DefaultINodeFilter;
  50. /***********************************************************************************************
  51. * HelperINodeFilter::Accept_Node -- Accepts all helper inodes (including hidden) *
  52. * *
  53. * INPUT: *
  54. * *
  55. * OUTPUT: *
  56. * *
  57. * WARNINGS: *
  58. * *
  59. * HISTORY: *
  60. * 07/10/1997 GH : Created. *
  61. *=============================================================================================*/
  62. BOOL HelperINodeFilter::Accept_Node(INode * node,TimeValue time)
  63. {
  64. Object * obj = node->EvalWorldState(time).obj;
  65. if (obj && obj->SuperClassID() == HELPER_CLASS_ID) {
  66. return TRUE;
  67. }
  68. return FALSE;
  69. }
  70. /***********************************************************************************************
  71. * MeshINodeFilter::Accept_Node -- Accepts all mesh inodes (including hidden) *
  72. * *
  73. * INPUT: *
  74. * *
  75. * OUTPUT: *
  76. * *
  77. * WARNINGS: *
  78. * *
  79. * HISTORY: *
  80. * 07/10/1997 GH : Created. *
  81. *=============================================================================================*/
  82. BOOL MeshINodeFilter::Accept_Node(INode * node,TimeValue time)
  83. {
  84. Object * obj = node->EvalWorldState(time).obj;
  85. if (obj &&
  86. obj->CanConvertToType(triObjectClassID) &&
  87. obj->SuperClassID() == GEOMOBJECT_CLASS_ID)
  88. {
  89. return TRUE;
  90. } else {
  91. return FALSE;
  92. }
  93. }
  94. /***********************************************************************************************
  95. * VisibleMeshINodeFilter::Accept_Node -- Accepts visible meshes *
  96. * *
  97. * Accepts nodes which: *
  98. * - can be converted to tri-meshes *
  99. * - are not hidden *
  100. * - whose visibility > 0.0 *
  101. * *
  102. * INPUT: *
  103. * *
  104. * OUTPUT: *
  105. * *
  106. * WARNINGS: *
  107. * *
  108. * HISTORY: *
  109. * 06/09/1997 GH : Created. *
  110. *=============================================================================================*/
  111. BOOL VisibleMeshINodeFilter::Accept_Node(INode * node, TimeValue time)
  112. {
  113. Object * obj = node->EvalWorldState(time).obj;
  114. if
  115. (
  116. obj
  117. && !node->IsHidden ()
  118. && obj->CanConvertToType(triObjectClassID)
  119. && obj->SuperClassID() == GEOMOBJECT_CLASS_ID
  120. // && node->GetVisibility (time) > 0.0f
  121. )
  122. {
  123. return TRUE;
  124. } else {
  125. return FALSE;
  126. }
  127. }
  128. /***********************************************************************************************
  129. * VisibleHelperINodeFilter::Accept_Node -- Accepts visible helper objects *
  130. * *
  131. * INPUT: *
  132. * *
  133. * OUTPUT: *
  134. * *
  135. * WARNINGS: *
  136. * *
  137. * HISTORY: *
  138. * 07/03/1997 GH : Created. *
  139. *=============================================================================================*/
  140. BOOL VisibleHelperINodeFilter::Accept_Node(INode * node, TimeValue time)
  141. {
  142. Object * obj = node->EvalWorldState(time).obj;
  143. if ((!obj) || (node->IsHidden()) /*|| (node->GetVisibility(time) <= 0.0f)*/) {
  144. return FALSE;
  145. }
  146. if (obj->SuperClassID() == HELPER_CLASS_ID) {
  147. return TRUE;
  148. }
  149. return FALSE;
  150. }
  151. /***********************************************************************************************
  152. * VisibleMeshOrHelperINodeFilter::Accept_Node -- Accepts visible helper or mesh objects *
  153. * *
  154. * INPUT: *
  155. * *
  156. * OUTPUT: *
  157. * *
  158. * WARNINGS: *
  159. * *
  160. * HISTORY: *
  161. * 07/03/1997 GH : Created. *
  162. *=============================================================================================*/
  163. BOOL VisibleMeshOrHelperINodeFilter::Accept_Node(INode * node, TimeValue time)
  164. {
  165. Object * obj = node->EvalWorldState(time).obj;
  166. if ((!obj) || (node->IsHidden()) /*|| (node->GetVisibility(time) <= 0.0f)*/) {
  167. return FALSE;
  168. }
  169. if (obj->CanConvertToType(triObjectClassID) && obj->SuperClassID() == GEOMOBJECT_CLASS_ID) {
  170. return TRUE;
  171. }
  172. if (obj->SuperClassID() == HELPER_CLASS_ID) {
  173. return TRUE;
  174. }
  175. return FALSE;
  176. }
  177. /***********************************************************************************************
  178. * AnimatedINodeFilter::Accept_Node -- Accepts animated INodes *
  179. * *
  180. * Accepts nodes which: *
  181. * - can be converted to tri-meshes *
  182. * - are not hidden *
  183. * - whose visibility > 0.0 *
  184. * - have animation keys! *
  185. * *
  186. * INPUT: *
  187. * *
  188. * OUTPUT: *
  189. * *
  190. * WARNINGS: *
  191. * *
  192. * HISTORY: *
  193. * 06/09/1997 GH : Created. *
  194. *=============================================================================================*/
  195. BOOL AnimatedINodeFilter::Accept_Node(INode * node, TimeValue time)
  196. {
  197. Object * obj = node->EvalWorldState(time).obj;
  198. Control * poscon = node->GetTMController()->GetPositionController();
  199. Control * rotcon = node->GetTMController()->GetRotationController();
  200. int numkeys = 0;
  201. if (poscon != NULL) {
  202. IKeyControl * poskeys = GetKeyControlInterface(poscon);
  203. if (poskeys != NULL) numkeys += poskeys->GetNumKeys();
  204. }
  205. if (rotcon != NULL) {
  206. IKeyControl * rotkeys = GetKeyControlInterface(rotcon);
  207. if (rotkeys != NULL) numkeys += rotkeys->GetNumKeys();
  208. }
  209. if (obj && !node->IsHidden() && numkeys > 0) {
  210. return TRUE;
  211. }
  212. return FALSE;
  213. }
  214. /***********************************************************************************************
  215. * VisibleSelectedINodeFilter::Accept_Node -- Accepts Visible and selected inodes *
  216. * *
  217. * INPUT: *
  218. * *
  219. * OUTPUT: *
  220. * *
  221. * WARNINGS: *
  222. * *
  223. * HISTORY: *
  224. * 1/13/98 GTH : Created. *
  225. *=============================================================================================*/
  226. BOOL VisibleSelectedINodeFilter::Accept_Node(INode * node, TimeValue time)
  227. {
  228. if (!node->IsHidden() && node->Selected()) {
  229. return TRUE;
  230. } else {
  231. return FALSE;
  232. }
  233. }