DamageZoneNode.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/DamageZoneNode.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 10/09/00 1:10p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __DAMAGE_ZONE_NODE_H
  39. #define __DAMAGE_ZONE_NODE_H
  40. #include "objectnode.h"
  41. #include "icons.h"
  42. #include "spawn.h"
  43. #include "grabhandles.h"
  44. ////////////////////////////////////////////////////////////////////////////
  45. // Forward declarations
  46. ////////////////////////////////////////////////////////////////////////////
  47. class PresetClass;
  48. class DamageZoneGameObj;
  49. ////////////////////////////////////////////////////////////////////////////
  50. //
  51. // DamageZoneNodeClass
  52. //
  53. ////////////////////////////////////////////////////////////////////////////
  54. class DamageZoneNodeClass : public NodeClass
  55. {
  56. public:
  57. //////////////////////////////////////////////////////////////////
  58. // Public constructors/destructors
  59. //////////////////////////////////////////////////////////////////
  60. DamageZoneNodeClass (PresetClass *preset = NULL);
  61. DamageZoneNodeClass (const DamageZoneNodeClass &src);
  62. ~DamageZoneNodeClass (void);
  63. //////////////////////////////////////////////////////////////
  64. // Public operators
  65. //////////////////////////////////////////////////////////////
  66. const DamageZoneNodeClass &operator= (const DamageZoneNodeClass &src);
  67. //////////////////////////////////////////////////////////////////
  68. // Public methods
  69. //////////////////////////////////////////////////////////////////
  70. //
  71. // From PersistClass
  72. //
  73. virtual const PersistFactoryClass & Get_Factory (void) const;
  74. virtual bool Save (ChunkSaveClass &csave);
  75. virtual bool Load (ChunkLoadClass &cload);
  76. // From NodeClass
  77. NodeClass * Clone (void) { return new DamageZoneNodeClass (*this); }
  78. void Initialize (void);
  79. NODE_TYPE Get_Type (void) const { return NODE_TYPE_DAMAGE_ZONE; }
  80. int Get_Icon_Index (void) const { return ZONE_ICON; }
  81. PhysClass * Peek_Physics_Obj (void) const;
  82. bool Is_Static (void) const { return false; }
  83. void Hide (bool hide);
  84. //
  85. // Scene methods
  86. //
  87. void Add_To_Scene (void);
  88. void Remove_From_Scene (void);
  89. //
  90. // Notifications
  91. //
  92. void On_Rotate (void);
  93. void On_Translate (void);
  94. void On_Transform (void);
  95. //
  96. // Export methods
  97. //
  98. void Pre_Export (void);
  99. void Post_Export (void);
  100. //
  101. // Zone edit methods
  102. //
  103. void On_Vertex_Drag_Begin (int vertex_index);
  104. void On_Vertex_Drag (int vertex_index, POINT point);
  105. //
  106. // DamageZoneNodeClass specific
  107. //
  108. Box3DClass * Get_Box (void);
  109. //DamageZoneGameObj * Get_Zone_Obj (void) const { return DamageZoneGameObj; }
  110. protected:
  111. //////////////////////////////////////////////////////////////////
  112. // Protected methods
  113. //////////////////////////////////////////////////////////////////
  114. void Update_Game_Obj (void);
  115. void Create_Game_Obj (void);
  116. void Destroy_Game_Obj (void);
  117. private:
  118. //////////////////////////////////////////////////////////////////
  119. // Private member data
  120. //////////////////////////////////////////////////////////////////
  121. Box3DPhysClass * m_PhysObj;
  122. DamageZoneGameObj * m_GameObj;
  123. GrabHandlesClass m_GrabHandles;
  124. Vector3 m_FirstPoint;
  125. Vector3 m_CachedSize;
  126. };
  127. //////////////////////////////////////////////////////////////////
  128. // Peek_Physics_Obj
  129. //////////////////////////////////////////////////////////////////
  130. inline PhysClass *
  131. DamageZoneNodeClass::Peek_Physics_Obj (void) const
  132. {
  133. return m_PhysObj;
  134. }
  135. //////////////////////////////////////////////////////////////////
  136. // On_Rotate
  137. //////////////////////////////////////////////////////////////////
  138. inline void
  139. DamageZoneNodeClass::On_Rotate (void)
  140. {
  141. if (m_IsInScene) {
  142. m_GrabHandles.Position_Around_Node (this);
  143. }
  144. Update_Game_Obj ();
  145. NodeClass::On_Rotate ();
  146. return ;
  147. }
  148. //////////////////////////////////////////////////////////////////
  149. // On_Translate
  150. //////////////////////////////////////////////////////////////////
  151. inline void
  152. DamageZoneNodeClass::On_Translate (void)
  153. {
  154. if (m_IsInScene) {
  155. m_GrabHandles.Position_Around_Node (this);
  156. }
  157. Update_Game_Obj ();
  158. NodeClass::On_Translate ();
  159. return ;
  160. }
  161. //////////////////////////////////////////////////////////////////
  162. // On_Transform
  163. //////////////////////////////////////////////////////////////////
  164. inline void
  165. DamageZoneNodeClass::On_Transform (void)
  166. {
  167. if (m_IsInScene) {
  168. m_GrabHandles.Position_Around_Node (this);
  169. }
  170. Update_Game_Obj ();
  171. NodeClass::On_Transform ();
  172. return ;
  173. }
  174. //////////////////////////////////////////////////////////////////
  175. // Get_Box
  176. //////////////////////////////////////////////////////////////////
  177. inline Box3DClass *
  178. DamageZoneNodeClass::Get_Box (void)
  179. {
  180. Box3DClass *box = NULL;
  181. if (m_PhysObj != NULL) {
  182. box = m_PhysObj->Get_Box ();
  183. }
  184. return box;
  185. }
  186. #endif //__DAMAGE_ZONE_NODE_H