w3ddlg.cpp 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. /*
  2. ** Command & Conquer Generals(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. /* $Header: /Commando/Code/Tools/max2w3d/w3ddlg.cpp 24 11/07/00 5:40p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - W3D export *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/w3ddlg.cpp $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 11/07/00 4:39p $*
  30. * *
  31. * $Revision:: 24 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #include "w3ddlg.h"
  37. #include "resource.h"
  38. #include "dllmain.h"
  39. #include "w3dexp.h"
  40. #include "util.h"
  41. #include "rawfile.h"
  42. #include <string>
  43. #include "units.h"
  44. #include "presetexportoptionsdialog.h"
  45. #define ENABLE_MESH_OPTIMIZING 0
  46. /*
  47. ** Static functions
  48. */
  49. static BOOL CALLBACK _options_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam);
  50. static void _init_ofn(void);
  51. /*
  52. ** Static data
  53. */
  54. static bool _OfnInited = false;
  55. static OPENFILENAME _HierarchyFileOFN;
  56. /***********************************************************************************************
  57. * W3dOptionsDialogClass::W3dOptionsDialogClass -- constructor for the options dialog object *
  58. * *
  59. * INPUT: *
  60. * *
  61. * OUTPUT: *
  62. * *
  63. * WARNINGS: *
  64. * *
  65. * HISTORY: *
  66. * 07/24/1997 GH : Created. *
  67. *=============================================================================================*/
  68. W3dOptionsDialogClass::W3dOptionsDialogClass(Interface * maxinterface,ExpInterface * exportinterface)
  69. {
  70. MaxInterface = maxinterface;
  71. ExportInterface = exportinterface;
  72. if (!_OfnInited) _init_ofn();
  73. GotHierarchyFilename = false;
  74. RangeLowSpin = NULL;
  75. RangeHighSpin = NULL;
  76. GetMasterUnitInfo(&UnitsType, &UnitsScale);
  77. }
  78. W3dOptionsDialogClass::~W3dOptionsDialogClass(void)
  79. {
  80. ReleaseISpinner(RangeLowSpin);
  81. ReleaseISpinner(RangeHighSpin);
  82. }
  83. bool W3dOptionsDialogClass::Get_Export_Options(W3dExportOptionsStruct * options)
  84. {
  85. Options = options;
  86. // Put up the options dialog box.
  87. /*BOOL result = DialogBoxParam
  88. (
  89. AppInstance,
  90. MAKEINTRESOURCE (IDD_W3D_EXPORT_OPTIONS),
  91. MaxInterface->GetMAXHWnd(),
  92. (DLGPROC) _options_dialog_proc,
  93. (LPARAM) this
  94. );*/
  95. PresetExportOptionsDialogClass dialog (MaxInterface, MaxInterface->GetMAXHWnd ());
  96. dialog.Set_Options (Options);
  97. int result = dialog.Do_Modal ();
  98. if (result == IDOK) {
  99. return true;
  100. } else {
  101. return false;
  102. }
  103. }
  104. /***********************************************************************************************
  105. * W3dOptionsDialogClass::Dialog_Proc -- Handles the windows message for the options dialog *
  106. * *
  107. * INPUT: *
  108. * *
  109. * OUTPUT: *
  110. * *
  111. * WARNINGS: *
  112. * *
  113. * HISTORY: *
  114. * 07/24/1997 GH : Created. *
  115. *=============================================================================================*/
  116. bool W3dOptionsDialogClass::Dialog_Proc
  117. (
  118. HWND hwnd,
  119. UINT message,
  120. WPARAM wParam,
  121. LPARAM
  122. )
  123. {
  124. int code = HIWORD(wParam);
  125. switch (message ) {
  126. /*******************************************************************
  127. * WM_INITDIALOG
  128. *
  129. * Initialize all of the custom controls for the dialog box
  130. *
  131. *******************************************************************/
  132. case WM_INITDIALOG:
  133. Dialog_Init();
  134. return 1;
  135. /*******************************************************************
  136. * WM_COMMAND
  137. *
  138. *
  139. *******************************************************************/
  140. case WM_COMMAND:
  141. switch (LOWORD(wParam))
  142. {
  143. case IDOK:
  144. if (Dialog_Ok() == FALSE) {
  145. MessageBox(Hwnd,"You have not supplied a Base Pose hierarchy file!","Error",MB_OK);
  146. return 1;
  147. }
  148. SetCursor(LoadCursor (NULL, IDC_WAIT));
  149. EndDialog(Hwnd, 1);
  150. break;
  151. case IDCANCEL:
  152. EndDialog(Hwnd, 0);
  153. break;
  154. case IDC_WHT_EXPORT_RADIO:
  155. case IDC_WHT_LOAD_RADIO:
  156. case IDC_WHT_NO_EXPORT_RADIO:
  157. WHT_Export_Radio_Changed();
  158. break;
  159. case IDC_WHA_EXPORT_RADIO:
  160. case IDC_WHA_NO_EXPORT_RADIO:
  161. WHA_Export_Radio_Changed();
  162. break;
  163. case IDC_WTM_EXPORT_RADIO:
  164. case IDC_WTM_NO_EXPORT_RADIO:
  165. WTM_Export_Radio_Changed();
  166. break;
  167. case IDC_COMPRESS_ANIMATION_CHECK:
  168. WHA_Compress_Animation_Check_Changed();
  169. break;
  170. case IDC_REDUCE_ANIMATION_CHECK:
  171. WHA_Reduce_Animation_Check_Changed();
  172. break;
  173. case IDC_COMPRESS_ANIMATION_FLAVOR_COMBO:
  174. WHA_Compression_Flavor_Changed();
  175. break;
  176. case IDC_WHT_BROWSE_BUTTON:
  177. // use the open file common dialog to get a hierarchy filename.
  178. _HierarchyFileOFN.hwndOwner = Hwnd;
  179. _HierarchyFileOFN.lpstrFileTitle = NULL;
  180. _HierarchyFileOFN.lpstrFile = Options->HierarchyFilename;
  181. if (GetOpenFileName(&_HierarchyFileOFN)) {
  182. // Get the relative path between the current export path
  183. // and the full file path to the hierarchy file:
  184. Create_Relative_Path(Options->RelativeHierarchyFilename,
  185. W3dExportClass::CurrentExportPath,
  186. _HierarchyFileOFN.lpstrFile);
  187. // set window text to the relative path.
  188. HWND butHwnd = GetDlgItem(hwnd,IDC_WHT_BROWSE_BUTTON);
  189. if (Options->RelativeHierarchyFilename[0] != 0) {
  190. SetWindowText(butHwnd, Options->RelativeHierarchyFilename);
  191. } else {
  192. SetWindowText(butHwnd, Options->HierarchyFilename);
  193. }
  194. GotHierarchyFilename = true;
  195. SetSaveRequiredFlag(true);
  196. }
  197. _HierarchyFileOFN.lpstrFile = NULL;
  198. break;
  199. }
  200. return 1;
  201. /*******************************************************************
  202. * CC_SPINNER_CHANGE
  203. *
  204. * Max custom spinner controls
  205. *
  206. *******************************************************************/
  207. case CC_SPINNER_CHANGE:
  208. switch (LOWORD(wParam))
  209. {
  210. case IDC_RANGE_LOW_SPIN:
  211. if (RangeLowSpin->GetIVal() > RangeHighSpin->GetIVal())
  212. {
  213. RangeHighSpin->SetValue (RangeLowSpin->GetIVal(),FALSE);
  214. }
  215. break;
  216. case IDC_RANGE_HIGH_SPIN:
  217. if (RangeHighSpin->GetIVal() < RangeLowSpin->GetIVal())
  218. {
  219. RangeLowSpin->SetValue(RangeHighSpin->GetIVal(),FALSE);
  220. }
  221. break;
  222. }
  223. }
  224. return 0;
  225. }
  226. void W3dOptionsDialogClass::Dialog_Init()
  227. {
  228. CenterWindow(Hwnd, GetParent(Hwnd));
  229. SetCursor(LoadCursor (NULL, IDC_ARROW));
  230. // initialize the export radio buttons
  231. if (Options->ExportHierarchy) {
  232. CheckDlgButton(Hwnd,IDC_WHT_EXPORT_RADIO,BST_CHECKED);
  233. Enable_WHT_Export();
  234. } else {
  235. if (Options->LoadHierarchy) {
  236. CheckDlgButton(Hwnd,IDC_WHT_LOAD_RADIO,BST_CHECKED);
  237. Enable_WHT_Load();
  238. // If the relative path is a full path, just erase both paths
  239. // This case happens with files which were exported using a previous,
  240. // bugged version of the exporter which did not handle files on
  241. // different drives correctly.
  242. if (Is_Full_Path(Options->RelativeHierarchyFilename)) {
  243. Options->RelativeHierarchyFilename[0] = 0;
  244. Options->HierarchyFilename[0] = 0;
  245. }
  246. // Honor the relative path if it is present
  247. if (Options->RelativeHierarchyFilename[0] != 0)
  248. {
  249. HWND butHwnd = GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON);
  250. SetWindowText(butHwnd, Options->RelativeHierarchyFilename);
  251. Create_Full_Path(Options->HierarchyFilename,
  252. W3dExportClass::CurrentExportPath,
  253. Options->RelativeHierarchyFilename);
  254. GotHierarchyFilename = true;
  255. } else if (Options->HierarchyFilename[0] != 0) {
  256. HWND butHwnd = GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON);
  257. SetWindowText(butHwnd, Options->HierarchyFilename);
  258. GotHierarchyFilename = true;
  259. }
  260. } else {
  261. CheckDlgButton(Hwnd,IDC_WHT_NO_EXPORT_RADIO,BST_CHECKED);
  262. Disable_WHT_Export();
  263. }
  264. }
  265. if (Options->ExportGeometry) {
  266. CheckDlgButton(Hwnd,IDC_WTM_EXPORT_RADIO,BST_CHECKED);
  267. Enable_WTM_Export();
  268. } else {
  269. CheckDlgButton(Hwnd,IDC_WTM_NO_EXPORT_RADIO,BST_CHECKED);
  270. Disable_WTM_Export();
  271. }
  272. if (Options->SmoothBetweenMeshes && Options->ExportGeometry) {
  273. CheckDlgButton(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK,BST_CHECKED);
  274. } else {
  275. CheckDlgButton(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK,BST_UNCHECKED);
  276. }
  277. SetCheckBox(Hwnd, IDC_TRANSLATION_ONLY_CHECK, Options->TranslationOnly);
  278. SetCheckBox(Hwnd, IDC_TERRAIN_MODE_CHECK, Options->EnableTerrainMode);
  279. // Initialize additional Animation Options
  280. SetCheckBox(Hwnd, IDC_COMPRESS_ANIMATION_CHECK, Options->CompressAnimation);
  281. SetCheckBox(Hwnd, IDC_REDUCE_ANIMATION_CHECK , Options->ReduceAnimation);
  282. SetCheckBox(Hwnd, IDC_VIEWLOG_CHECK, Options->ReviewLog);
  283. char string[128]; // temp string buffer
  284. sprintf(string, "Current FPS: %d", GetFrameRate());
  285. SetDlgItemText(Hwnd, IDC_ANIMATION_FPS_STATIC, string);
  286. // initialize animation combo/list boxes
  287. HwndReduce = GetDlgItem(Hwnd, IDC_REDUCE_ANIMATION_COMBO);
  288. HwndFlavor = GetDlgItem(Hwnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO);
  289. ComboBox_ResetContent(HwndReduce);
  290. ComboBox_ResetContent(HwndFlavor);
  291. for (int i=1; i<100; i++) {
  292. sprintf(string, "%d", i);
  293. ComboBox_AddString(HwndReduce, string);
  294. }
  295. ComboBox_AddString(HwndFlavor, "TimeCoded");
  296. ComboBox_AddString(HwndFlavor, "Adaptive Delta");
  297. if ((Options->ReduceAnimationPercent < 1) || (Options->ReduceAnimationPercent > 99)) {
  298. Options->ReduceAnimationPercent = 50;
  299. }
  300. if ((Options->CompressAnimationFlavor < 0) || (Options->CompressAnimationFlavor >= ANIM_FLAVOR_VALID)) {
  301. Options->CompressAnimationFlavor = 0;
  302. }
  303. ComboBox_SetCurSel(HwndReduce, Options->ReduceAnimationPercent-1);
  304. ComboBox_SetCurSel(HwndFlavor, Options->CompressAnimationFlavor);
  305. HwndTError = GetDlgItem(Hwnd, IDC_MAX_TRANS_ERROR_EDIT);
  306. HwndRError = GetDlgItem(Hwnd, IDC_MAX_ROT_ERROR_EDIT);
  307. sprintf(string, "%f", Options->CompressAnimationTranslationError);
  308. Edit_SetText(HwndTError, string);
  309. sprintf(string, "%f", Options->CompressAnimationRotationError);
  310. Edit_SetText(HwndRError, string);
  311. // Make sure everything under animations is properly active/inactive
  312. WHA_Compress_Animation_Check_Changed();
  313. if (Options->ExportAnimation) {
  314. CheckDlgButton(Hwnd,IDC_WHA_EXPORT_RADIO,BST_CHECKED);
  315. Enable_WHA_Export();
  316. } else {
  317. CheckDlgButton(Hwnd,IDC_WHA_NO_EXPORT_RADIO,BST_CHECKED);
  318. Disable_WHA_Export();
  319. }
  320. // initialize the frame-range spinners
  321. int ticksperframe = GetTicksPerFrame();
  322. int startframe = MaxInterface->GetAnimRange().Start() / ticksperframe;
  323. int endframe = MaxInterface->GetAnimRange().End() / ticksperframe;
  324. RangeLowSpin = SetupIntSpinner
  325. (
  326. Hwnd,
  327. IDC_RANGE_LOW_SPIN,
  328. IDC_RANGE_LOW_EDIT,
  329. startframe,
  330. endframe,
  331. Options->StartFrame
  332. );
  333. RangeHighSpin = SetupIntSpinner
  334. (
  335. Hwnd,
  336. IDC_RANGE_HIGH_SPIN,
  337. IDC_RANGE_HIGH_EDIT,
  338. startframe,
  339. endframe,
  340. Options->EndFrame
  341. );
  342. // initialize the 'DisableExportAABTrees' option
  343. CheckDlgButton(Hwnd,IDC_EXPORT_MESH_AABTREES,!Options->DisableExportAABTrees);
  344. CheckDlgButton(Hwnd,IDC_EXPORT_MESH_MAT_TO_TEXTURE,Options->EnableMaterialColorToTextureConversion);
  345. #if ENABLE_MESH_OPTIMIZING
  346. CheckDlgButton(Hwnd,IDC_EXPORT_MESH_OPTIMIZE,Options->EnableOptimizeMeshData);
  347. #endif
  348. }
  349. BOOL W3dOptionsDialogClass::Dialog_Ok()
  350. {
  351. bool changed = false;
  352. // export options:
  353. bool export_h = (IsDlgButtonChecked(Hwnd,IDC_WHT_EXPORT_RADIO) == BST_CHECKED);
  354. changed = changed || (Options->ExportHierarchy != export_h);
  355. Options->ExportHierarchy = export_h;
  356. bool load_h = (IsDlgButtonChecked(Hwnd,IDC_WHT_LOAD_RADIO) == BST_CHECKED);
  357. changed = changed || (Options->LoadHierarchy != load_h);
  358. Options->LoadHierarchy = load_h;
  359. bool export_a = (IsDlgButtonChecked(Hwnd,IDC_WHA_EXPORT_RADIO) == BST_CHECKED);
  360. changed = changed || (Options->ExportAnimation != export_a);
  361. Options->ExportAnimation = export_a;
  362. bool export_g = (IsDlgButtonChecked(Hwnd,IDC_WTM_EXPORT_RADIO) == BST_CHECKED);
  363. changed = changed || (Options->ExportGeometry != export_g);
  364. Options->ExportGeometry = export_g;
  365. if (export_g) {
  366. bool smooth_meshes = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK) == BST_CHECKED);
  367. changed = changed || (Options->SmoothBetweenMeshes != smooth_meshes);
  368. Options->SmoothBetweenMeshes = smooth_meshes;
  369. bool disable_export_aabs = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_AABTREES) != BST_CHECKED);
  370. changed = changed || (Options->DisableExportAABTrees != disable_export_aabs);
  371. Options->DisableExportAABTrees = disable_export_aabs;
  372. bool convert_materials = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_MAT_TO_TEXTURE) == BST_CHECKED);
  373. changed = changed || (Options->EnableMaterialColorToTextureConversion != convert_materials);
  374. Options->EnableMaterialColorToTextureConversion = convert_materials;
  375. #if ENABLE_MESH_OPTIMIZING
  376. bool optimize_mesh_data = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_OPTIMIZE) == BST_CHECKED);
  377. changed = changed || (Options->EnableOptimizeMeshData != optimize_mesh_data);
  378. Options->EnableOptimizeMeshData = optimize_mesh_data;
  379. #else
  380. Options->EnableOptimizeMeshData = false;
  381. #endif
  382. } else {
  383. Options->SmoothBetweenMeshes = false;
  384. Options->DisableExportAABTrees = false;
  385. Options->EnableOptimizeMeshData = false;
  386. Options->EnableMaterialColorToTextureConversion = false;
  387. }
  388. // Hierarchy Options:
  389. bool xlation_only = (IsDlgButtonChecked(Hwnd,IDC_TRANSLATION_ONLY_CHECK) == BST_CHECKED);
  390. changed = changed || (Options->TranslationOnly != xlation_only);
  391. Options->TranslationOnly = xlation_only;
  392. bool terrain_mode = (IsDlgButtonChecked(Hwnd,IDC_TERRAIN_MODE_CHECK) == BST_CHECKED);
  393. changed = changed || (Options->EnableTerrainMode != terrain_mode);
  394. Options->EnableTerrainMode = terrain_mode;
  395. if (Options->LoadHierarchy && (Options->ExportAnimation || Options->ExportGeometry)) {
  396. if (!GotHierarchyFilename) {
  397. MessageBox(Hwnd,"You have not supplied a Base Pose hierarchy file!","Error",MB_OK);
  398. if (changed) SetSaveRequiredFlag(true);
  399. return FALSE;
  400. }
  401. RawFileClass file(Options->HierarchyFilename);
  402. if (!file.Open()) {
  403. char buf[100+_MAX_FNAME+_MAX_EXT];
  404. sprintf(buf,"Unable to load hierarchy file: %s\nIf this Max file has been moved, please re-select the hierarchy file.",Options->HierarchyFilename);
  405. MessageBox(Hwnd,buf,"Error",MB_OK);
  406. return FALSE;
  407. }
  408. file.Close();
  409. }
  410. // Animation options:
  411. int start_frame = RangeLowSpin->GetIVal();
  412. changed = changed || (Options->StartFrame != start_frame);
  413. Options->StartFrame = start_frame;
  414. int end_frame = RangeHighSpin->GetIVal();
  415. changed = changed || (Options->EndFrame != end_frame);
  416. Options->EndFrame = end_frame;
  417. bool compress_animation = (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED);
  418. changed = changed || (Options->CompressAnimation != compress_animation);
  419. Options->CompressAnimation = compress_animation;
  420. bool reduce_animation = (IsDlgButtonChecked(Hwnd, IDC_REDUCE_ANIMATION_CHECK) == BST_CHECKED);
  421. changed = changed || (Options->ReduceAnimation != reduce_animation);
  422. Options->ReduceAnimation = reduce_animation;
  423. int reduce_percent = ComboBox_GetCurSel(HwndReduce) + 1;
  424. changed = changed || (Options->ReduceAnimationPercent != reduce_percent);
  425. Options->ReduceAnimationPercent = reduce_percent;
  426. int flavor = ComboBox_GetCurSel(HwndFlavor);
  427. changed = changed || (Options->CompressAnimationFlavor != flavor);
  428. Options->CompressAnimationFlavor = flavor;
  429. char string[128];
  430. Edit_GetText(HwndTError, string, 128);
  431. float trans_error = atof(string);
  432. changed = changed || (Options->CompressAnimationTranslationError != trans_error);
  433. Options->CompressAnimationTranslationError = trans_error;
  434. Edit_GetText(HwndRError, string, 128);
  435. float rot_error = atof(string);
  436. changed = changed || (Options->CompressAnimationRotationError != rot_error);
  437. Options->CompressAnimationRotationError = rot_error;
  438. bool review_log = (IsDlgButtonChecked(Hwnd, IDC_VIEWLOG_CHECK) == BST_CHECKED);
  439. changed = changed || (Options->ReviewLog != review_log);
  440. Options->ReviewLog = review_log;
  441. // Geometry options:
  442. //Options->UseVoxelizer = (IsDlgButtonChecked(Hwnd,IDC_VOXELIZER_CHECK) == BST_CHECKED);
  443. Options->UseVoxelizer = false;
  444. if (changed) SetSaveRequiredFlag(true);
  445. return TRUE;
  446. }
  447. void W3dOptionsDialogClass::Enable_WHT_Export(void)
  448. {
  449. EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),TRUE);
  450. EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),TRUE);
  451. EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),FALSE);
  452. EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),TRUE);
  453. }
  454. void W3dOptionsDialogClass::Enable_WHT_Load(void)
  455. {
  456. EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),FALSE);
  457. EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),FALSE);
  458. EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),TRUE);
  459. EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),TRUE);
  460. }
  461. void W3dOptionsDialogClass::Disable_WHT_Export(void)
  462. {
  463. // since there will be no hierarchy tree, disable animation
  464. CheckDlgButton(Hwnd,IDC_WHA_EXPORT_RADIO,BST_UNCHECKED);
  465. CheckDlgButton(Hwnd,IDC_WHA_NO_EXPORT_RADIO,BST_CHECKED);
  466. Disable_WHA_Export();
  467. EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),FALSE);
  468. EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),FALSE);
  469. EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),FALSE);
  470. EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),FALSE);
  471. }
  472. void W3dOptionsDialogClass::Enable_WHA_Export(void)
  473. {
  474. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_EDIT),TRUE);
  475. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_SPIN),TRUE);
  476. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_EDIT),TRUE);
  477. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_SPIN),TRUE);
  478. EnableWindow(GetDlgItem(Hwnd,IDC_VIEWLOG_CHECK), TRUE);
  479. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_CHECK),TRUE);
  480. if (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED) {
  481. Enable_CompressAnimationOptions_Export();
  482. }
  483. }
  484. void W3dOptionsDialogClass::Disable_WHA_Export(void)
  485. {
  486. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_EDIT),FALSE);
  487. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_SPIN),FALSE);
  488. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_EDIT),FALSE);
  489. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_SPIN),FALSE);
  490. EnableWindow(GetDlgItem(Hwnd,IDC_VIEWLOG_CHECK), FALSE);
  491. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_CHECK),FALSE);
  492. Disable_CompressAnimationOptions_Export();
  493. }
  494. void W3dOptionsDialogClass::Enable_ReduceAnimationOptions_Export(void)
  495. {
  496. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), TRUE);
  497. }
  498. void W3dOptionsDialogClass::Disable_ReduceAnimationOptions_Export(void)
  499. {
  500. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), FALSE);
  501. }
  502. void W3dOptionsDialogClass::Enable_CompressAnimationOptions_Export(void)
  503. {
  504. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_FLAVOR_COMBO), TRUE);
  505. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), TRUE);
  506. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), TRUE);
  507. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), TRUE);
  508. WHA_Reduce_Animation_Check_Changed();
  509. WHA_Compression_Flavor_Changed();
  510. }
  511. void W3dOptionsDialogClass::Disable_CompressAnimationOptions_Export(void)
  512. {
  513. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_FLAVOR_COMBO), FALSE);
  514. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), FALSE);
  515. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), FALSE);
  516. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), FALSE);
  517. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), FALSE);
  518. }
  519. void W3dOptionsDialogClass::Enable_WTM_Export(void)
  520. {
  521. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK),TRUE);
  522. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_AABTREES),TRUE);
  523. #if ENABLE_MESH_OPTIMIZING
  524. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_OPTIMIZE),TRUE);
  525. #endif
  526. }
  527. void W3dOptionsDialogClass::Disable_WTM_Export(void)
  528. {
  529. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK),FALSE);
  530. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_AABTREES),FALSE);
  531. #if ENABLE_MESH_OPTIMIZING
  532. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_OPTIMIZE),FALSE);
  533. #endif
  534. }
  535. void W3dOptionsDialogClass::WHT_Export_Radio_Changed(void)
  536. {
  537. if (IsDlgButtonChecked(Hwnd, IDC_WHT_EXPORT_RADIO) == BST_CHECKED) {
  538. Enable_WHT_Export();
  539. } else if (IsDlgButtonChecked(Hwnd,IDC_WHT_LOAD_RADIO) == BST_CHECKED) {
  540. Enable_WHT_Load();
  541. } else if (IsDlgButtonChecked(Hwnd,IDC_WHT_NO_EXPORT_RADIO) == BST_CHECKED) {
  542. Disable_WHT_Export();
  543. }
  544. }
  545. void W3dOptionsDialogClass::WHA_Export_Radio_Changed(void)
  546. {
  547. if (IsDlgButtonChecked(Hwnd, IDC_WHA_EXPORT_RADIO) == BST_CHECKED) {
  548. Enable_WHA_Export();
  549. } else if (IsDlgButtonChecked(Hwnd,IDC_WHA_NO_EXPORT_RADIO) == BST_CHECKED) {
  550. Disable_WHA_Export();
  551. }
  552. }
  553. void W3dOptionsDialogClass::WTM_Export_Radio_Changed(void)
  554. {
  555. if (IsDlgButtonChecked(Hwnd, IDC_WTM_EXPORT_RADIO) == BST_CHECKED) {
  556. Enable_WTM_Export();
  557. } else if (IsDlgButtonChecked(Hwnd,IDC_WTM_NO_EXPORT_RADIO) == BST_CHECKED) {
  558. Disable_WTM_Export();
  559. }
  560. }
  561. void W3dOptionsDialogClass::WHA_Compress_Animation_Check_Changed(void)
  562. {
  563. if (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED) {
  564. Enable_CompressAnimationOptions_Export();
  565. } else {
  566. Disable_CompressAnimationOptions_Export();
  567. }
  568. }
  569. void W3dOptionsDialogClass::WHA_Reduce_Animation_Check_Changed(void)
  570. {
  571. if (IsDlgButtonChecked(Hwnd, IDC_REDUCE_ANIMATION_CHECK) == BST_CHECKED) {
  572. Enable_ReduceAnimationOptions_Export();
  573. } else {
  574. Disable_ReduceAnimationOptions_Export();
  575. }
  576. }
  577. void W3dOptionsDialogClass::WHA_Compression_Flavor_Changed()
  578. {
  579. int flavor = ComboBox_GetCurSel(HwndFlavor);
  580. switch (flavor) {
  581. case ANIM_FLAVOR_TIMECODED: {
  582. WHA_Reduce_Animation_Check_Changed();
  583. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), TRUE);
  584. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), TRUE);
  585. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), TRUE);
  586. break;
  587. }
  588. case ANIM_FLAVOR_ADAPTIVE_DELTA: {
  589. // Disable Reduce animation controls
  590. Disable_ReduceAnimationOptions_Export();
  591. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), FALSE);
  592. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), FALSE);
  593. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), FALSE);
  594. break;
  595. }
  596. default:
  597. assert(0); // invalid compressed flavor setting
  598. break;
  599. }
  600. }
  601. /***********************************************************************************************
  602. * _options_dialog_proc -- thunks into the Options dialog class's windows message handler *
  603. * *
  604. * INPUT: *
  605. * *
  606. * OUTPUT: *
  607. * *
  608. * WARNINGS: *
  609. * *
  610. * HISTORY: *
  611. * 07/24/1997 GH : Created. *
  612. *=============================================================================================*/
  613. BOOL CALLBACK _options_dialog_proc
  614. (
  615. HWND hwnd,
  616. UINT message,
  617. WPARAM wParam,
  618. LPARAM lParam
  619. )
  620. {
  621. static W3dOptionsDialogClass * optdialog = NULL;
  622. if (message == WM_INITDIALOG) {
  623. optdialog = (W3dOptionsDialogClass *) lParam;
  624. optdialog->Hwnd = hwnd;
  625. }
  626. if (optdialog) {
  627. return optdialog->Dialog_Proc(hwnd, message, wParam, lParam);
  628. } else {
  629. return FALSE;
  630. }
  631. }
  632. /***********************************************************************************************
  633. * _init_ofn -- initialize the OpenFilename struct. *
  634. * *
  635. * INPUT: *
  636. * *
  637. * OUTPUT: *
  638. * *
  639. * WARNINGS: *
  640. * *
  641. * HISTORY: *
  642. * 07/24/1997 GH : Created. *
  643. *=============================================================================================*/
  644. void _init_ofn(void)
  645. {
  646. static char _szhierarchyfilter[] = "W3D Files (*.W3D)\0*.W3D\0WHT Files (*.WHT)\0*.WHT\0\0";
  647. _HierarchyFileOFN.lStructSize = sizeof(OPENFILENAME);
  648. _HierarchyFileOFN.hwndOwner = NULL;
  649. _HierarchyFileOFN.hInstance = NULL;
  650. _HierarchyFileOFN.lpstrFilter = _szhierarchyfilter;
  651. _HierarchyFileOFN.lpstrCustomFilter = NULL;
  652. _HierarchyFileOFN.nMaxCustFilter = 0;
  653. _HierarchyFileOFN.nFilterIndex = 0;
  654. _HierarchyFileOFN.lpstrFile = NULL;
  655. _HierarchyFileOFN.nMaxFile = _MAX_PATH;
  656. _HierarchyFileOFN.lpstrFileTitle = NULL;
  657. _HierarchyFileOFN.nMaxFileTitle = _MAX_FNAME + _MAX_EXT;
  658. _HierarchyFileOFN.lpstrInitialDir = NULL;
  659. _HierarchyFileOFN.lpstrTitle = NULL;
  660. _HierarchyFileOFN.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT;
  661. _HierarchyFileOFN.nFileOffset = 0;
  662. _HierarchyFileOFN.nFileExtension = 0;
  663. _HierarchyFileOFN.lpstrDefExt = "wht";
  664. _HierarchyFileOFN.lCustData = 0L;
  665. _HierarchyFileOFN.lpfnHook = NULL;
  666. _HierarchyFileOFN.lpTemplateName = NULL;
  667. _OfnInited = true;
  668. }