SceneEditor.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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/SceneEditor.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 9/08/01 10:48a $*
  29. * *
  30. * $Revision:: 58 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __SCENEEDITOR_H
  39. #define __SCENEEDITOR_H
  40. #include "pscene.h"
  41. #include "listtypes.h"
  42. #include "undomgr.h"
  43. #include "vector.h"
  44. #include "vislog.h"
  45. #include "viswindowdialog.h"
  46. //////////////////////////////////////////////////////////////////////////////////////////////////
  47. // Forward declarations
  48. //////////////////////////////////////////////////////////////////////////////////////////////////
  49. class Vector3;
  50. class Matrix3D;
  51. class NodeBaseClass;
  52. class NodeMgrClass;
  53. class SelectionMgrClass;
  54. class AudibleSoundClass;
  55. class DecorationPhysClass;
  56. class Phys3Class;
  57. class PresetClass;
  58. class SkyClass;
  59. class LightNodeClass;
  60. //////////////////////////////////////////////////////////////////////////////////////////////////
  61. //
  62. // SceneEditorClass
  63. //////////////////////////////////////////////////////////////////////////////////////////////////
  64. class SceneEditorClass : public PhysicsSceneClass
  65. {
  66. public:
  67. //////////////////////////////////////////////////////////
  68. // Public constructors/destructors
  69. //////////////////////////////////////////////////////////
  70. SceneEditorClass (void);
  71. virtual ~SceneEditorClass (void);
  72. //////////////////////////////////////////////////////////
  73. // Public methods
  74. //////////////////////////////////////////////////////////
  75. //
  76. // Object creation/destruction
  77. //
  78. virtual void Add_Node (NodeClass *node);
  79. virtual NodeClass * Create_Node (PresetClass *preset, Matrix3D *transform = NULL, DWORD obj_id = 0, bool add_to_scene = true);
  80. virtual NodeClass * Clone_Node (NodeClass *node);
  81. virtual bool Delete_Node (NodeClass *node, bool allow_undo = true);
  82. virtual void Delete_Nodes (void);
  83. virtual bool Delete_Nodes (PresetClass *preset);
  84. virtual void Update_File_Mgr (NodeClass *node, bool badd = true);
  85. //
  86. // Cut/copy/paste/undo methods
  87. //
  88. virtual bool Cut_Objects (void);
  89. virtual bool Cut_Object (NodeClass *pnode) { return false; }
  90. virtual bool Copy_Objects (void);
  91. virtual bool Copy_Object (NodeClass *pnode) { return false; }
  92. virtual bool Paste_Objects (void);
  93. virtual bool Paste_Object (NodeClass *pnode) { return false; }
  94. virtual bool Can_Paste (void);
  95. virtual bool Clone_Objects (void);
  96. virtual bool Clone_Object (NodeClass *pnode) { return false; }
  97. virtual bool Undo (void);
  98. virtual void Begin_Operation (OPERATION_TYPE type, NodeClass *node);
  99. virtual void Begin_Operation (OPERATION_TYPE type, NODE_LIST *affected_list = NULL);
  100. virtual void End_Operation (void);
  101. //
  102. // Object transformation methods
  103. //
  104. virtual void Lock_Nodes (bool lock);
  105. virtual Vector3 Build_Node_List (NODE_LIST &node_list);
  106. //
  107. // Inline accessors
  108. //
  109. virtual SelectionMgrClass & Get_Selection_Mgr (void) { return *m_SelectionMgr; }
  110. virtual UndoMgrClass & Get_Undo_Mgr (void) { return m_UndoMgr; }
  111. virtual GROUP_LIST & Get_Group_List (void) { return m_GroupsList; }
  112. //
  113. // Group methods
  114. //
  115. virtual GroupMgrClass * Add_Global_Group (const CString &name, NODE_LIST *initial_list = NULL);
  116. virtual void Remove_Global_Group (GroupMgrClass *pgroup);
  117. virtual void Add_Group_To_Toolbar (GroupMgrClass *pgroup);
  118. virtual void Remove_Group_From_Toolbar (GroupMgrClass *pgroup);
  119. virtual void Reset_Global_Groups_List (void);
  120. //
  121. // Initialization methods
  122. //
  123. virtual void Initialize (void);
  124. virtual void Cleanup_Resources (void);
  125. //
  126. // Selection methods
  127. //
  128. void Set_Selection (NodeClass *node);
  129. void Toggle_Selection (NodeClass *node);
  130. void Update_Selection_Boxes (void);
  131. void Replace_Selection (void);
  132. //
  133. // Hit test methods
  134. //
  135. bool Execute_Function_At_Point (CPoint point);
  136. NodeClass * Find_Node_At_Point (CPoint point, Vector3 *intersect_pt = NULL);
  137. void Select_Node_At_Point (CPoint point) { Set_Selection (Find_Node_At_Point (point)); }
  138. void Toggle_Node_Selection_At_Point (CPoint point) { Toggle_Selection (Find_Node_At_Point (point)); }
  139. //
  140. // Vis generation methods
  141. //
  142. void Record_Vis_Info (const Matrix3D & view_transform, const Vector3 &store_loc);
  143. void Display_Vis_Points (bool onoff);
  144. bool Are_Vis_Points_Displayed (void) const { return m_bVisPointsDisplayed; }
  145. void Create_Vis_Point (const Matrix3D &transform);
  146. void Remove_All_Vis_Points (void);
  147. virtual void Reset_Vis (bool doitnow = false);
  148. virtual void Internal_Vis_Reset (void);
  149. void Get_Vis_Camera_FOV (double &hov, double &vfov);
  150. void Get_Vis_Camera_Clip_Planes (float &znear, float &zfar);
  151. VisLogClass & Get_Vis_Log (void) { return m_VisLog; }
  152. void Set_Total_Vis_Points (int total) { m_TotalVisPoints = total; }
  153. int Get_Total_Vis_Points (void) const { return m_TotalVisPoints; }
  154. CameraClass * Get_Render_Camera (void);
  155. void Export_VIS (LPCTSTR filename);
  156. void Discard_Vis (void);
  157. void Reset_Dynamic_Object_Visibility_Status (void);
  158. void Reset_Vis_For_Node (NodeClass *node);
  159. void Generate_Uniform_Sampled_Vis (float granularity, float sample_height, bool ignore_bias, bool selection_only, bool farm_mode = false,int farm_cpu_index = 1,int farm_cpu_total = 1);
  160. void Generate_Edge_Sampled_Vis (float granularity, bool ignore_bias,bool farm_mode = false,int farm_cpu_index = 1,int farm_cpu_total = 1);
  161. void Generate_Light_Vis(bool farm_mode = false, int farm_cpu_index = 1, int farm_cpu_total = 1);
  162. void Generate_Manual_Vis(bool farm_mode = false, int farm_cpu_index = 1, int farm_cpu_total = 1);
  163. bool Are_Manual_Vis_Points_Visible (void);
  164. void Show_Manual_Vis_Points (bool show_points);
  165. bool Is_Vis_Window_Visible (void);
  166. void Show_Vis_Window (bool onoff);
  167. //
  168. // Update methods
  169. //
  170. void On_Frame (void);
  171. //
  172. // Sphere methods
  173. //
  174. bool Are_Sound_Spheres_Displayed (void) const { return m_DisplaySoundSpheres; }
  175. void Display_Sound_Spheres (bool onoff);
  176. bool Are_Light_Spheres_Displayed (void) const { return m_DisplayLightSpheres; }
  177. void Display_Light_Spheres (bool onoff);
  178. //
  179. // Light methods
  180. //
  181. bool Are_Lights_On (void) const { return m_bLightsOn; }
  182. void Turn_Lights_On (bool onoff);
  183. void Reload_Lightmap_Models (void);
  184. void Export_Lights (LPCTSTR filename);
  185. void Import_Lights (DynamicVectorClass<StringClass> &filename_list, DynamicVectorClass<LightNodeClass *> *node_list = NULL);
  186. void Import_Sunlight (LPCTSTR filename);
  187. void Build_Light_List (ChunkLoadClass &cload, DynamicVectorClass<LightClass *> &light_list, int group_id = 0);
  188. void Filter_Lights (DynamicVectorClass<LightClass *> &light_list);
  189. bool Compare_Lights (LightClass *light1, LightClass *light2);
  190. void Update_Lighting (void);
  191. void Set_Sun_Light_Orientation (float yaw, float pitch);
  192. //
  193. // Background sound methods
  194. //
  195. void Set_Background_Music (LPCTSTR filename);
  196. LPCTSTR Get_Background_Music_Filename (void) const { return m_BackgroundSoundFilename; }
  197. //
  198. // Pathfinding methods
  199. //
  200. void Generate_Pathfind_Portals (void);
  201. void Pathfind_Floodfill (Phys3Class &char_sim, const Vector3 &start_pos);
  202. void DoObjectGoto (NodeClass *node1, NodeClass *node2);
  203. //
  204. // Aggregate methods
  205. //
  206. void View_Aggregate_Children (bool view = true);
  207. bool Are_Aggregate_Children_Visible (void) const { return m_bAggregateChildrenVisible; }
  208. //
  209. // Culling system accessors
  210. //
  211. void Re_Partition_Dynamic_Objects (DynamicVectorClass<AABoxClass> & virtual_occludees) { Re_Partition_Dynamic_Culling_System (virtual_occludees); }
  212. void Re_Partition_Audio_System (void);
  213. //
  214. // Miscellaneous
  215. //
  216. bool Are_Static_Anim_Phys_Displayed (void) const { return m_ShowStaticAnimPhys; }
  217. void Display_Static_Anim_Phys (bool onoff);
  218. bool Are_Editor_Objects_Displayed (void) const { return m_ShowEditorObjects; }
  219. void Display_Editor_Objects (bool onoff);
  220. void Enable_Proxy_Creation (bool onoff) { m_CreateProxies = onoff; }
  221. bool Is_Proxy_Creation_Enabled (void) const { return m_CreateProxies; }
  222. //
  223. // Building methods
  224. //
  225. void Enable_Building_Power (bool onoff);
  226. bool Is_Building_Power_Enabled (void) const { return m_BuildingPowerEnabled; }
  227. protected:
  228. //////////////////////////////////////////////////////////
  229. // Protected methods
  230. //////////////////////////////////////////////////////////
  231. virtual void Add_Groups_To_List (NodeClass &node, GROUP_LIST &group_list);
  232. virtual void Add_Nodes_To_List (NodeClass &node, NODE_LIST &node_list);
  233. virtual void Build_Group_List (GROUP_LIST &group_list, NodeClass *node = NULL);
  234. virtual void Build_Node_List (NODE_LIST &node_list, NodeClass *node);
  235. virtual void Update_Toolbars (void);
  236. virtual void Empty_Local_Clipboard (void);
  237. void Move_Selected_Nodes (void);
  238. //
  239. // From base class
  240. //
  241. virtual void On_Vis_Occluders_Rendered(VisRenderContextClass & context,VisSampleClass & sample);
  242. private:
  243. //////////////////////////////////////////////////////////
  244. // Private member data
  245. //////////////////////////////////////////////////////////
  246. //SkyClass * m_Sky;
  247. SelectionMgrClass * m_SelectionMgr;
  248. UndoMgrClass m_UndoMgr;
  249. UINT m_uiClipboardFormat;
  250. GROUP_LIST m_GroupsList;
  251. DynamicVectorClass<NodeClass *> m_LocalClipboard;
  252. bool m_bLightsOn;
  253. bool m_bAggregateChildrenVisible;
  254. bool m_DisplaySoundSpheres;
  255. bool m_DisplayLightSpheres;
  256. CString m_BackgroundSoundFilename;
  257. CString m_SkyTexture;
  258. bool m_bVisPointsDisplayed;
  259. DynamicVectorClass<DecorationPhysClass *> m_VisPoints;
  260. VisLogClass m_VisLog;
  261. int m_TotalVisPoints;
  262. bool m_ManualVisPointsVisible;
  263. bool m_ShowStaticAnimPhys;
  264. bool m_ShowEditorObjects;
  265. bool m_BuildingPowerEnabled;
  266. bool m_CreateProxies;
  267. VisWindowDialogClass m_VisWindow;
  268. NodeClass * m_MovingObject;
  269. };
  270. #endif //__SCENEEDITOR_H