GraphicView.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. #if !defined(AFX_GRAPHICVIEW_H__2BB39E41_5D3A_11D2_9FC6_00104B791122__INCLUDED_)
  19. #define AFX_GRAPHICVIEW_H__2BB39E41_5D3A_11D2_9FC6_00104B791122__INCLUDED_
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif // _MSC_VER >= 1000
  23. // GraphicView.h : header file
  24. //
  25. /////////////////////////////////////////////////////////////////
  26. //
  27. // Constants
  28. //
  29. #define ROTATION_X 0x01
  30. #define ROTATION_Y 0x02
  31. #define ROTATION_Z 0x04
  32. #define ROTATION_X_BACK 0x08
  33. #define ROTATION_Y_BACK 0x10
  34. #define ROTATION_Z_BACK 0x20
  35. // Forward declarations
  36. class ParticleEmitterClass;
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CGraphicView view
  39. #include "Camera.H"
  40. class CGraphicView : public CView
  41. {
  42. protected:
  43. CGraphicView(); // protected constructor used by dynamic creation
  44. DECLARE_DYNCREATE(CGraphicView)
  45. // Attributes
  46. public:
  47. // Operations
  48. public:
  49. // Overrides
  50. // ClassWizard generated virtual function overrides
  51. //{{AFX_VIRTUAL(CGraphicView)
  52. public:
  53. virtual void OnInitialUpdate();
  54. protected:
  55. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  56. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  57. //}}AFX_VIRTUAL
  58. // Implementation
  59. protected:
  60. virtual ~CGraphicView();
  61. #ifdef _DEBUG
  62. virtual void AssertValid() const;
  63. virtual void Dump(CDumpContext& dc) const;
  64. #endif
  65. // Generated message map functions
  66. protected:
  67. //{{AFX_MSG(CGraphicView)
  68. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  69. afx_msg void OnSize(UINT nType, int cx, int cy);
  70. afx_msg void OnDestroy();
  71. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  72. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  73. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  74. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  75. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  76. afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
  77. //}}AFX_MSG
  78. DECLARE_MESSAGE_MAP()
  79. public:
  80. /////////////////////////////////////////////////
  81. //
  82. // Public Data Types
  83. //
  84. typedef enum
  85. {
  86. AnimInvalid = -1,
  87. AnimPlaying = 0,
  88. AnimStopped = 1,
  89. AnimPaused = 2
  90. } ANIMATION_STATE;
  91. typedef enum
  92. {
  93. CameraFront = -1,
  94. CameraBack = 0,
  95. CameraTop = 1,
  96. CameraBottom = 2,
  97. CameraLeft = 3,
  98. CameraRight = 4
  99. } CAMERA_POS;
  100. typedef enum
  101. {
  102. NoRotation = 0,
  103. RotateX = ROTATION_X,
  104. RotateY = ROTATION_Y,
  105. RotateZ = ROTATION_Z,
  106. RotateXBack = ROTATION_X_BACK,
  107. RotateYBack = ROTATION_Y_BACK,
  108. RotateZBack = ROTATION_Z_BACK
  109. } OBJECT_ROTATION;
  110. typedef enum
  111. {
  112. FreeRotation = 0,
  113. OnlyRotateX = ROTATION_X,
  114. OnlyRotateY = ROTATION_Y,
  115. OnlyRotateZ = ROTATION_Z
  116. } CAMERA_ROTATION;
  117. /////////////////////////////////////////////////
  118. //
  119. // Public Methods
  120. //
  121. BOOL InitializeGraphicView (void);
  122. //
  123. // Initial display methods
  124. //
  125. void Reset_Camera_To_Display_Sphere (SphereClass &sphere);
  126. void Reset_Camera_To_Display_Object (RenderObjClass &physObject);
  127. void Reset_Camera_To_Display_Emitter (ParticleEmitterClass &emitter);
  128. void Load_Default_Dat (void);
  129. void UpdateDisplay (void);
  130. void RepaintView (BOOL bUpdateAnimation = TRUE, DWORD ticks_to_use = 0);
  131. void SetActiveUpdate (BOOL bActive)
  132. { m_bActive = bActive;
  133. if (!m_bActive) { ::SetProp (m_hWnd, "Inactive", (HANDLE)1); }
  134. else { RemoveProp (m_hWnd, "Inactive"); m_dwLastFrameUpdate = ::GetTickCount (); }
  135. }
  136. void Allow_Update (bool onoff);
  137. //
  138. // Animation methods
  139. //
  140. float GetAnimationSpeed (void) const { return m_animationSpeed; }
  141. void SetAnimationSpeed (float animationSpeed) { m_animationSpeed = animationSpeed; }
  142. ANIMATION_STATE GetAnimationState (void) const { return m_animationState; }
  143. void SetAnimationState (ANIMATION_STATE animationState);
  144. //
  145. // Camera Methods
  146. //
  147. void SetAllowedCameraRotation (CAMERA_ROTATION cameraRotation);
  148. CAMERA_ROTATION GetAllowedCameraRotation () const { return m_allowedCameraRotation; }
  149. void SetCameraPos (CAMERA_POS cameraPos);
  150. class CameraClass *GetCamera (void) const { return m_pCamera; }
  151. float Get_Camera_Distance (void) const { return m_CameraDistance; }
  152. void Set_Camera_Distance (float dist);
  153. void Set_Camera_Bone_Pos_X (bool onoff) { m_CameraBonePosX = onoff; }
  154. BOOL Is_Camera_Bone_Pos_X (void) const { return m_CameraBonePosX; }
  155. //
  156. // Object rotation methods
  157. //
  158. void ResetObject (void);
  159. void RotateObject (OBJECT_ROTATION rotation);
  160. OBJECT_ROTATION GetObjectRotation (void) const { return m_objectRotation; }
  161. //
  162. // Light rotation methods
  163. //
  164. void Rotate_Light (OBJECT_ROTATION rotation) { m_LightRotation = rotation; }
  165. OBJECT_ROTATION Get_Light_Rotation (void) const { return m_LightRotation; }
  166. //
  167. // Fullscreen mode
  168. //
  169. BOOL Is_Fullscreen (void) const { return !(BOOL)m_iWindowed; }
  170. void Set_Fullscreen (bool fullscreen) { m_iWindowed = fullscreen ? 0 : 1; InitializeGraphicView (); }
  171. //
  172. // Misc
  173. //
  174. RenderObjClass * Get_Light_Mesh (void) const { return m_pLightMesh; }
  175. Vector3 & Get_Object_Center (void) { return m_ObjectCenter; }
  176. //
  177. // FOV methods
  178. //
  179. void Set_FOV (double hfov, double vfov, bool force = false);
  180. void Reset_FOV (void);
  181. protected:
  182. /////////////////////////////////////////////////
  183. //
  184. // Protected methods
  185. //
  186. void Rotate_Object (void);
  187. void Rotate_Light (void);
  188. private:
  189. /////////////////////////////////////////////////
  190. //
  191. // Private Member Data
  192. //
  193. BOOL m_bInitialized;
  194. BOOL m_bActive;
  195. UINT m_TimerID;
  196. CameraClass * m_pCamera;
  197. RenderObjClass * m_pLightMesh;
  198. bool m_bLightMeshInScene;
  199. Vector3 m_ObjectCenter;
  200. SphereClass m_ViewedSphere;
  201. BOOL m_bMouseDown;
  202. BOOL m_bRMouseDown;
  203. POINT m_lastPoint;
  204. int m_iWindowed;
  205. int m_UpdateCounter;
  206. float m_CameraDistance;
  207. DWORD m_ParticleCountUpdate;
  208. BOOL m_CameraBonePosX;
  209. // Animation data
  210. DWORD m_dwLastFrameUpdate;
  211. float m_animationSpeed;
  212. ANIMATION_STATE m_animationState;
  213. OBJECT_ROTATION m_objectRotation;
  214. OBJECT_ROTATION m_LightRotation;
  215. CAMERA_ROTATION m_allowedCameraRotation;
  216. };
  217. /////////////////////////////////////////////////////////////////////////////
  218. //{{AFX_INSERT_LOCATION}}
  219. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  220. #endif // !defined(AFX_GRAPHICVIEW_H__2BB39E41_5D3A_11D2_9FC6_00104B791122__INCLUDED_)