GameMtlVertexMaterialDlg.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 : Max2W3d *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlVertexMaterialDlg.cpp $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 7/10/00 3:37p $*
  29. * *
  30. * $Revision:: 12 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg -- constructor *
  35. * GameMtlVertexMaterialDlg::~GameMtlVertexMaterialDlg -- destructor *
  36. * GameMtlVertexMaterialDlg::Dialog_Proc -- windows message handler *
  37. * GameMtlVertexMaterialDlg::ReloadDialog -- reload the contents of the controls *
  38. * GameMtlVertexMaterialDlg::ActivateDlg -- activate / deactivate this dialog *
  39. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  40. #include "GameMtlVertexMaterialDlg.h"
  41. #include "GameMtl.h"
  42. #include "dllmain.h"
  43. #include "resource.h"
  44. /***********************************************************************************************
  45. * GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg -- constructor *
  46. * *
  47. * INPUT: *
  48. * *
  49. * OUTPUT: *
  50. * *
  51. * WARNINGS: *
  52. * *
  53. * HISTORY: *
  54. * 11/23/98 GTH : Created. *
  55. *=============================================================================================*/
  56. GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg
  57. (
  58. HWND parent,
  59. IMtlParams * imp,
  60. GameMtl * mtl,
  61. int pass
  62. ) :
  63. GameMtlFormClass(imp,mtl,pass)
  64. {
  65. AmbientSwatch = NULL;
  66. DiffuseSwatch = NULL;
  67. SpecularSwatch = NULL;
  68. EmissiveSwatch = NULL;
  69. OpacitySpin = NULL;
  70. TranslucencySpin = NULL;
  71. ShininessSpin = NULL;
  72. for (int i=0; i<MAX_STAGES; i++) {
  73. UVChannelSpin[i] = NULL;
  74. }
  75. Create_Form(parent,IDD_GAMEMTL_VERTEX_MATERIAL);
  76. }
  77. /***********************************************************************************************
  78. * GameMtlVertexMaterialDlg::~GameMtlVertexMaterialDlg -- destructor *
  79. * *
  80. * INPUT: *
  81. * *
  82. * OUTPUT: *
  83. * *
  84. * WARNINGS: *
  85. * *
  86. * HISTORY: *
  87. * 11/23/98 GTH : Created. *
  88. *=============================================================================================*/
  89. GameMtlVertexMaterialDlg::~GameMtlVertexMaterialDlg()
  90. {
  91. if (AmbientSwatch) {
  92. ReleaseIColorSwatch(AmbientSwatch);
  93. }
  94. if (DiffuseSwatch) {
  95. ReleaseIColorSwatch(DiffuseSwatch);
  96. }
  97. if (SpecularSwatch) {
  98. ReleaseIColorSwatch(SpecularSwatch);
  99. }
  100. if (EmissiveSwatch) {
  101. ReleaseIColorSwatch(EmissiveSwatch);
  102. }
  103. if (OpacitySpin) {
  104. ReleaseISpinner(OpacitySpin);
  105. }
  106. if (TranslucencySpin) {
  107. ReleaseISpinner(TranslucencySpin);
  108. }
  109. if (ShininessSpin) {
  110. ReleaseISpinner(ShininessSpin);
  111. }
  112. for (int i=0; i<MAX_STAGES; i++) {
  113. if (UVChannelSpin[i] != NULL) {
  114. ReleaseISpinner(UVChannelSpin[i]);
  115. }
  116. }
  117. }
  118. /***********************************************************************************************
  119. * GameMtlVertexMaterialDlg::Dialog_Proc -- windows message handler *
  120. * *
  121. * INPUT: *
  122. * *
  123. * OUTPUT: *
  124. * *
  125. * WARNINGS: *
  126. * *
  127. * HISTORY: *
  128. * 11/23/98 GTH : Created. *
  129. *=============================================================================================*/
  130. BOOL GameMtlVertexMaterialDlg::Dialog_Proc(HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam)
  131. {
  132. int val;
  133. int id = LOWORD(wparam);
  134. int code = HIWORD(wparam);
  135. switch (message)
  136. {
  137. case WM_INITDIALOG:
  138. {
  139. AmbientSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_AMBIENT_COLOR),TheMtl->Get_Ambient(PassIndex,IParams->GetTime()),Get_String(IDS_AMBIENT_COLOR));
  140. DiffuseSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_DIFFUSE_COLOR),TheMtl->Get_Diffuse(PassIndex,IParams->GetTime()),Get_String(IDS_DIFFUSE_COLOR));
  141. SpecularSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_SPECULAR_COLOR),TheMtl->Get_Specular(PassIndex,IParams->GetTime()),Get_String(IDS_SPECULAR_COLOR));
  142. EmissiveSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_EMISSIVE_COLOR),TheMtl->Get_Emissive(PassIndex,IParams->GetTime()),Get_String(IDS_EMISSIVE_COLOR));
  143. OpacitySpin = SetupFloatSpinner(dlg_wnd,IDC_OPACITY_SPIN,IDC_OPACITY_EDIT,0.0f,1.0f,TheMtl->Get_Opacity(PassIndex,IParams->GetTime()),0.01f);
  144. TranslucencySpin = SetupFloatSpinner(dlg_wnd,IDC_TRANSLUCENCY_SPIN,IDC_TRANSULCENCY_EDIT,0.0f,1.0f,TheMtl->Get_Translucency(PassIndex,IParams->GetTime()),0.01f);
  145. ShininessSpin = SetupFloatSpinner(dlg_wnd,IDC_SHININESS_SPIN,IDC_SHININESS_EDIT,1.0f,1000.0f,TheMtl->Get_Shininess(PassIndex,IParams->GetTime()),1.0f);
  146. UVChannelSpin[0] = SetupIntSpinner(dlg_wnd,IDC_STAGE0UVCHAN_SPIN,IDC_STAGE0UVCHAN_EDIT,1,99,1);
  147. UVChannelSpin[1] = SetupIntSpinner(dlg_wnd,IDC_STAGE1UVCHAN_SPIN,IDC_STAGE1UVCHAN_EDIT,1,99,1);
  148. break;
  149. }
  150. case WM_LBUTTONDOWN:
  151. case WM_LBUTTONUP:
  152. case WM_MOUSEMOVE:
  153. {
  154. IParams->RollupMouseMessage(dlg_wnd,message,wparam,lparam);
  155. return FALSE;
  156. }
  157. case WM_COMMAND:
  158. {
  159. switch (id)
  160. {
  161. case IDC_COPY_SPECULAR_DIFFUSE:
  162. TheMtl->Set_Copy_Specular_To_Diffuse(PassIndex,GetCheckBox(dlg_wnd, IDC_COPY_SPECULAR_DIFFUSE) == TRUE);
  163. break;
  164. case IDC_MAPPING0_COMBO:
  165. if (code == CBN_SELCHANGE) {
  166. val = SendDlgItemMessage(dlg_wnd,IDC_MAPPING0_COMBO,CB_GETCURSEL,0,0);
  167. TheMtl->Set_Mapping_Type(PassIndex,0,val);
  168. }
  169. break;
  170. case IDC_MAPPING1_COMBO:
  171. if (code == CBN_SELCHANGE) {
  172. val = SendDlgItemMessage(dlg_wnd,IDC_MAPPING1_COMBO,CB_GETCURSEL,0,0);
  173. TheMtl->Set_Mapping_Type(PassIndex,1,val);
  174. }
  175. break;
  176. case IDC_MAPPING0_ARGS_EDIT:
  177. switch (code) {
  178. case EN_SETFOCUS:
  179. DisableAccelerators();
  180. break;
  181. case EN_KILLFOCUS:
  182. EnableAccelerators();
  183. break;
  184. case EN_CHANGE:
  185. int len = GetWindowTextLength(GetDlgItem(dlg_wnd, IDC_MAPPING0_ARGS_EDIT));
  186. char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 0, len);
  187. GetWindowText(GetDlgItem(dlg_wnd, IDC_MAPPING0_ARGS_EDIT), buffer, len + 1);
  188. break;
  189. }
  190. break;
  191. case IDC_MAPPING1_ARGS_EDIT:
  192. switch (code) {
  193. case EN_SETFOCUS:
  194. DisableAccelerators();
  195. break;
  196. case EN_KILLFOCUS:
  197. EnableAccelerators();
  198. break;
  199. case EN_CHANGE:
  200. int len = GetWindowTextLength(GetDlgItem(dlg_wnd, IDC_MAPPING1_ARGS_EDIT));
  201. char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 1, len);
  202. GetWindowText(GetDlgItem(dlg_wnd, IDC_MAPPING1_ARGS_EDIT), buffer, len + 1);
  203. break;
  204. }
  205. break;
  206. case IDC_NO_TRANS:
  207. TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_NONE);
  208. break;
  209. case IDC_100_TRANS:
  210. TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_100);
  211. break;
  212. case IDC_50_TRANS:
  213. TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_50);
  214. break;
  215. case IDC_25_TRANS:
  216. TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_25);
  217. break;
  218. case IDC_MINUS_100_TRANS:
  219. TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_MINUS_100);
  220. break;
  221. case IDC_NO_RT_LIGHTING:
  222. TheMtl->Set_PSX_Lighting(PassIndex,!GetCheckBox(dlg_wnd, IDC_NO_RT_LIGHTING));
  223. break;
  224. }
  225. break;
  226. }
  227. case CC_COLOR_CHANGE:
  228. {
  229. // just update all of the colors
  230. TheMtl->Set_Ambient(PassIndex,IParams->GetTime(),AmbientSwatch->GetColor());
  231. TheMtl->Set_Diffuse(PassIndex,IParams->GetTime(),DiffuseSwatch->GetColor());
  232. TheMtl->Set_Specular(PassIndex,IParams->GetTime(),SpecularSwatch->GetColor());
  233. TheMtl->Set_Emissive(PassIndex,IParams->GetTime(),EmissiveSwatch->GetColor());
  234. TheMtl->Notify_Changed();
  235. break;
  236. }
  237. case CC_SPINNER_CHANGE:
  238. {
  239. TheMtl->Set_Shininess(PassIndex,IParams->GetTime(),ShininessSpin->GetFVal());
  240. TheMtl->Set_Opacity(PassIndex,IParams->GetTime(),OpacitySpin->GetFVal());
  241. TheMtl->Set_Translucency(PassIndex,IParams->GetTime(),TranslucencySpin->GetFVal());
  242. for (int i=0; i<MAX_STAGES; i++) {
  243. TheMtl->Set_Map_Channel(PassIndex,i,UVChannelSpin[i]->GetIVal());
  244. }
  245. break;
  246. }
  247. case CC_SPINNER_BUTTONUP:
  248. {
  249. TheMtl->Notify_Changed();
  250. break;
  251. }
  252. }
  253. return FALSE;
  254. }
  255. /***********************************************************************************************
  256. * GameMtlVertexMaterialDlg::ReloadDialog -- reload the contents of the controls *
  257. * *
  258. * INPUT: *
  259. * *
  260. * OUTPUT: *
  261. * *
  262. * WARNINGS: *
  263. * *
  264. * HISTORY: *
  265. * 11/23/98 GTH : Created. *
  266. *=============================================================================================*/
  267. void GameMtlVertexMaterialDlg::ReloadDialog(void)
  268. {
  269. // Vertex Material Controls
  270. DebugPrint("GameMtlVertexMaterialDlg::ReloadDialog\n");
  271. assert(AmbientSwatch && DiffuseSwatch && SpecularSwatch && EmissiveSwatch);
  272. assert(ShininessSpin && OpacitySpin && TranslucencySpin);
  273. AmbientSwatch->InitColor(TheMtl->Get_Ambient(PassIndex,IParams->GetTime()));
  274. DiffuseSwatch->InitColor(TheMtl->Get_Diffuse(PassIndex,IParams->GetTime()));
  275. SpecularSwatch->InitColor(TheMtl->Get_Specular(PassIndex,IParams->GetTime()));
  276. EmissiveSwatch->InitColor(TheMtl->Get_Emissive(PassIndex,IParams->GetTime()));
  277. ShininessSpin->SetValue(TheMtl->Get_Shininess(PassIndex,IParams->GetTime()),FALSE);
  278. OpacitySpin->SetValue(TheMtl->Get_Opacity(PassIndex,IParams->GetTime()),FALSE);
  279. TranslucencySpin->SetValue(TheMtl->Get_Translucency(PassIndex,IParams->GetTime()),FALSE);
  280. for (int i=0; i<MAX_STAGES; i++) {
  281. UVChannelSpin[i]->SetValue(TheMtl->Get_Map_Channel(PassIndex,i),FALSE);
  282. }
  283. SetCheckBox(m_hWnd,IDC_COPY_SPECULAR_DIFFUSE, TheMtl->Get_Copy_Specular_To_Diffuse(PassIndex));
  284. SendDlgItemMessage( m_hWnd,
  285. IDC_MAPPING0_COMBO,
  286. CB_SETCURSEL,
  287. TheMtl->Get_Mapping_Type(PassIndex, 0),
  288. 0 );
  289. SendDlgItemMessage( m_hWnd,
  290. IDC_MAPPING1_COMBO,
  291. CB_SETCURSEL,
  292. TheMtl->Get_Mapping_Type(PassIndex, 1),
  293. 0 );
  294. // PSX Controls
  295. SetCheckBox(m_hWnd,IDC_NO_RT_LIGHTING, !TheMtl->Get_PSX_Lighting(PassIndex));
  296. SetCheckBox(m_hWnd,IDC_NO_TRANS, false);
  297. SetCheckBox(m_hWnd,IDC_100_TRANS, false);
  298. SetCheckBox(m_hWnd,IDC_50_TRANS, false);
  299. SetCheckBox(m_hWnd,IDC_25_TRANS, false);
  300. SetCheckBox(m_hWnd,IDC_MINUS_100_TRANS, false);
  301. switch (TheMtl->Get_PSX_Translucency(PassIndex)) {
  302. case 0:
  303. SetCheckBox(m_hWnd,IDC_NO_TRANS,true);
  304. break;
  305. case GAMEMTL_PSX_TRANS_100:
  306. SetCheckBox(m_hWnd,IDC_100_TRANS,true);
  307. break;
  308. case GAMEMTL_PSX_TRANS_50:
  309. SetCheckBox(m_hWnd,IDC_50_TRANS,true);
  310. break;
  311. case GAMEMTL_PSX_TRANS_25:
  312. SetCheckBox(m_hWnd,IDC_25_TRANS,true);
  313. break;
  314. case GAMEMTL_PSX_TRANS_MINUS_100:
  315. SetCheckBox(m_hWnd,IDC_MINUS_100_TRANS,true);
  316. break;
  317. }
  318. // Reload contents of mapper args edit box:
  319. char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 0);
  320. SetWindowText(GetDlgItem(m_hWnd, IDC_MAPPING0_ARGS_EDIT), buffer);
  321. buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 1);
  322. SetWindowText(GetDlgItem(m_hWnd, IDC_MAPPING1_ARGS_EDIT), buffer);
  323. }
  324. /***********************************************************************************************
  325. * GameMtlVertexMaterialDlg::ActivateDlg -- activate / deactivate this dialog *
  326. * *
  327. * INPUT: *
  328. * *
  329. * OUTPUT: *
  330. * *
  331. * WARNINGS: *
  332. * *
  333. * HISTORY: *
  334. * 11/23/98 GTH : Created. *
  335. *=============================================================================================*/
  336. void GameMtlVertexMaterialDlg::ActivateDlg(BOOL onoff)
  337. {
  338. if (AmbientSwatch) {
  339. AmbientSwatch->Activate(onoff);
  340. }
  341. if (DiffuseSwatch) {
  342. DiffuseSwatch->Activate(onoff);
  343. }
  344. if (SpecularSwatch) {
  345. SpecularSwatch->Activate(onoff);
  346. }
  347. if (EmissiveSwatch) {
  348. EmissiveSwatch->Activate(onoff);
  349. }
  350. }