viewerctrl.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/viewerctrl.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 11/06/01 4:24p $*
  29. * *
  30. * $Revision:: 6 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __VIEWER_CTRL_H
  39. #define __VIEWER_CTRL_H
  40. #include "dialogcontrol.h"
  41. #include "vector3.h"
  42. #include "render2d.h"
  43. #include "aabox.h"
  44. ////////////////////////////////////////////////////////////////
  45. // Forward declarations
  46. ////////////////////////////////////////////////////////////////
  47. class SimpleSceneClass;
  48. class CameraClass;
  49. class RenderObjClass;
  50. class LightClass;
  51. ////////////////////////////////////////////////////////////////
  52. //
  53. // ViewerCtrlClass
  54. //
  55. ////////////////////////////////////////////////////////////////
  56. class ViewerCtrlClass : public DialogControlClass
  57. {
  58. public:
  59. enum InterfaceModeEnum {
  60. Z_ROTATION, // Automatic rotation of camera around Z-axis.
  61. VIRTUAL_TRACKBALL // Camera rotation with virtual trackball under user control.
  62. };
  63. ////////////////////////////////////////////////////////////////
  64. // Public constructors/destructors
  65. ////////////////////////////////////////////////////////////////
  66. ViewerCtrlClass (void);
  67. virtual ~ViewerCtrlClass (void);
  68. ////////////////////////////////////////////////////////////////
  69. // Public methods
  70. ////////////////////////////////////////////////////////////////
  71. // RTTI.
  72. ViewerCtrlClass *As_ViewerCtrlClass (void) { return this; }
  73. //
  74. // From DialogControlClass
  75. //
  76. void Render (void);
  77. //
  78. // Configuation
  79. //
  80. void Set_Background_Visible (bool isvisible) {IsBackgroundVisible = isvisible;}
  81. void Set_Rotation_Rate (float r) {RotationRate = DEG_TO_RADF (r);}
  82. void Set_Interface_Mode (InterfaceModeEnum mode, float rotationrate = 0.0f);
  83. void Set_Camera_Min_Dist (float dist) { MinCameraDist = dist; }
  84. //
  85. // Selection management
  86. //
  87. SimpleSceneClass *Peek_Scene() { return (Scene); }
  88. CameraClass *Peek_Camera() { return (Camera); }
  89. void Set_Model (const char *model_name);
  90. void Set_Model (RenderObjClass *new_model);
  91. RenderObjClass *Peek_Model() { return (Model); }
  92. void Set_Animation (const char *anim_name);
  93. protected:
  94. ////////////////////////////////////////////////////////////////
  95. // Protected methods
  96. ////////////////////////////////////////////////////////////////
  97. void On_LButton_Down (const Vector2 &mouse_pos);
  98. void On_LButton_Up (const Vector2 &mouse_pos);
  99. void On_Set_Cursor (const Vector2 &mouse_pos);
  100. void On_Frame_Update (void);
  101. void Update_Client_Rect (void);
  102. void Create_Control_Renderer (void);
  103. void Free_Model (void);
  104. void Get_Visible_Bounding_Box (AABoxClass *box, RenderObjClass *render_obj, bool &is_first);
  105. void Calculate_Camera_Position (void);
  106. ////////////////////////////////////////////////////////////////
  107. // Protected member data
  108. ////////////////////////////////////////////////////////////////
  109. SimpleSceneClass * Scene;
  110. CameraClass * Camera;
  111. LightClass * Light; // Light source.
  112. RenderObjClass * Model;
  113. Render2DClass ControlRenderer;
  114. AABoxClass BoundingBox;
  115. float Distance;
  116. float ZRotation;
  117. float RotationRate;
  118. float MinCameraDist;
  119. bool IsCameraDirty;
  120. bool IsBackgroundVisible;
  121. InterfaceModeEnum InterfaceMode;
  122. Vector3 LastMousePosition;
  123. };
  124. #endif //__VIEWER_CTRL_H