TerrainNode.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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/TerrainNode.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 2/12/02 1:44p $*
  29. * *
  30. * $Revision:: 22 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __TERRAIN_NODE_H
  39. #define __TERRAIN_NODE_H
  40. #include "node.h"
  41. #include "vector.h"
  42. #include "icons.h"
  43. #include "tilenode.h"
  44. #include "terrainsectionpersist.h"
  45. #include "proxy.h"
  46. ////////////////////////////////////////////////////////////////////////////
  47. // Forward declarations
  48. ////////////////////////////////////////////////////////////////////////////
  49. class PresetClass;
  50. class CollectionClass;
  51. ////////////////////////////////////////////////////////////////////////////
  52. //
  53. // TerrainSectionNodeClass
  54. //
  55. ////////////////////////////////////////////////////////////////////////////
  56. class TerrainSectionNodeClass : public TileNodeClass
  57. {
  58. public:
  59. //////////////////////////////////////////////////////////////////
  60. // Public constructors/destructors
  61. //////////////////////////////////////////////////////////////////
  62. TerrainSectionNodeClass (void) :
  63. Terrain (NULL) {}
  64. ~TerrainSectionNodeClass (void) {}
  65. //////////////////////////////////////////////////////////////////
  66. // Public methods
  67. //////////////////////////////////////////////////////////////////
  68. //
  69. // From PersistClass
  70. //
  71. virtual const PersistFactoryClass & Get_Factory (void) const;
  72. //
  73. // From NodeClass
  74. //
  75. NodeClass * Clone (void) { return NULL; }
  76. void Initialize (void) {}
  77. NODE_TYPE Get_Type (void) const { return NODE_TYPE_TERRAIN_SECTION; }
  78. int Get_Icon_Index (void) const { return TERRAIN_ICON; }
  79. void Set_Transform (const Matrix3D &tm);
  80. void Special_Set_Transform (const Matrix3D &tm) { NodeClass::Set_Transform (tm); }
  81. void Pre_Export (void) {}
  82. void Post_Export (void) {}
  83. //
  84. // Terrain Section specific
  85. //
  86. void Create (RenderObjClass *render_obj);
  87. TerrainNodeClass * Peek_Terrain (void) const { return Terrain; }
  88. void Set_Terrain (TerrainNodeClass *terrain) { Terrain = terrain; }
  89. private:
  90. //////////////////////////////////////////////////////////////////
  91. // Private member data
  92. //////////////////////////////////////////////////////////////////
  93. TerrainNodeClass * Terrain;
  94. };
  95. ////////////////////////////////////////////////////////////////////////////
  96. //
  97. // TerrainNodeClass
  98. //
  99. ////////////////////////////////////////////////////////////////////////////
  100. class TerrainNodeClass : public NodeClass
  101. {
  102. public:
  103. //////////////////////////////////////////////////////////////////
  104. // Public constructors/destructors
  105. //////////////////////////////////////////////////////////////////
  106. TerrainNodeClass (PresetClass *preset = NULL);
  107. ~TerrainNodeClass (void);
  108. //////////////////////////////////////////////////////////////////
  109. // Public methods
  110. //////////////////////////////////////////////////////////////////
  111. //
  112. // From PersistClass
  113. //
  114. virtual const PersistFactoryClass & Get_Factory (void) const;
  115. void On_Post_Load (void);
  116. //
  117. // RTTI
  118. //
  119. TerrainNodeClass *As_TerrainNodeClass (void) { return this; }
  120. //
  121. // From NodeClass
  122. //
  123. NodeClass * Clone (void) { return NULL; }
  124. void Initialize (void);
  125. NODE_TYPE Get_Type (void) const { return NODE_TYPE_TERRAIN; }
  126. int Get_Icon_Index (void) const { return TERRAIN_ICON; }
  127. void Add_To_Scene (void);
  128. void Remove_From_Scene (void);
  129. void Set_Transform (const Matrix3D &tm);
  130. Matrix3D Get_Transform (void) { return Transform; }
  131. PhysClass * Peek_Physics_Obj (void) const { return NULL; }
  132. bool Is_Static (void) const { return true; }
  133. void Add_Vis_Points (VisPointGeneratorClass &generator, RenderObjClass *render_obj = NULL);
  134. void Hide (bool hide);
  135. bool Is_Hidden (void) const;
  136. void Update_Cached_Vis_IDs (void);
  137. void Reload (void);
  138. void Pre_Export (void);
  139. void Post_Export (void);
  140. bool Is_A_Child_Node (NodeClass *node) const;
  141. // Terrain specific
  142. int Get_Sub_Node_Count (void) const { return m_Sections.Count (); }
  143. NodeClass * Get_Sub_Node (int index) { return m_Sections[index]; }
  144. void Special_Set_Transform (const Matrix3D &tm);
  145. //
  146. // From PersistClass
  147. //
  148. bool Save (ChunkSaveClass &csave);
  149. bool Load (ChunkLoadClass &cload);
  150. protected:
  151. //////////////////////////////////////////////////////////////////
  152. // Protected methods
  153. //////////////////////////////////////////////////////////////////
  154. void Free_Sections (void);
  155. void Assign_Section_IDs (void);
  156. void Build_Section_ID_List (void);
  157. bool Load_Variables (ChunkLoadClass &cload);
  158. void Create_Proxies (DynamicVectorClass<ProxyClass> &proxy_list);
  159. void Create_Lights (void);
  160. void Free_Section_Data (void);
  161. PresetClass *Find_Proxy_Preset (const char *preset_name);
  162. //////////////////////////////////////////////////////////////////
  163. // Protected member data
  164. //////////////////////////////////////////////////////////////////
  165. DynamicVectorClass<NodeClass *> m_Sections;
  166. TerrainSectionPersistListClass m_TerrainSectionInfo;
  167. friend TerrainSectionPersistClass;
  168. friend TerrainSectionPersistListClass;
  169. Matrix3D Transform;
  170. Matrix3D LoadedTransform;
  171. };
  172. /////////////////////////////////////////////////////////////
  173. // Get_Transform
  174. /////////////////////////////////////////////////////////////
  175. /*inline Matrix3D
  176. TerrainNodeClass::Get_Transform (void)
  177. {
  178. return Matrix3D (1);
  179. }*/
  180. #endif //__TERRAIN_NODE_H