EmitterPhysicsPropPage.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. // EmitterPhysicsPropPage.cpp : implementation file
  19. //
  20. #include "StdAfx.H"
  21. #include "W3DView.H"
  22. #include "EmitterPhysicsPropPage.H"
  23. #include "Utils.H"
  24. #include "Part_Emt.H"
  25. #include "VolumeRandomDialog.H"
  26. #include "EmitterInstanceList.H"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // EmitterPhysicsPropPageClass property page
  34. IMPLEMENT_DYNCREATE(EmitterPhysicsPropPageClass, CPropertyPage)
  35. /////////////////////////////////////////////////////////////
  36. //
  37. // EmitterPhysicsPropPageClass
  38. //
  39. /////////////////////////////////////////////////////////////
  40. EmitterPhysicsPropPageClass::EmitterPhysicsPropPageClass (EmitterInstanceListClass *pemitter)
  41. : m_pEmitterList (NULL),
  42. m_bValid (true),
  43. m_Velocity (0, 0, 1),
  44. m_Acceleration (0, 0, 0),
  45. m_OutFactor (0),
  46. m_InheritanceFactor (0),
  47. m_Randomizer (NULL),
  48. CPropertyPage(EmitterPhysicsPropPageClass::IDD)
  49. {
  50. //{{AFX_DATA_INIT(EmitterPhysicsPropPageClass)
  51. //}}AFX_DATA_INIT
  52. Initialize ();
  53. return ;
  54. }
  55. /////////////////////////////////////////////////////////////
  56. //
  57. // ~EmitterPhysicsPropPageClass
  58. //
  59. /////////////////////////////////////////////////////////////
  60. EmitterPhysicsPropPageClass::~EmitterPhysicsPropPageClass (void)
  61. {
  62. SAFE_DELETE (m_Randomizer);
  63. return;
  64. }
  65. /////////////////////////////////////////////////////////////
  66. //
  67. // DoDataExchange
  68. //
  69. /////////////////////////////////////////////////////////////
  70. void
  71. EmitterPhysicsPropPageClass::DoDataExchange (CDataExchange* pDX)
  72. {
  73. // Allow the base class to process this message
  74. CPropertyPage::DoDataExchange(pDX);
  75. //{{AFX_DATA_MAP(EmitterPhysicsPropPageClass)
  76. DDX_Control(pDX, IDC_OUT_FACTOR_SPIN, m_OutSpin);
  77. DDX_Control(pDX, IDC_INHERITANCE_FACTOR_SPIN, m_InheritanceSpin);
  78. DDX_Control(pDX, IDC_VELOCITY_Z_SPIN, m_VelocityZSpin);
  79. DDX_Control(pDX, IDC_VELOCITY_Y_SPIN, m_VelocityYSpin);
  80. DDX_Control(pDX, IDC_VELOCITY_X_SPIN, m_VelocityXSpin);
  81. DDX_Control(pDX, IDC_ACCELERATION_Z_SPIN, m_AccelZSpin);
  82. DDX_Control(pDX, IDC_ACCELERATION_Y_SPIN, m_AccelYSpin);
  83. DDX_Control(pDX, IDC_ACCELERATION_X_SPIN, m_AccelXSpin);
  84. //}}AFX_DATA_MAP
  85. return ;
  86. }
  87. BEGIN_MESSAGE_MAP(EmitterPhysicsPropPageClass, CPropertyPage)
  88. //{{AFX_MSG_MAP(EmitterPhysicsPropPageClass)
  89. ON_BN_CLICKED(IDC_SPECIFY_VELOCITY_RANDOM, OnSpecifyVelocityRandom)
  90. //}}AFX_MSG_MAP
  91. END_MESSAGE_MAP()
  92. /////////////////////////////////////////////////////////////
  93. //
  94. // Initialize
  95. //
  96. /////////////////////////////////////////////////////////////
  97. void
  98. EmitterPhysicsPropPageClass::Initialize (void)
  99. {
  100. SAFE_DELETE (m_Randomizer);
  101. if (m_pEmitterList != NULL) {
  102. //
  103. // Get the emitter's settings
  104. //
  105. m_Velocity = m_pEmitterList->Get_Velocity ();
  106. m_Acceleration = m_pEmitterList->Get_Acceleration ();
  107. m_OutFactor = m_pEmitterList->Get_Outward_Vel ();
  108. m_InheritanceFactor = m_pEmitterList->Get_Vel_Inherit ();
  109. m_Randomizer = m_pEmitterList->Get_Velocity_Random ();
  110. }
  111. return ;
  112. }
  113. /////////////////////////////////////////////////////////////
  114. //
  115. // OnInitDialog
  116. //
  117. /////////////////////////////////////////////////////////////
  118. BOOL
  119. EmitterPhysicsPropPageClass::OnInitDialog (void)
  120. {
  121. // Allow the base class to process this message
  122. CPropertyPage::OnInitDialog ();
  123. //
  124. // Setup the velocity controls
  125. //
  126. ::Initialize_Spinner (m_OutSpin, m_OutFactor, -10000, 10000);
  127. ::Initialize_Spinner (m_InheritanceSpin, m_InheritanceFactor, -10000, 10000);
  128. ::Initialize_Spinner (m_VelocityXSpin, m_Velocity.X, -10000, 10000);
  129. ::Initialize_Spinner (m_VelocityYSpin, m_Velocity.Y, -10000, 10000);
  130. ::Initialize_Spinner (m_VelocityZSpin, m_Velocity.Z, -10000, 10000);
  131. //
  132. // Setup the acceleration controls
  133. //
  134. ::Initialize_Spinner (m_AccelXSpin, m_Acceleration.X, -10000, 10000);
  135. ::Initialize_Spinner (m_AccelYSpin, m_Acceleration.Y, -10000, 10000);
  136. ::Initialize_Spinner (m_AccelZSpin, m_Acceleration.Z, -10000, 10000);
  137. return TRUE;
  138. }
  139. /////////////////////////////////////////////////////////////
  140. //
  141. // OnApply
  142. //
  143. /////////////////////////////////////////////////////////////
  144. BOOL
  145. EmitterPhysicsPropPageClass::OnApply (void)
  146. {
  147. //
  148. // Read the velocity settings
  149. //
  150. m_Velocity.X = ::GetDlgItemFloat (m_hWnd, IDC_VELOCITY_X_EDIT);
  151. m_Velocity.Y = ::GetDlgItemFloat (m_hWnd, IDC_VELOCITY_Y_EDIT);
  152. m_Velocity.Z = ::GetDlgItemFloat (m_hWnd, IDC_VELOCITY_Z_EDIT);
  153. m_OutFactor = ::GetDlgItemFloat (m_hWnd, IDC_OUT_FACTOR_SPIN);
  154. m_InheritanceFactor = ::GetDlgItemFloat (m_hWnd, IDC_INHERITANCE_FACTOR_SPIN);
  155. //
  156. // Read the acceleration settings
  157. //
  158. m_Acceleration.X = ::GetDlgItemFloat (m_hWnd, IDC_ACCELERATION_X_EDIT);
  159. m_Acceleration.Y = ::GetDlgItemFloat (m_hWnd, IDC_ACCELERATION_Y_EDIT);
  160. m_Acceleration.Z = ::GetDlgItemFloat (m_hWnd, IDC_ACCELERATION_Z_EDIT);
  161. // Allow the base class to process this message
  162. return CPropertyPage::OnApply ();
  163. }
  164. /////////////////////////////////////////////////////////////
  165. //
  166. // OnNotify
  167. //
  168. /////////////////////////////////////////////////////////////
  169. BOOL
  170. EmitterPhysicsPropPageClass::OnNotify
  171. (
  172. WPARAM wParam,
  173. LPARAM lParam,
  174. LRESULT *pResult
  175. )
  176. {
  177. //
  178. // Update the spinner control if necessary
  179. //
  180. NMHDR *pheader = (NMHDR *)lParam;
  181. if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) {
  182. LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam;
  183. ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta);
  184. On_Setting_Changed (wParam);
  185. }
  186. // Allow the base class to process this message
  187. return CPropertyPage::OnNotify (wParam, lParam, pResult);
  188. }
  189. /////////////////////////////////////////////////////////////
  190. //
  191. // OnSpecifyCreationVolume
  192. //
  193. /////////////////////////////////////////////////////////////
  194. void
  195. EmitterPhysicsPropPageClass::OnSpecifyVelocityRandom (void)
  196. {
  197. VolumeRandomDialogClass dialog (m_Randomizer, this);
  198. if (dialog.DoModal () == IDOK) {
  199. //
  200. // Get the new randomizer from the dialog
  201. //
  202. SAFE_DELETE (m_Randomizer);
  203. m_Randomizer = dialog.Get_Randomizer ();
  204. if (m_Randomizer != NULL) {
  205. m_pEmitterList->Set_Velocity_Random (m_Randomizer->Clone ());
  206. SetModified ();
  207. }
  208. }
  209. return ;
  210. }
  211. /////////////////////////////////////////////////////////////
  212. //
  213. // OnCommand
  214. //
  215. /////////////////////////////////////////////////////////////
  216. BOOL
  217. EmitterPhysicsPropPageClass::OnCommand
  218. (
  219. WPARAM wParam,
  220. LPARAM lParam
  221. )
  222. {
  223. switch (LOWORD (wParam))
  224. {
  225. case IDC_VELOCITY_X_EDIT:
  226. case IDC_VELOCITY_Y_EDIT:
  227. case IDC_VELOCITY_Z_EDIT:
  228. {
  229. // Update the emitter
  230. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  231. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  232. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  233. On_Setting_Changed (LOWORD (wParam));
  234. } else if (HIWORD (wParam) == EN_CHANGE) {
  235. SetModified ();
  236. }
  237. }
  238. break;
  239. case IDC_ACCELERATION_X_EDIT:
  240. case IDC_ACCELERATION_Y_EDIT:
  241. case IDC_ACCELERATION_Z_EDIT:
  242. {
  243. // Update the emitter
  244. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  245. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  246. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  247. On_Setting_Changed (LOWORD (wParam));
  248. } else if (HIWORD (wParam) == EN_CHANGE) {
  249. SetModified ();
  250. }
  251. }
  252. break;
  253. case IDC_INHERITANCE_FACTOR_EDIT:
  254. {
  255. // Update the emitter
  256. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  257. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  258. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  259. On_Setting_Changed (LOWORD (wParam));
  260. } else if (HIWORD (wParam) == EN_CHANGE) {
  261. SetModified ();
  262. }
  263. }
  264. break;
  265. case IDC_OUT_FACTOR_EDIT:
  266. {
  267. // Update the emitter
  268. if ((HIWORD (wParam) == EN_KILLFOCUS) &&
  269. SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY)) {
  270. SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
  271. On_Setting_Changed (LOWORD (wParam));
  272. } else if (HIWORD (wParam) == EN_CHANGE) {
  273. SetModified ();
  274. }
  275. }
  276. break;
  277. }
  278. return CPropertyPage::OnCommand (wParam, lParam);
  279. }
  280. /////////////////////////////////////////////////////////////
  281. //
  282. // On_Setting_Changed
  283. //
  284. /////////////////////////////////////////////////////////////
  285. void
  286. EmitterPhysicsPropPageClass::On_Setting_Changed (UINT ctrl_id)
  287. {
  288. switch (ctrl_id)
  289. {
  290. case IDC_VELOCITY_X_EDIT:
  291. case IDC_VELOCITY_Y_EDIT:
  292. case IDC_VELOCITY_Z_EDIT:
  293. case IDC_VELOCITY_X_SPIN:
  294. case IDC_VELOCITY_Y_SPIN:
  295. case IDC_VELOCITY_Z_SPIN:
  296. {
  297. Vector3 velocity;
  298. velocity.X = ::GetDlgItemFloat (m_hWnd, IDC_VELOCITY_X_EDIT);
  299. velocity.Y = ::GetDlgItemFloat (m_hWnd, IDC_VELOCITY_Y_EDIT);
  300. velocity.Z = ::GetDlgItemFloat (m_hWnd, IDC_VELOCITY_Z_EDIT);
  301. m_pEmitterList->Set_Velocity (velocity);
  302. SetModified ();
  303. }
  304. break;
  305. case IDC_ACCELERATION_X_EDIT:
  306. case IDC_ACCELERATION_Y_EDIT:
  307. case IDC_ACCELERATION_Z_EDIT:
  308. case IDC_ACCELERATION_X_SPIN:
  309. case IDC_ACCELERATION_Y_SPIN:
  310. case IDC_ACCELERATION_Z_SPIN:
  311. {
  312. Vector3 acceleration;
  313. acceleration.X = ::GetDlgItemFloat (m_hWnd, IDC_ACCELERATION_X_EDIT);
  314. acceleration.Y = ::GetDlgItemFloat (m_hWnd, IDC_ACCELERATION_Y_EDIT);
  315. acceleration.Z = ::GetDlgItemFloat (m_hWnd, IDC_ACCELERATION_Z_EDIT);
  316. m_pEmitterList->Set_Acceleration (acceleration);
  317. SetModified ();
  318. }
  319. break;
  320. case IDC_INHERITANCE_FACTOR_EDIT:
  321. case IDC_INHERITANCE_FACTOR_SPIN:
  322. {
  323. float value = ::GetDlgItemFloat (m_hWnd, IDC_INHERITANCE_FACTOR_EDIT);
  324. m_pEmitterList->Set_Vel_Inherit (value);
  325. SetModified ();
  326. }
  327. break;
  328. case IDC_OUT_FACTOR_EDIT:
  329. case IDC_OUT_FACTOR_SPIN:
  330. {
  331. float value = ::GetDlgItemFloat (m_hWnd, IDC_OUT_FACTOR_EDIT);
  332. m_pEmitterList->Set_Outward_Vel (value);
  333. SetModified ();
  334. }
  335. break;
  336. }
  337. return ;
  338. }