CameraSettingsForm.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. // ameraSettingsFormClass.cpp : implementation file
  19. //
  20. #include "StdAfx.h"
  21. #include "leveledit.h"
  22. #include "CameraSettingsForm.H"
  23. #include "Utils.H"
  24. #include "CameraMgr.H"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. //
  32. // CameraSettingsFormClass
  33. //
  34. CameraSettingsFormClass::CameraSettingsFormClass (void)
  35. : DockableFormClass(CameraSettingsFormClass::IDD)
  36. {
  37. //{{AFX_DATA_INIT(CameraSettingsFormClass)
  38. // NOTE: the ClassWizard will add member initialization here
  39. //}}AFX_DATA_INIT
  40. return ;
  41. }
  42. /////////////////////////////////////////////////////////////////////////////
  43. //
  44. // ~CameraSettingsFormClass
  45. //
  46. CameraSettingsFormClass::~CameraSettingsFormClass (void)
  47. {
  48. return ;
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. //
  52. // DoDataExchange
  53. //
  54. void
  55. CameraSettingsFormClass::DoDataExchange (CDataExchange* pDX)
  56. {
  57. DockableFormClass::DoDataExchange(pDX);
  58. //{{AFX_DATA_MAP(CameraSettingsFormClass)
  59. // NOTE: the ClassWizard will add DDX and DDV calls here
  60. //}}AFX_DATA_MAP
  61. return ;
  62. }
  63. BEGIN_MESSAGE_MAP(CameraSettingsFormClass, DockableFormClass)
  64. //{{AFX_MSG_MAP(CameraSettingsFormClass)
  65. ON_NOTIFY(UDN_DELTAPOS, IDC_DEPTH_SPIN, OnDeltaPosDepthSpin)
  66. ON_EN_UPDATE(IDC_DEPTH_EDIT, OnUpdateDepthEdit)
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CameraSettingsFormClass diagnostics
  71. #ifdef _DEBUG
  72. void CameraSettingsFormClass::AssertValid() const
  73. {
  74. DockableFormClass::AssertValid();
  75. }
  76. void CameraSettingsFormClass::Dump(CDumpContext& dc) const
  77. {
  78. DockableFormClass::Dump(dc);
  79. }
  80. #endif //_DEBUG
  81. /////////////////////////////////////////////////////////////////////////////
  82. //
  83. // HandleInitDialog
  84. //
  85. void
  86. CameraSettingsFormClass::HandleInitDialog (void)
  87. {
  88. // Set the depth range
  89. SendDlgItemMessage (IDC_DEPTH_SPIN, UDM_SETRANGE, 0, MAKELPARAM (4000, 20));
  90. // Put the current camera information into the controls
  91. Update_Controls ();
  92. return ;
  93. }
  94. /////////////////////////////////////////////////////////////////////////////
  95. //
  96. // Update_Controls
  97. //
  98. void
  99. CameraSettingsFormClass::Update_Controls (void)
  100. {
  101. CameraMgr *pcamera_mgr = ::Get_Camera_Mgr ();
  102. if (pcamera_mgr != NULL) {
  103. const Matrix3D &transform = pcamera_mgr->Get_Camera ()->Get_Transform ();
  104. CString temp_string;
  105. // Put the x position of the camera into the controls
  106. temp_string.Format ("%.2f", transform.Get_X_Translation ());
  107. SetDlgItemText (IDC_POSX_EDIT, temp_string);
  108. // Put the y position of the camera into the controls
  109. temp_string.Format ("%.2f", transform.Get_Y_Translation ());
  110. SetDlgItemText (IDC_POSY_EDIT, temp_string);
  111. // Put the z position of the camera into the controls
  112. temp_string.Format ("%.2f", transform.Get_Z_Translation ());
  113. SetDlgItemText (IDC_POSZ_EDIT, temp_string);
  114. // Put the x rotation of the camera into the controls
  115. temp_string.Format ("%.2f", (float)RAD_TO_DEG (transform.Get_X_Rotation ()));
  116. SetDlgItemText (IDC_ROTATEX_EDIT, temp_string);
  117. // Put the y rotation of the camera into the controls
  118. temp_string.Format ("%.2f", (float)RAD_TO_DEG (transform.Get_Y_Rotation ()));
  119. SetDlgItemText (IDC_ROTATEY_EDIT, temp_string);
  120. // Put the z rotation of the camera into the controls
  121. temp_string.Format ("%.2f", (float)RAD_TO_DEG (transform.Get_Z_Rotation ()));
  122. SetDlgItemText (IDC_ROTATEZ_EDIT, temp_string);
  123. // Put the current depth of the camera into its dialog control
  124. float near_plane = 0;
  125. float far_plane = 0;
  126. pcamera_mgr->Get_Camera ()->Get_Clip_Planes (near_plane, far_plane);
  127. SetDlgItemInt (IDC_DEPTH_EDIT, (int)far_plane);
  128. SendDlgItemMessage (IDC_DEPTH_SPIN, 0, MAKELPARAM ((short)far_plane, 0));
  129. }
  130. return ;
  131. }
  132. /////////////////////////////////////////////////////////////////////////////
  133. //
  134. // OnDeltaPosDepthSpin
  135. //
  136. void
  137. CameraSettingsFormClass::OnDeltaPosDepthSpin
  138. (
  139. NMHDR* pNMHDR,
  140. LRESULT* pResult
  141. )
  142. {
  143. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  144. if (pNMUpDown) {
  145. Set_Depth (pNMUpDown->iPos);
  146. }
  147. *pResult = 0;
  148. return ;
  149. }
  150. /////////////////////////////////////////////////////////////////////////////
  151. //
  152. // OnUpdateDepthEdit
  153. //
  154. void
  155. CameraSettingsFormClass::OnUpdateDepthEdit (void)
  156. {
  157. Set_Depth (GetDlgItemInt (IDC_DEPTH_EDIT));
  158. return ;
  159. }
  160. /////////////////////////////////////////////////////////////////////////////
  161. //
  162. // Set_Depth
  163. //
  164. void
  165. CameraSettingsFormClass::Set_Depth (int new_depth)
  166. {
  167. CameraMgr *pcamera_mgr = ::Get_Camera_Mgr ();
  168. if (pcamera_mgr != NULL) {
  169. // Get the current 'near' clip plane
  170. double near_plane = 0;
  171. double far_plane = 0;
  172. //pcamera_mgr->Get_Camera ()->Get_Clip_Planes (near_plane, far_plane);
  173. // Set the new 'far' clip plane
  174. //pcamera_mgr->Get_Camera ()->Set_Clip_Planes (near_plane, (double)new_depth);
  175. }
  176. return ;
  177. }
  178. ////////////////////////////////////////////////////////////////////////////
  179. //
  180. // WindowProc
  181. //
  182. LRESULT
  183. CameraSettingsFormClass::WindowProc
  184. (
  185. UINT message,
  186. WPARAM wParam,
  187. LPARAM lParam
  188. )
  189. {
  190. // Is this the message we are expecting?
  191. if ((message == WM_SHOWWINDOW) || (message == WM_ACTIVATE)) {
  192. // Make sure the controls reflect the current state when we are
  193. // shown
  194. if ((BOOL)LOWORD (wParam)) {
  195. Update_Controls ();
  196. }
  197. }
  198. // Allow the base class to process this message
  199. return DockableFormClass::WindowProc(message, wParam, lParam);
  200. }