ParticleEditorDialog.cpp 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. #include "StdAfx.h"
  19. #include "Resource.h"
  20. #include "ParticleEditorDialog.h"
  21. #include "CParticleEditorPage.h"
  22. #include "EmissionTypePanels.h"
  23. #include "GameClient/ParticleSys.h"
  24. #include "ParticleEditorExport.h"
  25. #include "ParticleTypePanels.h"
  26. #include "VelocityTypePanels.h"
  27. #define ARBITRARY_BUFF_SIZE 128
  28. DebugWindowDialog::DebugWindowDialog(UINT nIDTemplate, CWnd* pParentWnd) : CDialog(nIDTemplate, pParentWnd),
  29. m_colorAlphaDialog(CColorAlphaDialog::IDD, this),
  30. m_switchesDialog(CSwitchesDialog::IDD, this),
  31. m_moreParmsDialog(MoreParmsDialog::IDD, this)
  32. {
  33. mMainWndHWND = ::FindWindow(NULL, "Command & Conquer: Generals");
  34. m_activeEmissionPage = 0;
  35. m_activeVelocityPage = 0;
  36. m_activeParticlePage = 0;
  37. m_particleSystem = NULL;
  38. m_changeHasOcurred = false;
  39. m_shouldWriteINI = false;
  40. m_showColorDlg = false;
  41. m_showSwitchesDlg = false;
  42. m_showMoreParmsDlg = false;
  43. m_shouldBusyWait = false;
  44. m_shouldReload = false;
  45. m_shouldUpdateParticleCap = false;
  46. m_shouldReloadTextures = false;
  47. m_shouldKillAllParticleSystems = false;
  48. m_emissionTypePanels[0] = new EmissionPanelPoint;
  49. m_emissionTypePanels[1] = new EmissionPanelLine;
  50. m_emissionTypePanels[2] = new EmissionPanelBox;
  51. m_emissionTypePanels[3] = new EmissionPanelSphere;
  52. m_emissionTypePanels[4] = new EmissionPanelCylinder;
  53. m_velocityTypePanels[0] = new VelocityPanelOrtho;
  54. m_velocityTypePanels[1] = new VelocityPanelSphere;
  55. m_velocityTypePanels[2] = new VelocityPanelHemisphere;
  56. m_velocityTypePanels[3] = new VelocityPanelCylinder;
  57. m_velocityTypePanels[4] = new VelocityPanelOutward;
  58. m_particleTypePanels[0] = new ParticlePanelParticle;
  59. m_particleTypePanels[1] = new ParticlePanelDrawable;
  60. m_particleTypePanels[2] = new ParticlePanelStreak;
  61. m_particleParmValues.resize(PARM_NumParms);
  62. }
  63. DebugWindowDialog::~DebugWindowDialog()
  64. {
  65. int i;
  66. for (i = 0; i < NUM_EMISSION_TYPES; ++i) {
  67. delete m_emissionTypePanels[i];
  68. }
  69. for (i = 0; i < NUM_VELOCITY_TYPES; ++i) {
  70. delete m_velocityTypePanels[i];
  71. }
  72. for (i = 0; i < NUM_PARTICLE_TYPES; ++i) {
  73. delete m_particleTypePanels[i];
  74. }
  75. }
  76. int DebugWindowDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
  77. {
  78. return CDialog::OnCreate(lpCreateStruct);
  79. }
  80. void DebugWindowDialog::InitPanel( void )
  81. {
  82. CComboBox* pCombo;
  83. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_Priority);
  84. if (pCombo) {
  85. for (int i = 1; ParticlePriorityNames[i]; ++i) {
  86. pCombo->AddString(ParticlePriorityNames[i]);
  87. }
  88. pCombo->SetCurSel(0);
  89. }
  90. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_EmissionType);
  91. if (pCombo) {
  92. for (int i = 1; EmissionVolumeTypeNames[i]; ++i) {
  93. pCombo->AddString(EmissionVolumeTypeNames[i]);
  94. }
  95. pCombo->SetCurSel(0);
  96. }
  97. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_VelocityType);
  98. if (pCombo) {
  99. for (int i = 1; EmissionVelocityTypeNames[i]; ++i) {
  100. pCombo->AddString(EmissionVelocityTypeNames[i]);
  101. }
  102. pCombo->SetCurSel(0);
  103. }
  104. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_ParticleType);
  105. if (pCombo) {
  106. for (int i = 1; ParticleTypeNames[i]; ++i) {
  107. pCombo->AddString(ParticleTypeNames[i]);
  108. }
  109. pCombo->SetCurSel(0);
  110. }
  111. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_ShaderType);
  112. if (pCombo) {
  113. for (int i = 1; ParticleShaderTypeNames[i]; ++i) {
  114. pCombo->AddString(ParticleShaderTypeNames[i]);
  115. }
  116. pCombo->SetCurSel(0);
  117. }
  118. m_colorAlphaDialog.Create(CColorAlphaDialog::IDD, this);
  119. m_colorAlphaDialog.InitPanel();
  120. m_switchesDialog.Create(CSwitchesDialog::IDD, this);
  121. m_switchesDialog.InitPanel();
  122. m_moreParmsDialog.Create(MoreParmsDialog::IDD, this);
  123. m_moreParmsDialog.InitPanel();
  124. CWnd *pWnd;
  125. int j;
  126. pWnd = GetDlgItem(IDC_PSEd_EmissionPanel);
  127. if (pWnd) {
  128. CRect rect;
  129. pWnd->GetWindowRect(&rect);
  130. ScreenToClient(&rect);
  131. for (j = 0; j < NUM_EMISSION_TYPES; ++j) {
  132. m_emissionTypePanels[j]->Create(m_emissionTypePanels[j]->GetIDD(), this);
  133. m_emissionTypePanels[j]->InitPanel();
  134. m_emissionTypePanels[j]->ShowWindow(SW_HIDE);
  135. m_emissionTypePanels[j]->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
  136. }
  137. pWnd->ShowWindow(SW_HIDE);
  138. m_emissionTypePanels[0]->ShowWindow(SW_SHOW);
  139. }
  140. pWnd = GetDlgItem(IDC_PSEd_VelocityPanel);
  141. if (pWnd) {
  142. CRect rect;
  143. pWnd->GetWindowRect(&rect);
  144. ScreenToClient(&rect);
  145. for (j = 0; j < NUM_VELOCITY_TYPES; ++j) {
  146. m_velocityTypePanels[j]->Create(m_velocityTypePanels[j]->GetIDD(), this);
  147. m_velocityTypePanels[j]->InitPanel();
  148. m_velocityTypePanels[j]->ShowWindow(SW_HIDE);
  149. m_velocityTypePanels[j]->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
  150. }
  151. pWnd->ShowWindow(SW_HIDE);
  152. m_velocityTypePanels[0]->ShowWindow(SW_SHOW);
  153. }
  154. pWnd = GetDlgItem(IDC_PSEd_ParticlePanel);
  155. if (pWnd) {
  156. CRect rect;
  157. pWnd->GetWindowRect(&rect);
  158. ScreenToClient(&rect);
  159. for (j = 0; j < NUM_PARTICLE_TYPES; ++j) {
  160. m_particleTypePanels[j]->Create(m_particleTypePanels[j]->GetIDD(), this);
  161. m_particleTypePanels[j]->InitPanel();
  162. m_particleTypePanels[j]->ShowWindow(SW_HIDE);
  163. m_particleTypePanels[j]->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
  164. }
  165. pWnd->ShowWindow(SW_HIDE);
  166. m_particleTypePanels[0]->ShowWindow(SW_SHOW);
  167. }
  168. }
  169. HWND DebugWindowDialog::GetMainWndHWND(void)
  170. {
  171. return mMainWndHWND;
  172. }
  173. void DebugWindowDialog::addParticleSystem(const char *particleSystem)
  174. {
  175. if (!particleSystem) {
  176. return;
  177. }
  178. std::string particleSystemName = particleSystem;
  179. appendParticleSystemToList(particleSystemName);
  180. }
  181. void DebugWindowDialog::addThingTemplate(const char *thingTemplate)
  182. {
  183. if (!thingTemplate) {
  184. return;
  185. }
  186. std::string thingTemplateName = thingTemplate;
  187. appendThingTemplateToList(thingTemplateName);
  188. }
  189. void DebugWindowDialog::OnClose()
  190. {
  191. ShowWindow(SW_MINIMIZE);
  192. }
  193. void DebugWindowDialog::OnSize(UINT nType, int cx, int cy)
  194. {
  195. CDialog::OnSize(nType, cx, cy);
  196. if (nType == SIZE_MINIMIZED) {
  197. if (mMainWndHWND) {
  198. ::SetFocus(mMainWndHWND);
  199. }
  200. }
  201. }
  202. void DebugWindowDialog::clearAllParticleSystems(void)
  203. {
  204. CComboBox* combo = (CComboBox*) GetDlgItem(IDC_PSEd_ParticleSystem);
  205. if (!combo) {
  206. return;
  207. }
  208. m_listOfParticleSystems.clear();
  209. combo->ResetContent();
  210. }
  211. void DebugWindowDialog::clearAllThingTemplates( void )
  212. {
  213. m_listOfThingTemplates.clear();
  214. // this is a kindof(dirty_hack), because there's no way at runtime to verify that
  215. // particleTypePanels[1] is actually a PArticlePanelDrawable
  216. ((ParticlePanelDrawable*)m_particleTypePanels[1])->clearAllThingTemplates();
  217. }
  218. void DebugWindowDialog::appendParticleSystemToList( const std::string &rString )
  219. {
  220. CComboBox* combo = (CComboBox*) GetDlgItem(IDC_PSEd_ParticleSystem);
  221. if (!combo) {
  222. return;
  223. }
  224. m_listOfParticleSystems.push_front(rString);
  225. combo->AddString(rString.c_str());
  226. }
  227. void DebugWindowDialog::appendThingTemplateToList( IN const std::string &rString )
  228. {
  229. m_listOfThingTemplates.push_back(rString);
  230. }
  231. void DebugWindowDialog::OnParticleSystemChange()
  232. {
  233. m_changeHasOcurred = true;
  234. }
  235. void DebugWindowDialog::OnPushSave()
  236. {
  237. m_shouldWriteINI = true;
  238. }
  239. void DebugWindowDialog::OnReloadTextures()
  240. {
  241. // First, reload the textures
  242. ParticlePanelParticle* pParticle = (ParticlePanelParticle*) m_particleTypePanels[0];
  243. if (!pParticle) {
  244. return;
  245. }
  246. pParticle->InitPanel();
  247. // Then, force an update to the ui, to repick the appropriate texture.
  248. performUpdate(true);
  249. // Finally, signal a flag to the asset manager to reload the actual textures.
  250. m_shouldReloadTextures = true;
  251. }
  252. Bool DebugWindowDialog::hasSelectionChanged(void)
  253. {
  254. if (m_changeHasOcurred) {
  255. m_changeHasOcurred = false;
  256. return true;
  257. }
  258. return false;
  259. }
  260. void DebugWindowDialog::getSelectedSystemName(char *bufferToCopyInto) const
  261. {
  262. if (!bufferToCopyInto) {
  263. return;
  264. }
  265. CComboBox* combo = (CComboBox*) GetDlgItem(IDC_PSEd_ParticleSystem);
  266. if (!combo) {
  267. bufferToCopyInto[0] = '\0';
  268. return;
  269. }
  270. int ndx = combo->GetCurSel();
  271. CString string;
  272. if (ndx > -1) {
  273. combo->GetLBText(ndx, string);
  274. strcpy(bufferToCopyInto, string.GetBuffer(0));
  275. } else {
  276. combo->GetWindowText(string);
  277. strcpy(bufferToCopyInto, string.GetBuffer(0));
  278. }
  279. }
  280. void DebugWindowDialog::getSelectedParticleAsciiStringParm( IN int parmNum, OUT char *bufferToCopyInto ) const
  281. {
  282. if (parmNum < 0 || parmNum >= PARM_NumParms || !bufferToCopyInto || !m_particleSystem) {
  283. return;
  284. }
  285. if (m_particleParmValues[parmNum].length()) {
  286. strcpy(bufferToCopyInto, m_particleParmValues[parmNum].c_str());
  287. } else {
  288. bufferToCopyInto[0] = 0;
  289. }
  290. }
  291. void DebugWindowDialog::updateParticleAsciiStringParm( IN int parmNum, OUT const char *bufferToCopyFrom )
  292. {
  293. if (parmNum < 0 || parmNum >= PARM_NumParms || !bufferToCopyFrom) {
  294. return;
  295. }
  296. m_particleParmValues[parmNum] = bufferToCopyFrom;
  297. }
  298. void DebugWindowDialog::getColorValueFromSystem(IN Int systemNum, OUT RGBColorKeyframe &colorFrame) const
  299. {
  300. if (systemNum >= MAX_KEYFRAMES || systemNum < 0 || !m_particleSystem) {
  301. return;
  302. }
  303. colorFrame = m_particleSystem->m_colorKey[systemNum];
  304. }
  305. void DebugWindowDialog::updateColorValueToSystem(IN Int systemNum, IN const RGBColorKeyframe &colorFrame)
  306. {
  307. if (systemNum >= MAX_KEYFRAMES || systemNum < 0 || !m_particleSystem) {
  308. return;
  309. }
  310. m_particleSystem->m_colorKey[systemNum] = colorFrame;
  311. }
  312. void DebugWindowDialog::getAlphaRangeFromSystem(IN Int systemNum, OUT ParticleSystemInfo::RandomKeyframe &randomVar) const
  313. {
  314. if (systemNum >= MAX_KEYFRAMES || systemNum < 0 || !m_particleSystem) {
  315. return;
  316. }
  317. randomVar = m_particleSystem->m_alphaKey[systemNum];
  318. }
  319. void DebugWindowDialog::updateAlphaRangeToSystem(IN Int systemNum, IN const ParticleSystemInfo::RandomKeyframe &randomVar)
  320. {
  321. if (systemNum >= MAX_KEYFRAMES || systemNum < 0 || !m_particleSystem) {
  322. return;
  323. }
  324. m_particleSystem->m_alphaKey[systemNum] = randomVar;
  325. }
  326. void DebugWindowDialog::getHalfSizeFromSystem( IN Int coordNum, OUT Real& halfSize) const
  327. {
  328. if (!m_particleSystem) {
  329. return;
  330. }
  331. switch (coordNum)
  332. {
  333. case 0: halfSize = m_particleSystem->m_emissionVolume.box.halfSize.x; return;
  334. case 1: halfSize = m_particleSystem->m_emissionVolume.box.halfSize.y; return;
  335. case 2: halfSize = m_particleSystem->m_emissionVolume.box.halfSize.z; return;
  336. default: return;
  337. };
  338. }
  339. void DebugWindowDialog::updateHalfSizeToSystem( IN Int coordNum, IN const Real& halfSize)
  340. {
  341. if (!m_particleSystem) {
  342. return;
  343. }
  344. switch (coordNum)
  345. {
  346. case 0: m_particleSystem->m_emissionVolume.box.halfSize.x = halfSize; return;
  347. case 1: m_particleSystem->m_emissionVolume.box.halfSize.y = halfSize; return;
  348. case 2: m_particleSystem->m_emissionVolume.box.halfSize.z = halfSize; return;
  349. default: return;
  350. };
  351. }
  352. void DebugWindowDialog::getSphereRadiusFromSystem( OUT Real &radius ) const
  353. {
  354. if (!m_particleSystem) {
  355. return;
  356. }
  357. radius = m_particleSystem->m_emissionVolume.sphere.radius;
  358. }
  359. void DebugWindowDialog::updateSphereRadiusToSystem( IN const Real &radius )
  360. {
  361. if (!m_particleSystem) {
  362. return;
  363. }
  364. m_particleSystem->m_emissionVolume.sphere.radius = radius;
  365. }
  366. void DebugWindowDialog::getCylinderRadiusFromSystem( OUT Real &radius ) const
  367. {
  368. if (!m_particleSystem) {
  369. return;
  370. }
  371. radius = m_particleSystem->m_emissionVolume.cylinder.radius;
  372. }
  373. void DebugWindowDialog::updateCylinderRadiusToSystem( IN const Real &radius )
  374. {
  375. if (!m_particleSystem) {
  376. return;
  377. }
  378. m_particleSystem->m_emissionVolume.cylinder.radius = radius;
  379. }
  380. void DebugWindowDialog::getCylinderLengthFromSystem( OUT Real &length ) const
  381. {
  382. if (!m_particleSystem) {
  383. return;
  384. }
  385. length = m_particleSystem->m_emissionVolume.cylinder.length;
  386. }
  387. void DebugWindowDialog::updateCylinderLengthToSystem( IN const Real &length )
  388. {
  389. if (!m_particleSystem) {
  390. return;
  391. }
  392. m_particleSystem->m_emissionVolume.cylinder.length = length;
  393. }
  394. void DebugWindowDialog::getLineFromSystem( IN Int coordNum, OUT Real& linePoint) const
  395. {
  396. if (!m_particleSystem) {
  397. return;
  398. }
  399. switch (coordNum)
  400. {
  401. case 0: linePoint = m_particleSystem->m_emissionVolume.line.start.x; return;
  402. case 1: linePoint = m_particleSystem->m_emissionVolume.line.start.y; return;
  403. case 2: linePoint = m_particleSystem->m_emissionVolume.line.start.z; return;
  404. case 3: linePoint = m_particleSystem->m_emissionVolume.line.end.x; return;
  405. case 4: linePoint = m_particleSystem->m_emissionVolume.line.end.y; return;
  406. case 5: linePoint = m_particleSystem->m_emissionVolume.line.end.z; return;
  407. default: return;
  408. };
  409. }
  410. void DebugWindowDialog::updateLineToSystem( IN Int coordNum, IN const Real& linePoint)
  411. {
  412. if (!m_particleSystem) {
  413. return;
  414. }
  415. switch (coordNum)
  416. {
  417. case 0: m_particleSystem->m_emissionVolume.line.start.x = linePoint; return;
  418. case 1: m_particleSystem->m_emissionVolume.line.start.y = linePoint; return;
  419. case 2: m_particleSystem->m_emissionVolume.line.start.z = linePoint; return;
  420. case 3: m_particleSystem->m_emissionVolume.line.end.x = linePoint; return;
  421. case 4: m_particleSystem->m_emissionVolume.line.end.y = linePoint; return;
  422. case 5: m_particleSystem->m_emissionVolume.line.end.z = linePoint; return;
  423. default: return;
  424. };
  425. }
  426. void DebugWindowDialog::getVelSphereFromSystem( IN Int velNum, OUT Real &radius) const
  427. {
  428. if (!m_particleSystem) {
  429. return;
  430. }
  431. switch (velNum)
  432. {
  433. case 0: radius = m_particleSystem->m_emissionVelocity.spherical.speed.m_low; return;
  434. case 1: radius = m_particleSystem->m_emissionVelocity.spherical.speed.m_high; return;
  435. default: return;
  436. };
  437. }
  438. void DebugWindowDialog::updateVelSphereToSystem( IN Int velNum, IN const Real &radius)
  439. {
  440. if (!m_particleSystem) {
  441. return;
  442. }
  443. switch (velNum)
  444. {
  445. case 0: m_particleSystem->m_emissionVelocity.spherical.speed.m_low = radius; return;
  446. case 1: m_particleSystem->m_emissionVelocity.spherical.speed.m_high = radius; return;
  447. default: return;
  448. };
  449. }
  450. void DebugWindowDialog::getVelHemisphereFromSystem( IN Int velNum, OUT Real &radius) const
  451. {
  452. if (!m_particleSystem) {
  453. return;
  454. }
  455. switch (velNum)
  456. {
  457. case 0: radius = m_particleSystem->m_emissionVelocity.hemispherical.speed.m_low; return;
  458. case 1: radius = m_particleSystem->m_emissionVelocity.hemispherical.speed.m_high; return;
  459. default: return;
  460. };
  461. }
  462. void DebugWindowDialog::updateVelHemisphereToSystem( IN Int velNum, IN const Real &radius)
  463. {
  464. if (!m_particleSystem) {
  465. return;
  466. }
  467. switch (velNum)
  468. {
  469. case 0: m_particleSystem->m_emissionVelocity.hemispherical.speed.m_low = radius; return;
  470. case 1: m_particleSystem->m_emissionVelocity.hemispherical.speed.m_high = radius; return;
  471. default: return;
  472. };
  473. }
  474. void DebugWindowDialog::getVelOrthoFromSystem( IN Int coordNum, OUT Real& ortho) const
  475. {
  476. if (!m_particleSystem) {
  477. return;
  478. }
  479. switch (coordNum)
  480. {
  481. case 0: ortho = m_particleSystem->m_emissionVelocity.ortho.x.m_low; return;
  482. case 1: ortho = m_particleSystem->m_emissionVelocity.ortho.y.m_low; return;
  483. case 2: ortho = m_particleSystem->m_emissionVelocity.ortho.z.m_low; return;
  484. case 3: ortho = m_particleSystem->m_emissionVelocity.ortho.x.m_high; return;
  485. case 4: ortho = m_particleSystem->m_emissionVelocity.ortho.y.m_high; return;
  486. case 5: ortho = m_particleSystem->m_emissionVelocity.ortho.z.m_high; return;
  487. default: return;
  488. };
  489. }
  490. void DebugWindowDialog::updateVelOrthoToSystem( IN Int coordNum, IN const Real& ortho)
  491. {
  492. if (!m_particleSystem) {
  493. return;
  494. }
  495. switch (coordNum)
  496. {
  497. case 0: m_particleSystem->m_emissionVelocity.ortho.x.m_low = ortho; return;
  498. case 1: m_particleSystem->m_emissionVelocity.ortho.y.m_low = ortho; return;
  499. case 2: m_particleSystem->m_emissionVelocity.ortho.z.m_low = ortho; return;
  500. case 3: m_particleSystem->m_emissionVelocity.ortho.x.m_high = ortho; return;
  501. case 4: m_particleSystem->m_emissionVelocity.ortho.y.m_high = ortho; return;
  502. case 5: m_particleSystem->m_emissionVelocity.ortho.z.m_high = ortho; return;
  503. default: return;
  504. };
  505. }
  506. void DebugWindowDialog::getVelCylinderFromSystem( IN Int coordNum, OUT Real& cylinder) const
  507. {
  508. if (!m_particleSystem) {
  509. return;
  510. }
  511. switch (coordNum)
  512. {
  513. case 0: cylinder = m_particleSystem->m_emissionVelocity.cylindrical.radial.m_low; return;
  514. case 1: cylinder = m_particleSystem->m_emissionVelocity.cylindrical.normal.m_low; return;
  515. case 2: cylinder = m_particleSystem->m_emissionVelocity.cylindrical.radial.m_high; return;
  516. case 3: cylinder = m_particleSystem->m_emissionVelocity.cylindrical.normal.m_high; return;
  517. default: return;
  518. };
  519. }
  520. void DebugWindowDialog::updateVelCylinderToSystem( IN Int coordNum, IN const Real& cylinder)
  521. {
  522. if (!m_particleSystem) {
  523. return;
  524. }
  525. switch (coordNum)
  526. {
  527. case 0: m_particleSystem->m_emissionVelocity.cylindrical.radial.m_low = cylinder; return;
  528. case 1: m_particleSystem->m_emissionVelocity.cylindrical.normal.m_low = cylinder; return;
  529. case 2: m_particleSystem->m_emissionVelocity.cylindrical.radial.m_high = cylinder; return;
  530. case 3: m_particleSystem->m_emissionVelocity.cylindrical.normal.m_high = cylinder; return;
  531. default: return;
  532. };
  533. }
  534. void DebugWindowDialog::getVelOutwardFromSystem( IN Int coordNum, OUT Real& cylinder) const
  535. {
  536. if (!m_particleSystem) {
  537. return;
  538. }
  539. switch (coordNum)
  540. {
  541. case 0: cylinder = m_particleSystem->m_emissionVelocity.outward.speed.m_low; return;
  542. case 1: cylinder = m_particleSystem->m_emissionVelocity.outward.otherSpeed.m_low; return;
  543. case 2: cylinder = m_particleSystem->m_emissionVelocity.outward.speed.m_high; return;
  544. case 3: cylinder = m_particleSystem->m_emissionVelocity.outward.otherSpeed.m_high; return;
  545. default: return;
  546. };
  547. }
  548. void DebugWindowDialog::updateVelOutwardToSystem( IN Int coordNum, IN const Real& cylinder)
  549. {
  550. if (!m_particleSystem) {
  551. return;
  552. }
  553. switch (coordNum)
  554. {
  555. case 0: m_particleSystem->m_emissionVelocity.outward.speed.m_low = cylinder; return;
  556. case 1: m_particleSystem->m_emissionVelocity.outward.otherSpeed.m_low = cylinder; return;
  557. case 2: m_particleSystem->m_emissionVelocity.outward.speed.m_high = cylinder; return;
  558. case 3: m_particleSystem->m_emissionVelocity.outward.otherSpeed.m_high = cylinder; return;
  559. default: return;
  560. };
  561. }
  562. void DebugWindowDialog::getParticleNameFromSystem( OUT char *buffer, IN int buffLen ) const
  563. {
  564. if (!m_particleSystem) {
  565. return;
  566. }
  567. if (!buffer) {
  568. return;
  569. }
  570. getSelectedParticleAsciiStringParm( PARM_ParticleTypeName, buffer);
  571. }
  572. void DebugWindowDialog::updateParticleNameToSystem( IN const char *buffer )
  573. {
  574. if (!m_particleSystem) {
  575. return;
  576. }
  577. if (!buffer) {
  578. return;
  579. }
  580. updateParticleAsciiStringParm( PARM_ParticleTypeName, buffer);
  581. }
  582. void DebugWindowDialog::getDrawableNameFromSystem( OUT char *buffer, IN int buffLen ) const
  583. {
  584. getParticleNameFromSystem(buffer, buffLen);
  585. }
  586. void DebugWindowDialog::updateDrawableNameToSystem( IN const char* buffer )
  587. {
  588. updateParticleNameToSystem(buffer);
  589. }
  590. void DebugWindowDialog::updateCurrentParticleSystem(ParticleSystemTemplate *particleTemplate )
  591. {
  592. m_particleSystem = particleTemplate;
  593. performUpdate(true);
  594. }
  595. void DebugWindowDialog::updateSystemUseParameters(IN ParticleSystemTemplate *particleTemplate )
  596. {
  597. m_particleSystem = particleTemplate;
  598. performUpdate(false);
  599. }
  600. void DebugWindowDialog::getInitialDelayFromSystem( IN Int parmNum, OUT Real& initialDelay ) const
  601. {
  602. if (!m_particleSystem) {
  603. return;
  604. }
  605. switch (parmNum)
  606. {
  607. case 0: initialDelay = m_particleSystem->m_initialDelay.m_low; return;
  608. case 1: initialDelay = m_particleSystem->m_initialDelay.m_high; return;
  609. default: return;
  610. };
  611. }
  612. void DebugWindowDialog::updateInitialDelayToSystem( IN Int parmNum, IN const Real& initialDelay )
  613. {
  614. if (!m_particleSystem) {
  615. return;
  616. }
  617. switch (parmNum)
  618. {
  619. case 0: m_particleSystem->m_initialDelay.m_low = initialDelay; return;
  620. case 1: m_particleSystem->m_initialDelay.m_high = initialDelay; return;
  621. default: return;
  622. };
  623. }
  624. void DebugWindowDialog::getBurstDelayFromSystem( IN Int parmNum, OUT Real& burstDelay ) const
  625. {
  626. if (!m_particleSystem) {
  627. return;
  628. }
  629. switch (parmNum)
  630. {
  631. case 0: burstDelay = m_particleSystem->m_burstDelay.m_low; return;
  632. case 1: burstDelay = m_particleSystem->m_burstDelay.m_high; return;
  633. default: return;
  634. };
  635. }
  636. void DebugWindowDialog::updateBurstDelayToSystem( IN Int parmNum, IN const Real& burstDelay )
  637. {
  638. if (!m_particleSystem) {
  639. return;
  640. }
  641. switch (parmNum)
  642. {
  643. case 0: m_particleSystem->m_burstDelay.m_low = burstDelay; return;
  644. case 1: m_particleSystem->m_burstDelay.m_high = burstDelay; return;
  645. default: return;
  646. };
  647. }
  648. void DebugWindowDialog::getBurstCountFromSystem( IN Int parmNum, OUT Real& burstCount ) const
  649. {
  650. if (!m_particleSystem) {
  651. return;
  652. }
  653. switch (parmNum)
  654. {
  655. case 0: burstCount = m_particleSystem->m_burstCount.m_low; return;
  656. case 1: burstCount = m_particleSystem->m_burstCount.m_high; return;
  657. default: return;
  658. };
  659. }
  660. void DebugWindowDialog::updateBurstCountToSystem( IN Int parmNum, IN const Real& burstCount )
  661. {
  662. if (!m_particleSystem) {
  663. return;
  664. }
  665. switch (parmNum)
  666. {
  667. case 0: m_particleSystem->m_burstCount.m_low = burstCount; return;
  668. case 1: m_particleSystem->m_burstCount.m_high = burstCount; return;
  669. default: return;
  670. };
  671. }
  672. void DebugWindowDialog::getColorScaleFromSystem( IN Int parmNum, OUT Real& colorScale ) const
  673. {
  674. if (!m_particleSystem) {
  675. return;
  676. }
  677. switch (parmNum)
  678. {
  679. case 0: colorScale = m_particleSystem->m_colorScale.m_low; return;
  680. case 1: colorScale = m_particleSystem->m_colorScale.m_high; return;
  681. default: return;
  682. };
  683. }
  684. void DebugWindowDialog::updateColorScaleToSystem( IN Int parmNum, IN const Real& colorScale )
  685. {
  686. if (!m_particleSystem) {
  687. return;
  688. }
  689. switch (parmNum)
  690. {
  691. case 0: m_particleSystem->m_colorScale.m_low = colorScale; return;
  692. case 1: m_particleSystem->m_colorScale.m_high = colorScale; return;
  693. default: return;
  694. };
  695. }
  696. void DebugWindowDialog::getParticleLifetimeFromSystem( IN Int parmNum, OUT Real& particleLifetime ) const
  697. {
  698. if (!m_particleSystem) {
  699. return;
  700. }
  701. switch (parmNum)
  702. {
  703. case 0: particleLifetime = m_particleSystem->m_lifetime.m_low; return;
  704. case 1: particleLifetime = m_particleSystem->m_lifetime.m_high; return;
  705. default: return;
  706. };
  707. }
  708. void DebugWindowDialog::updateParticleLifetimeToSystem( IN Int parmNum, IN const Real& particleLifetime )
  709. {
  710. if (!m_particleSystem) {
  711. return;
  712. }
  713. switch (parmNum)
  714. {
  715. case 0: m_particleSystem->m_lifetime.m_low = particleLifetime; return;
  716. case 1: m_particleSystem->m_lifetime.m_high = particleLifetime; return;
  717. default: return;
  718. };
  719. }
  720. void DebugWindowDialog::getParticleSizeFromSystem( IN Int parmNum, OUT Real& particleSize ) const
  721. {
  722. if (!m_particleSystem) {
  723. return;
  724. }
  725. switch (parmNum)
  726. {
  727. case 0: particleSize = m_particleSystem->m_startSize.m_low; return;
  728. case 1: particleSize = m_particleSystem->m_startSize.m_high; return;
  729. default: return;
  730. };
  731. }
  732. void DebugWindowDialog::updateParticleSizeToSystem( IN Int parmNum, IN const Real& particleSize )
  733. {
  734. if (!m_particleSystem) {
  735. return;
  736. }
  737. switch (parmNum)
  738. {
  739. case 0: m_particleSystem->m_startSize.m_low = particleSize; return;
  740. case 1: m_particleSystem->m_startSize.m_high = particleSize; return;
  741. default: return;
  742. };
  743. }
  744. void DebugWindowDialog::getStartSizeRateFromSystem( IN Int parmNum, OUT Real& startSizeRate ) const
  745. {
  746. if (!m_particleSystem) {
  747. return;
  748. }
  749. switch (parmNum)
  750. {
  751. case 0: startSizeRate = m_particleSystem->m_startSizeRate.m_low; return;
  752. case 1: startSizeRate = m_particleSystem->m_startSizeRate.m_high; return;
  753. default: return;
  754. };
  755. }
  756. void DebugWindowDialog::updateStartSizeRateToSystem( IN Int parmNum, IN const Real& startSizeRate )
  757. {
  758. if (!m_particleSystem) {
  759. return;
  760. }
  761. switch (parmNum)
  762. {
  763. case 0: m_particleSystem->m_startSizeRate.m_low = startSizeRate; return;
  764. case 1: m_particleSystem->m_startSizeRate.m_high = startSizeRate; return;
  765. default: return;
  766. };
  767. }
  768. void DebugWindowDialog::getSizeRateFromSystem( IN Int parmNum, OUT Real& sizeRate ) const
  769. {
  770. if (!m_particleSystem) {
  771. return;
  772. }
  773. switch (parmNum)
  774. {
  775. case 0: sizeRate = m_particleSystem->m_sizeRate.m_low; return;
  776. case 1: sizeRate = m_particleSystem->m_sizeRate.m_high; return;
  777. default: return;
  778. };
  779. }
  780. void DebugWindowDialog::updateSizeRateToSystem( IN Int parmNum, IN const Real& sizeRate )
  781. {
  782. if (!m_particleSystem) {
  783. return;
  784. }
  785. switch (parmNum)
  786. {
  787. case 0: m_particleSystem->m_sizeRate.m_low = sizeRate; return;
  788. case 1: m_particleSystem->m_sizeRate.m_high = sizeRate; return;
  789. default: return;
  790. };
  791. }
  792. void DebugWindowDialog::getSizeDampingFromSystem( IN Int parmNum, OUT Real& sizeDamping ) const
  793. {
  794. if (!m_particleSystem) {
  795. return;
  796. }
  797. switch (parmNum)
  798. {
  799. case 0: sizeDamping = m_particleSystem->m_sizeRateDamping.m_low; return;
  800. case 1: sizeDamping = m_particleSystem->m_sizeRateDamping.m_high; return;
  801. default: return;
  802. };
  803. }
  804. void DebugWindowDialog::updateSizeDampingToSystem( IN Int parmNum, IN const Real& sizeDamping )
  805. {
  806. if (!m_particleSystem) {
  807. return;
  808. }
  809. switch (parmNum)
  810. {
  811. case 0: m_particleSystem->m_sizeRateDamping.m_low = sizeDamping; return;
  812. case 1: m_particleSystem->m_sizeRateDamping.m_high = sizeDamping; return;
  813. default: return;
  814. };
  815. }
  816. void DebugWindowDialog::getSystemLifetimeFromSystem( OUT Real& systemLifetime ) const
  817. {
  818. if (!m_particleSystem) {
  819. return;
  820. }
  821. systemLifetime = m_particleSystem->m_systemLifetime;
  822. }
  823. void DebugWindowDialog::updateSystemLifetimeToSystem( IN const Real& systemLifetime )
  824. {
  825. if (!m_particleSystem) {
  826. return;
  827. }
  828. m_particleSystem->m_systemLifetime = systemLifetime;
  829. }
  830. void DebugWindowDialog::getSlaveOffsetFromSystem( IN Int parmNum, OUT Real& slaveOffset ) const
  831. {
  832. if (!m_particleSystem) {
  833. return;
  834. }
  835. switch (parmNum)
  836. {
  837. case 0: slaveOffset = m_particleSystem->m_slavePosOffset.x; return;
  838. case 1: slaveOffset = m_particleSystem->m_slavePosOffset.y; return;
  839. case 2: slaveOffset = m_particleSystem->m_slavePosOffset.z; return;
  840. default: return;
  841. };
  842. }
  843. void DebugWindowDialog::updateSlaveOffsetToSystem( IN Int parmNum, IN const Real& slaveOffset )
  844. {
  845. if (!m_particleSystem) {
  846. return;
  847. }
  848. switch (parmNum)
  849. {
  850. case 0: m_particleSystem->m_slavePosOffset.x = slaveOffset; return;
  851. case 1: m_particleSystem->m_slavePosOffset.y = slaveOffset; return;
  852. case 2: m_particleSystem->m_slavePosOffset.z = slaveOffset; return;
  853. default: return;
  854. };
  855. }
  856. void DebugWindowDialog::getDriftVelocityFromSystem( IN Int parmNum, OUT Real& driftVelocity ) const
  857. {
  858. if (!m_particleSystem) {
  859. return;
  860. }
  861. switch (parmNum)
  862. {
  863. case 0: driftVelocity = m_particleSystem->m_driftVelocity.x; return;
  864. case 1: driftVelocity = m_particleSystem->m_driftVelocity.y; return;
  865. case 2: driftVelocity = m_particleSystem->m_driftVelocity.z; return;
  866. default: return;
  867. };
  868. }
  869. void DebugWindowDialog::updateDriftVelocityToSystem( IN Int parmNum, IN const Real& driftVelocity )
  870. {
  871. if (!m_particleSystem) {
  872. return;
  873. }
  874. switch (parmNum)
  875. {
  876. case 0: m_particleSystem->m_driftVelocity.x = driftVelocity; return;
  877. case 1: m_particleSystem->m_driftVelocity.y = driftVelocity; return;
  878. case 2: m_particleSystem->m_driftVelocity.z = driftVelocity; return;
  879. default: return;
  880. };
  881. }
  882. void DebugWindowDialog::getSlaveSystemFromSystem( OUT char *buffer, IN Int bufferSize) const
  883. {
  884. if (!m_particleSystem) {
  885. return;
  886. }
  887. getSelectedParticleAsciiStringParm(PARM_SlaveSystemName, buffer);
  888. }
  889. void DebugWindowDialog::updateSlaveSystemToSystem( IN const char *buffer )
  890. {
  891. if (!m_particleSystem) {
  892. return;
  893. }
  894. updateParticleAsciiStringParm(PARM_SlaveSystemName, buffer);
  895. }
  896. void DebugWindowDialog::getPerParticleSystemFromSystem( OUT char *buffer, IN Int bufferSize) const
  897. {
  898. if (!m_particleSystem) {
  899. return;
  900. }
  901. getSelectedParticleAsciiStringParm(PARM_AttachedSystemName, buffer);
  902. }
  903. void DebugWindowDialog::updatePerParticleSystemToSystem( IN const char *buffer )
  904. {
  905. if (!m_particleSystem) {
  906. return;
  907. }
  908. updateParticleAsciiStringParm(PARM_AttachedSystemName, buffer);
  909. }
  910. void DebugWindowDialog::getSwitchFromSystem( IN SwitchType switchType, OUT Bool& switchVal) const
  911. {
  912. if (!m_particleSystem) {
  913. return;
  914. }
  915. switch (switchType)
  916. {
  917. case ST_HOLLOW: switchVal = m_particleSystem->m_isEmissionVolumeHollow; break;
  918. case ST_ONESHOT: switchVal = m_particleSystem->m_isOneShot; break;
  919. case ST_ALIGNXY: switchVal = m_particleSystem->m_isGroundAligned; break;
  920. case ST_EMITABOVEGROUNDONLY: switchVal = m_particleSystem->m_isEmitAboveGroundOnly; break;
  921. case ST_PARTICLEUPTOWARDSEMITTER: switchVal = m_particleSystem->m_isParticleUpTowardsEmitter; break;
  922. };
  923. }
  924. void DebugWindowDialog::updateSwitchToSystem( IN SwitchType switchType, IN const Bool& switchVal)
  925. {
  926. if (!m_particleSystem) {
  927. return;
  928. }
  929. switch (switchType)
  930. {
  931. case ST_HOLLOW: m_particleSystem->m_isEmissionVolumeHollow = switchVal; break;
  932. case ST_ONESHOT: m_particleSystem->m_isOneShot = switchVal; break;
  933. case ST_ALIGNXY: m_particleSystem->m_isGroundAligned = switchVal; break;
  934. case ST_EMITABOVEGROUNDONLY: m_particleSystem->m_isEmitAboveGroundOnly = switchVal; break;
  935. case ST_PARTICLEUPTOWARDSEMITTER: m_particleSystem->m_isParticleUpTowardsEmitter = switchVal; break;
  936. };
  937. }
  938. // ------------------------------------------------------------------------------------------------
  939. static Real degreeToRadian( Real degree ) { return (degree / 180.0f) * PI; }
  940. static Real radianToDegree( Real radian ) { return (180.0f * radian) / PI; }
  941. void DebugWindowDialog::getPingPongStartAngleFromSystem( IN Int parmNum, OUT Real& angle ) const
  942. {
  943. if (!m_particleSystem) {
  944. return;
  945. }
  946. switch (parmNum)
  947. {
  948. case 0: angle = m_particleSystem->m_windMotionStartAngleMin; break;
  949. case 1: angle = m_particleSystem->m_windMotionStartAngleMax; break;
  950. default: return;
  951. };
  952. angle = radianToDegree( angle );
  953. }
  954. void DebugWindowDialog::updatePingPongStartAngleToSystem( IN Int parmNum, IN const Real& angle )
  955. {
  956. if (!m_particleSystem) {
  957. return;
  958. }
  959. Real radian = degreeToRadian( angle );
  960. switch (parmNum)
  961. {
  962. case 0: m_particleSystem->m_windMotionStartAngleMin = radian; return;
  963. case 1: m_particleSystem->m_windMotionStartAngleMax = radian; return;
  964. default: return;
  965. };
  966. }
  967. void DebugWindowDialog::getPingPongEndAngleFromSystem( IN Int parmNum, OUT Real& angle ) const
  968. {
  969. if (!m_particleSystem) {
  970. return;
  971. }
  972. switch (parmNum)
  973. {
  974. case 0: angle = m_particleSystem->m_windMotionEndAngleMin; break;
  975. case 1: angle = m_particleSystem->m_windMotionEndAngleMax; break;
  976. default: return;
  977. };
  978. angle = radianToDegree( angle );
  979. }
  980. void DebugWindowDialog::updatePingPongEndAngleToSystem( IN Int parmNum, IN const Real& angle )
  981. {
  982. if (!m_particleSystem) {
  983. return;
  984. }
  985. Real radian = degreeToRadian( angle );
  986. switch (parmNum)
  987. {
  988. case 0: m_particleSystem->m_windMotionEndAngleMin = radian; return;
  989. case 1: m_particleSystem->m_windMotionEndAngleMax = radian; return;
  990. default: return;
  991. };
  992. }
  993. void DebugWindowDialog::getWindAngleChangeFromSystem( IN Int parmNum, OUT Real& angle ) const
  994. {
  995. if (!m_particleSystem) {
  996. return;
  997. }
  998. switch (parmNum)
  999. {
  1000. case 0: angle = m_particleSystem->m_windAngleChangeMin; break;
  1001. case 1: angle = m_particleSystem->m_windAngleChangeMax; break;
  1002. default: return;
  1003. };
  1004. angle = radianToDegree( angle );
  1005. }
  1006. void DebugWindowDialog::updateWindAngleChangeToSystem( IN Int parmNum, IN const Real& angle )
  1007. {
  1008. if (!m_particleSystem) {
  1009. return;
  1010. }
  1011. Real radian = degreeToRadian( angle );
  1012. switch (parmNum)
  1013. {
  1014. case 0: m_particleSystem->m_windAngleChangeMin = radian; return;
  1015. case 1: m_particleSystem->m_windAngleChangeMax = radian; return;
  1016. default: return;
  1017. };
  1018. }
  1019. void DebugWindowDialog::getWindMotionFromSystem( OUT ParticleSystemInfo::WindMotion& windMotion ) const
  1020. {
  1021. if (!m_particleSystem) {
  1022. return;
  1023. }
  1024. windMotion = m_particleSystem->m_windMotion;
  1025. }
  1026. void DebugWindowDialog::updateWindMotionToSystem( IN const ParticleSystemInfo::WindMotion& windMotion )
  1027. {
  1028. if (!m_particleSystem) {
  1029. return;
  1030. }
  1031. m_particleSystem->m_windMotion = windMotion;
  1032. }
  1033. // The reason I'm using this function is to prohibit me from forgetting to add an update
  1034. // one way or the other. The idea is that when you implement one, you might as well implement
  1035. // the other, and this way they're in one place.
  1036. void DebugWindowDialog::performUpdate( IN Bool toUI )
  1037. {
  1038. if (!m_particleSystem) {
  1039. return;
  1040. }
  1041. static char buff[ARBITRARY_BUFF_SIZE];
  1042. { // Update the emission type, velocity type, particle type and shader type.
  1043. CComboBox *pCombo;
  1044. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_Priority);
  1045. if (pCombo) {
  1046. int selndx;
  1047. if (toUI) {
  1048. selndx = pCombo->SelectString(-1, ParticlePriorityNames[(long) m_particleSystem->m_priority]);
  1049. } else {
  1050. selndx = pCombo->GetCurSel();
  1051. if (selndx >= 0) {
  1052. m_particleSystem->m_priority = (ParticlePriorityType)(selndx + 1);
  1053. }
  1054. }
  1055. }
  1056. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_EmissionType);
  1057. if (pCombo) {
  1058. int selndx;
  1059. if (toUI) {
  1060. selndx = pCombo->SelectString(-1, EmissionVolumeTypeNames[(long) m_particleSystem->m_emissionVolumeType]);
  1061. } else {
  1062. selndx = pCombo->GetCurSel();
  1063. if (selndx >= 0) {
  1064. m_particleSystem->m_emissionVolumeType = (ParticleSystemInfo::EmissionVolumeType) (selndx + 1);
  1065. }
  1066. }
  1067. // do the page swap
  1068. if (selndx != m_activeEmissionPage && selndx >= 0) {
  1069. m_emissionTypePanels[m_activeEmissionPage]->ShowWindow(SW_HIDE);
  1070. m_activeEmissionPage = selndx;
  1071. m_emissionTypePanels[m_activeEmissionPage]->ShowWindow(SW_SHOW);
  1072. }
  1073. }
  1074. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_VelocityType);
  1075. if (pCombo) {
  1076. int selndx;
  1077. if (toUI) {
  1078. selndx = pCombo->SelectString(-1, EmissionVelocityTypeNames[(long) m_particleSystem->m_emissionVelocityType]);
  1079. } else {
  1080. selndx = pCombo->GetCurSel();
  1081. if (selndx >= 0) {
  1082. m_particleSystem->m_emissionVelocityType = (ParticleSystemInfo::EmissionVelocityType) (selndx + 1);
  1083. }
  1084. }
  1085. // do the page swap
  1086. if (selndx != m_activeVelocityPage && selndx >= 0) {
  1087. m_velocityTypePanels[m_activeVelocityPage]->ShowWindow(SW_HIDE);
  1088. m_activeVelocityPage = selndx;
  1089. m_velocityTypePanels[m_activeVelocityPage]->ShowWindow(SW_SHOW);
  1090. }
  1091. }
  1092. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_ParticleType);
  1093. if (pCombo) {
  1094. int selndx;
  1095. if (toUI) {
  1096. selndx = pCombo->SelectString(-1, ParticleTypeNames[(long) m_particleSystem->m_particleType]);
  1097. } else {
  1098. selndx = pCombo->GetCurSel();
  1099. if (selndx >= 0) {
  1100. m_particleSystem->m_particleType = (ParticleSystemInfo::ParticleType) (selndx + 1);
  1101. }
  1102. }
  1103. // do the swap
  1104. if (selndx != m_activeParticlePage && selndx >= 0) {
  1105. m_particleTypePanels[m_activeParticlePage]->ShowWindow(SW_HIDE);
  1106. m_activeParticlePage = selndx;
  1107. m_particleTypePanels[m_activeParticlePage]->ShowWindow(SW_SHOW);
  1108. }
  1109. }
  1110. pCombo = (CComboBox*) GetDlgItem(IDC_PSEd_ShaderType);
  1111. if (pCombo) {
  1112. if (toUI) {
  1113. pCombo->SelectString(-1, ParticleShaderTypeNames[(long) m_particleSystem->m_shaderType]);
  1114. } else {
  1115. int selndx = pCombo->GetCurSel();
  1116. if (selndx >= 0) {
  1117. m_particleSystem->m_shaderType = (ParticleSystemInfo::ParticleShaderType) (selndx + 1);
  1118. }
  1119. }
  1120. }
  1121. }
  1122. { // update the minimum and maximum for Angle X, Y and Z, and Angular X, Y, and Z
  1123. CWnd *pWnd;
  1124. pWnd = GetDlgItem(IDC_PSEd_AngleXMin);
  1125. if (pWnd) {
  1126. if (toUI) {
  1127. sprintf(buff, FORMAT_STRING, 0.0f);
  1128. pWnd->SetWindowText(buff);
  1129. }
  1130. }
  1131. pWnd = GetDlgItem(IDC_PSEd_AngleYMin);
  1132. if (pWnd) {
  1133. if (toUI) {
  1134. sprintf(buff, FORMAT_STRING, 0.0f);
  1135. pWnd->SetWindowText(buff);
  1136. }
  1137. }
  1138. pWnd = GetDlgItem(IDC_PSEd_AngleZMin);
  1139. if (pWnd) {
  1140. if (toUI) {
  1141. sprintf(buff, FORMAT_STRING, m_particleSystem->m_angleZ.getMinimumValue());
  1142. pWnd->SetWindowText(buff);
  1143. } else {
  1144. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1145. m_particleSystem->m_angleZ.m_low = atof(buff);
  1146. }
  1147. }
  1148. pWnd = GetDlgItem(IDC_PSEd_AngleXMax);
  1149. if (pWnd) {
  1150. if (toUI) {
  1151. sprintf(buff, FORMAT_STRING, 0.0f);
  1152. pWnd->SetWindowText(buff);
  1153. }
  1154. }
  1155. pWnd = GetDlgItem(IDC_PSEd_AngleYMax);
  1156. if (pWnd) {
  1157. if (toUI) {
  1158. sprintf(buff, FORMAT_STRING, 0.0f);
  1159. pWnd->SetWindowText(buff);
  1160. }
  1161. }
  1162. pWnd = GetDlgItem(IDC_PSEd_AngleZMax);
  1163. if (pWnd) {
  1164. if (toUI) {
  1165. sprintf(buff, FORMAT_STRING, m_particleSystem->m_angleZ.getMaximumValue());
  1166. pWnd->SetWindowText(buff);
  1167. } else {
  1168. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1169. m_particleSystem->m_angleZ.m_high = atof(buff);
  1170. }
  1171. }
  1172. pWnd = GetDlgItem(IDC_PSEd_AngularRateXMin);
  1173. if (pWnd) {
  1174. if (toUI) {
  1175. sprintf(buff, FORMAT_STRING, 0.0f);
  1176. pWnd->SetWindowText(buff);
  1177. }
  1178. }
  1179. pWnd = GetDlgItem(IDC_PSEd_AngularRateYMin);
  1180. if (pWnd) {
  1181. if (toUI) {
  1182. sprintf(buff, FORMAT_STRING, 0.0f);
  1183. pWnd->SetWindowText(buff);
  1184. }
  1185. }
  1186. pWnd = GetDlgItem(IDC_PSEd_AngularRateZMin);
  1187. if (pWnd) {
  1188. if (toUI) {
  1189. sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularRateZ.getMinimumValue());
  1190. pWnd->SetWindowText(buff);
  1191. } else {
  1192. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1193. m_particleSystem->m_angularRateZ.m_low = atof(buff);
  1194. }
  1195. }
  1196. pWnd = GetDlgItem(IDC_PSEd_AngularRateXMax);
  1197. if (pWnd) {
  1198. if (toUI) {
  1199. sprintf(buff, FORMAT_STRING, 0.0f);
  1200. pWnd->SetWindowText(buff);
  1201. }
  1202. }
  1203. pWnd = GetDlgItem(IDC_PSEd_AngularRateYMax);
  1204. if (pWnd) {
  1205. if (toUI) {
  1206. sprintf(buff, FORMAT_STRING, 0.0f);
  1207. pWnd->SetWindowText(buff);
  1208. }
  1209. }
  1210. pWnd = GetDlgItem(IDC_PSEd_AngularRateZMax);
  1211. if (pWnd) {
  1212. if (toUI) {
  1213. sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularRateZ.getMaximumValue());
  1214. pWnd->SetWindowText(buff);
  1215. } else {
  1216. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1217. m_particleSystem->m_angularRateZ.m_high = atof(buff);
  1218. }
  1219. }
  1220. }
  1221. { // update the damping values.
  1222. CWnd *pWnd;
  1223. pWnd = GetDlgItem(IDC_PSEd_AngleDampingMin);
  1224. if (pWnd) {
  1225. if (toUI) {
  1226. sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularDamping.getMinimumValue());
  1227. pWnd->SetWindowText(buff);
  1228. } else {
  1229. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1230. m_particleSystem->m_angularDamping.m_low = atof(buff);
  1231. }
  1232. }
  1233. pWnd = GetDlgItem(IDC_PSEd_AngleDampingMax);
  1234. if (pWnd) {
  1235. if (toUI) {
  1236. sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularDamping.getMaximumValue());
  1237. pWnd->SetWindowText(buff);
  1238. } else {
  1239. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1240. m_particleSystem->m_angularDamping.m_high = atof(buff);
  1241. }
  1242. }
  1243. pWnd = GetDlgItem(IDC_PSEd_VelocityDampingMin);
  1244. if (pWnd) {
  1245. if (toUI) {
  1246. sprintf(buff, FORMAT_STRING, m_particleSystem->m_velDamping.getMinimumValue());
  1247. pWnd->SetWindowText(buff);
  1248. } else {
  1249. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1250. m_particleSystem->m_velDamping.m_low = atof(buff);
  1251. }
  1252. }
  1253. pWnd = GetDlgItem(IDC_PSEd_VelocityDampingMax);
  1254. if (pWnd) {
  1255. if (toUI) {
  1256. sprintf(buff, FORMAT_STRING, m_particleSystem->m_velDamping.getMaximumValue());
  1257. pWnd->SetWindowText(buff);
  1258. } else {
  1259. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1260. m_particleSystem->m_velDamping.m_high = atof(buff);
  1261. }
  1262. }
  1263. }
  1264. { // update gravity
  1265. CWnd *pWnd;
  1266. pWnd = GetDlgItem(IDC_PSEd_Gravity);
  1267. if (pWnd) {
  1268. if (toUI) {
  1269. sprintf(buff, FORMAT_STRING, m_particleSystem->m_gravity);
  1270. pWnd->SetWindowText(buff);
  1271. } else {
  1272. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1273. m_particleSystem->m_gravity = atof(buff);
  1274. }
  1275. }
  1276. }
  1277. { // all the kids need to update too.
  1278. m_colorAlphaDialog.performUpdate(toUI);
  1279. m_switchesDialog.performUpdate(toUI);
  1280. m_moreParmsDialog.performUpdate(toUI);
  1281. m_emissionTypePanels[m_activeEmissionPage]->performUpdate(toUI);
  1282. m_velocityTypePanels[m_activeVelocityPage]->performUpdate(toUI);
  1283. m_particleTypePanels[m_activeParticlePage]->performUpdate(toUI);
  1284. }
  1285. }
  1286. void DebugWindowDialog::OnParticleSystemEdit()
  1287. {
  1288. signalParticleSystemEdit();
  1289. }
  1290. void DebugWindowDialog::signalParticleSystemEdit( void )
  1291. {
  1292. performUpdate(false);
  1293. }
  1294. void DebugWindowDialog::OnEditColorAlpha()
  1295. {
  1296. CButton *pButton = (CButton*) GetDlgItem(IDC_PSEd_EditColorButton);
  1297. if (!pButton) {
  1298. return;
  1299. }
  1300. m_showColorDlg = !m_showColorDlg;
  1301. if (m_showColorDlg) {
  1302. m_colorAlphaDialog.ShowWindow(SW_SHOW);
  1303. pButton->SetCheck(TRUE);
  1304. } else {
  1305. m_colorAlphaDialog.ShowWindow(SW_HIDE);
  1306. pButton->SetCheck(FALSE);
  1307. }
  1308. }
  1309. void DebugWindowDialog::OnEditSwitches()
  1310. {
  1311. CButton *pButton = (CButton*) GetDlgItem(IDC_PSEd_EditSwitchesButton);
  1312. if (!pButton) {
  1313. return;
  1314. }
  1315. m_showSwitchesDlg = !m_showSwitchesDlg ;
  1316. if (m_showSwitchesDlg) {
  1317. m_switchesDialog.ShowWindow(SW_SHOW);
  1318. pButton->SetCheck(TRUE);
  1319. } else {
  1320. m_switchesDialog.ShowWindow(SW_HIDE);
  1321. pButton->SetCheck(FALSE);
  1322. }
  1323. }
  1324. // kill all particle systems in the world -- one time effect
  1325. void DebugWindowDialog::OnKillAllParticleSystems()
  1326. {
  1327. m_shouldKillAllParticleSystems = true;
  1328. }
  1329. void DebugWindowDialog::OnEditMoreParms()
  1330. {
  1331. CButton *pButton = (CButton*) GetDlgItem(IDC_PSEd_Continued);
  1332. if (!pButton) {
  1333. return;
  1334. }
  1335. m_showMoreParmsDlg = !m_showMoreParmsDlg ;
  1336. if (m_showMoreParmsDlg ) {
  1337. m_moreParmsDialog.ShowWindow(SW_SHOW);
  1338. pButton->SetCheck(TRUE);
  1339. } else {
  1340. m_moreParmsDialog.ShowWindow(SW_HIDE);
  1341. pButton->SetCheck(FALSE);
  1342. }
  1343. }
  1344. Bool DebugWindowDialog::shouldWriteINI( void )
  1345. {
  1346. if (m_shouldWriteINI) {
  1347. m_shouldWriteINI = false;
  1348. return true;
  1349. }
  1350. return false;
  1351. }
  1352. Bool DebugWindowDialog::hasRequestedReload( void )
  1353. {
  1354. if (m_shouldReload) {
  1355. m_shouldReload = false;
  1356. return true;
  1357. }
  1358. return false;
  1359. }
  1360. Bool DebugWindowDialog::shouldBusyWait( void )
  1361. {
  1362. return m_shouldBusyWait;
  1363. }
  1364. Bool DebugWindowDialog::shouldUpdateParticleCap( void )
  1365. {
  1366. if (m_shouldUpdateParticleCap) {
  1367. m_shouldUpdateParticleCap = false;
  1368. return true;
  1369. }
  1370. return false;
  1371. }
  1372. Bool DebugWindowDialog::shouldReloadTextures( void )
  1373. {
  1374. if (m_shouldReloadTextures) {
  1375. m_shouldReloadTextures = false;
  1376. return true;
  1377. }
  1378. return false;
  1379. }
  1380. Bool DebugWindowDialog::shouldKillAllParticleSystems( void )
  1381. {
  1382. if (m_shouldKillAllParticleSystems) {
  1383. m_shouldKillAllParticleSystems = false;
  1384. return true;
  1385. }
  1386. return false;
  1387. }
  1388. void DebugWindowDialog::OnSysCommand(UINT nID, LPARAM lParam)
  1389. {
  1390. CDialog::OnSysCommand(nID, lParam);
  1391. }
  1392. void DebugWindowDialog::OnReloadSystem( void )
  1393. {
  1394. m_shouldReload = true;
  1395. }
  1396. void DebugWindowDialog::OnReloadCurrent()
  1397. {
  1398. OnReloadSystem();
  1399. }
  1400. void DebugWindowDialog::OnReloadAll()
  1401. {
  1402. OnReloadSystem();
  1403. }
  1404. void DebugWindowDialog::OnSaveCurrent()
  1405. {
  1406. OnPushSave();
  1407. }
  1408. void DebugWindowDialog::OnSaveAll()
  1409. {
  1410. OnPushSave();
  1411. }
  1412. void DebugWindowDialog::OnParticleCapEdit()
  1413. {
  1414. m_shouldUpdateParticleCap = true;
  1415. }
  1416. void DebugWindowDialog::updateCurrentParticleCap( IN int particleCap )
  1417. {
  1418. static char buff[ARBITRARY_BUFF_SIZE];
  1419. CWnd *pWnd = GetDlgItem(IDC_PSEd_CurrentParticleCap);
  1420. if (!pWnd) {
  1421. return;
  1422. }
  1423. sprintf(buff, "%d", particleCap);
  1424. pWnd->SetWindowText(buff);
  1425. }
  1426. void DebugWindowDialog::updateCurrentNumParticles( IN int particleCount )
  1427. {
  1428. static char buff[ARBITRARY_BUFF_SIZE];
  1429. CWnd *pWnd = GetDlgItem(IDC_PSEd_CurrentParticleCount);
  1430. if (!pWnd) {
  1431. return;
  1432. }
  1433. sprintf(buff, "%d", particleCount);
  1434. pWnd->SetWindowText(buff);
  1435. }
  1436. int DebugWindowDialog::getNewParticleCap( void )
  1437. {
  1438. static char buff[ARBITRARY_BUFF_SIZE];
  1439. CWnd *pWnd = GetDlgItem(IDC_PSEd_CurrentParticleCap);
  1440. if (!pWnd) {
  1441. return -1;
  1442. }
  1443. pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1);
  1444. return atoi(buff);
  1445. }
  1446. BEGIN_MESSAGE_MAP(DebugWindowDialog, CDialog)
  1447. ON_WM_CREATE()
  1448. ON_WM_CLOSE()
  1449. ON_WM_SIZE()
  1450. ON_WM_SYSCOMMAND()
  1451. ON_CBN_SELCHANGE(IDC_PSEd_ParticleSystem, OnParticleSystemChange)
  1452. ON_BN_CLICKED(IDC_PSEd_Go, OnParticleSystemChange)
  1453. ON_BN_CLICKED(IDC_PSEd_EditColorButton, OnEditColorAlpha)
  1454. ON_BN_CLICKED(IDC_PSEd_Continued, OnEditMoreParms)
  1455. ON_BN_CLICKED(IDC_PSEd_Save, OnPushSave)
  1456. ON_BN_CLICKED(IDC_PSEd_EditSwitchesButton, OnEditSwitches)
  1457. ON_BN_CLICKED(IDC_PSEd_KillAll, OnKillAllParticleSystems)
  1458. ON_CBN_SELCHANGE(IDC_PSEd_Priority, OnParticleSystemEdit)
  1459. ON_CBN_SELCHANGE(IDC_PSEd_EmissionType, OnParticleSystemEdit)
  1460. ON_CBN_SELCHANGE(IDC_PSEd_VelocityType, OnParticleSystemEdit)
  1461. ON_CBN_SELCHANGE(IDC_PSEd_ParticleType, OnParticleSystemEdit)
  1462. ON_CBN_SELCHANGE(IDC_PSEd_ShaderType, OnParticleSystemEdit)
  1463. ON_COMMAND(ID_FILE_RELOADCURRENT, OnReloadCurrent)
  1464. ON_COMMAND(ID_FILE_RELOADALL, OnReloadAll)
  1465. ON_COMMAND(ID_FILE_SAVECURRENT, OnSaveCurrent)
  1466. ON_COMMAND(ID_FILE_SAVEALL, OnSaveAll)
  1467. ON_COMMAND(ID_FILE_RELOADTEXTURES, OnReloadTextures)
  1468. ON_EN_KILLFOCUS(IDC_PSEd_CurrentParticleCap, OnParticleCapEdit)
  1469. ON_EN_KILLFOCUS(IDC_PSEd_AngleXMin, OnParticleSystemEdit)
  1470. ON_EN_KILLFOCUS(IDC_PSEd_AngleYMin, OnParticleSystemEdit)
  1471. ON_EN_KILLFOCUS(IDC_PSEd_AngleZMin, OnParticleSystemEdit)
  1472. ON_EN_KILLFOCUS(IDC_PSEd_AngleXMax, OnParticleSystemEdit)
  1473. ON_EN_KILLFOCUS(IDC_PSEd_AngleYMax, OnParticleSystemEdit)
  1474. ON_EN_KILLFOCUS(IDC_PSEd_AngleZMax, OnParticleSystemEdit)
  1475. ON_EN_KILLFOCUS(IDC_PSEd_AngularRateXMin, OnParticleSystemEdit)
  1476. ON_EN_KILLFOCUS(IDC_PSEd_AngularRateYMin, OnParticleSystemEdit)
  1477. ON_EN_KILLFOCUS(IDC_PSEd_AngularRateZMin, OnParticleSystemEdit)
  1478. ON_EN_KILLFOCUS(IDC_PSEd_AngularRateXMax, OnParticleSystemEdit)
  1479. ON_EN_KILLFOCUS(IDC_PSEd_AngularRateYMax, OnParticleSystemEdit)
  1480. ON_EN_KILLFOCUS(IDC_PSEd_AngularRateZMax, OnParticleSystemEdit)
  1481. ON_EN_KILLFOCUS(IDC_PSEd_AngleDampingMin, OnParticleSystemEdit)
  1482. ON_EN_KILLFOCUS(IDC_PSEd_AngleDampingMax, OnParticleSystemEdit)
  1483. ON_EN_KILLFOCUS(IDC_PSEd_VelocityDampingMin, OnParticleSystemEdit)
  1484. ON_EN_KILLFOCUS(IDC_PSEd_VelocityDampingMax, OnParticleSystemEdit)
  1485. ON_EN_KILLFOCUS(IDC_PSEd_Gravity, OnParticleSystemEdit)
  1486. END_MESSAGE_MAP()