w3ddlg.cpp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  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. /* $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. #if ENABLE_MESH_OPTIMIZING
  345. CheckDlgButton(Hwnd,IDC_EXPORT_MESH_OPTIMIZE,Options->EnableOptimizeMeshData);
  346. #endif
  347. }
  348. BOOL W3dOptionsDialogClass::Dialog_Ok()
  349. {
  350. bool changed = false;
  351. // export options:
  352. bool export_h = (IsDlgButtonChecked(Hwnd,IDC_WHT_EXPORT_RADIO) == BST_CHECKED);
  353. changed = changed || (Options->ExportHierarchy != export_h);
  354. Options->ExportHierarchy = export_h;
  355. bool load_h = (IsDlgButtonChecked(Hwnd,IDC_WHT_LOAD_RADIO) == BST_CHECKED);
  356. changed = changed || (Options->LoadHierarchy != load_h);
  357. Options->LoadHierarchy = load_h;
  358. bool export_a = (IsDlgButtonChecked(Hwnd,IDC_WHA_EXPORT_RADIO) == BST_CHECKED);
  359. changed = changed || (Options->ExportAnimation != export_a);
  360. Options->ExportAnimation = export_a;
  361. bool export_g = (IsDlgButtonChecked(Hwnd,IDC_WTM_EXPORT_RADIO) == BST_CHECKED);
  362. changed = changed || (Options->ExportGeometry != export_g);
  363. Options->ExportGeometry = export_g;
  364. if (export_g) {
  365. bool smooth_meshes = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK) == BST_CHECKED);
  366. changed = changed || (Options->SmoothBetweenMeshes != smooth_meshes);
  367. Options->SmoothBetweenMeshes = smooth_meshes;
  368. bool disable_export_aabs = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_AABTREES) != BST_CHECKED);
  369. changed = changed || (Options->DisableExportAABTrees != disable_export_aabs);
  370. Options->DisableExportAABTrees = disable_export_aabs;
  371. #if ENABLE_MESH_OPTIMIZING
  372. bool optimize_mesh_data = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_OPTIMIZE) == BST_CHECKED);
  373. changed = changed || (Options->EnableOptimizeMeshData != optimize_mesh_data);
  374. Options->EnableOptimizeMeshData = optimize_mesh_data;
  375. #else
  376. Options->EnableOptimizeMeshData = false;
  377. #endif
  378. } else {
  379. Options->SmoothBetweenMeshes = false;
  380. Options->DisableExportAABTrees = false;
  381. Options->EnableOptimizeMeshData = false;
  382. }
  383. // Hierarchy Options:
  384. bool xlation_only = (IsDlgButtonChecked(Hwnd,IDC_TRANSLATION_ONLY_CHECK) == BST_CHECKED);
  385. changed = changed || (Options->TranslationOnly != xlation_only);
  386. Options->TranslationOnly = xlation_only;
  387. bool terrain_mode = (IsDlgButtonChecked(Hwnd,IDC_TERRAIN_MODE_CHECK) == BST_CHECKED);
  388. changed = changed || (Options->EnableTerrainMode != terrain_mode);
  389. Options->EnableTerrainMode = terrain_mode;
  390. if (Options->LoadHierarchy && (Options->ExportAnimation || Options->ExportGeometry)) {
  391. if (!GotHierarchyFilename) {
  392. MessageBox(Hwnd,"You have not supplied a Base Pose hierarchy file!","Error",MB_OK);
  393. if (changed) SetSaveRequiredFlag(true);
  394. return FALSE;
  395. }
  396. RawFileClass file(Options->HierarchyFilename);
  397. if (!file.Open()) {
  398. char buf[100+_MAX_FNAME+_MAX_EXT];
  399. sprintf(buf,"Unable to load hierarchy file: %s\nIf this Max file has been moved, please re-select the hierarchy file.",Options->HierarchyFilename);
  400. MessageBox(Hwnd,buf,"Error",MB_OK);
  401. return FALSE;
  402. }
  403. file.Close();
  404. }
  405. // Animation options:
  406. int start_frame = RangeLowSpin->GetIVal();
  407. changed = changed || (Options->StartFrame != start_frame);
  408. Options->StartFrame = start_frame;
  409. int end_frame = RangeHighSpin->GetIVal();
  410. changed = changed || (Options->EndFrame != end_frame);
  411. Options->EndFrame = end_frame;
  412. bool compress_animation = (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED);
  413. changed = changed || (Options->CompressAnimation != compress_animation);
  414. Options->CompressAnimation = compress_animation;
  415. bool reduce_animation = (IsDlgButtonChecked(Hwnd, IDC_REDUCE_ANIMATION_CHECK) == BST_CHECKED);
  416. changed = changed || (Options->ReduceAnimation != reduce_animation);
  417. Options->ReduceAnimation = reduce_animation;
  418. int reduce_percent = ComboBox_GetCurSel(HwndReduce) + 1;
  419. changed = changed || (Options->ReduceAnimationPercent != reduce_percent);
  420. Options->ReduceAnimationPercent = reduce_percent;
  421. int flavor = ComboBox_GetCurSel(HwndFlavor);
  422. changed = changed || (Options->CompressAnimationFlavor != flavor);
  423. Options->CompressAnimationFlavor = flavor;
  424. char string[128];
  425. Edit_GetText(HwndTError, string, 128);
  426. float trans_error = atof(string);
  427. changed = changed || (Options->CompressAnimationTranslationError != trans_error);
  428. Options->CompressAnimationTranslationError = trans_error;
  429. Edit_GetText(HwndRError, string, 128);
  430. float rot_error = atof(string);
  431. changed = changed || (Options->CompressAnimationRotationError != rot_error);
  432. Options->CompressAnimationRotationError = rot_error;
  433. bool review_log = (IsDlgButtonChecked(Hwnd, IDC_VIEWLOG_CHECK) == BST_CHECKED);
  434. changed = changed || (Options->ReviewLog != review_log);
  435. Options->ReviewLog = review_log;
  436. // Geometry options:
  437. //Options->UseVoxelizer = (IsDlgButtonChecked(Hwnd,IDC_VOXELIZER_CHECK) == BST_CHECKED);
  438. Options->UseVoxelizer = false;
  439. if (changed) SetSaveRequiredFlag(true);
  440. return TRUE;
  441. }
  442. void W3dOptionsDialogClass::Enable_WHT_Export(void)
  443. {
  444. EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),TRUE);
  445. EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),TRUE);
  446. EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),FALSE);
  447. EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),TRUE);
  448. }
  449. void W3dOptionsDialogClass::Enable_WHT_Load(void)
  450. {
  451. EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),FALSE);
  452. EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),FALSE);
  453. EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),TRUE);
  454. EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),TRUE);
  455. }
  456. void W3dOptionsDialogClass::Disable_WHT_Export(void)
  457. {
  458. // since there will be no hierarchy tree, disable animation
  459. CheckDlgButton(Hwnd,IDC_WHA_EXPORT_RADIO,BST_UNCHECKED);
  460. CheckDlgButton(Hwnd,IDC_WHA_NO_EXPORT_RADIO,BST_CHECKED);
  461. Disable_WHA_Export();
  462. EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),FALSE);
  463. EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),FALSE);
  464. EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),FALSE);
  465. EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),FALSE);
  466. }
  467. void W3dOptionsDialogClass::Enable_WHA_Export(void)
  468. {
  469. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_EDIT),TRUE);
  470. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_SPIN),TRUE);
  471. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_EDIT),TRUE);
  472. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_SPIN),TRUE);
  473. EnableWindow(GetDlgItem(Hwnd,IDC_VIEWLOG_CHECK), TRUE);
  474. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_CHECK),TRUE);
  475. if (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED) {
  476. Enable_CompressAnimationOptions_Export();
  477. }
  478. }
  479. void W3dOptionsDialogClass::Disable_WHA_Export(void)
  480. {
  481. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_EDIT),FALSE);
  482. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_SPIN),FALSE);
  483. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_EDIT),FALSE);
  484. EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_SPIN),FALSE);
  485. EnableWindow(GetDlgItem(Hwnd,IDC_VIEWLOG_CHECK), FALSE);
  486. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_CHECK),FALSE);
  487. Disable_CompressAnimationOptions_Export();
  488. }
  489. void W3dOptionsDialogClass::Enable_ReduceAnimationOptions_Export(void)
  490. {
  491. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), TRUE);
  492. }
  493. void W3dOptionsDialogClass::Disable_ReduceAnimationOptions_Export(void)
  494. {
  495. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), FALSE);
  496. }
  497. void W3dOptionsDialogClass::Enable_CompressAnimationOptions_Export(void)
  498. {
  499. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_FLAVOR_COMBO), TRUE);
  500. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), TRUE);
  501. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), TRUE);
  502. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), TRUE);
  503. WHA_Reduce_Animation_Check_Changed();
  504. WHA_Compression_Flavor_Changed();
  505. }
  506. void W3dOptionsDialogClass::Disable_CompressAnimationOptions_Export(void)
  507. {
  508. EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_FLAVOR_COMBO), FALSE);
  509. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), FALSE);
  510. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), FALSE);
  511. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), FALSE);
  512. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), FALSE);
  513. }
  514. void W3dOptionsDialogClass::Enable_WTM_Export(void)
  515. {
  516. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK),TRUE);
  517. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_AABTREES),TRUE);
  518. #if ENABLE_MESH_OPTIMIZING
  519. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_OPTIMIZE),TRUE);
  520. #endif
  521. }
  522. void W3dOptionsDialogClass::Disable_WTM_Export(void)
  523. {
  524. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK),FALSE);
  525. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_AABTREES),FALSE);
  526. #if ENABLE_MESH_OPTIMIZING
  527. ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_OPTIMIZE),FALSE);
  528. #endif
  529. }
  530. void W3dOptionsDialogClass::WHT_Export_Radio_Changed(void)
  531. {
  532. if (IsDlgButtonChecked(Hwnd, IDC_WHT_EXPORT_RADIO) == BST_CHECKED) {
  533. Enable_WHT_Export();
  534. } else if (IsDlgButtonChecked(Hwnd,IDC_WHT_LOAD_RADIO) == BST_CHECKED) {
  535. Enable_WHT_Load();
  536. } else if (IsDlgButtonChecked(Hwnd,IDC_WHT_NO_EXPORT_RADIO) == BST_CHECKED) {
  537. Disable_WHT_Export();
  538. }
  539. }
  540. void W3dOptionsDialogClass::WHA_Export_Radio_Changed(void)
  541. {
  542. if (IsDlgButtonChecked(Hwnd, IDC_WHA_EXPORT_RADIO) == BST_CHECKED) {
  543. Enable_WHA_Export();
  544. } else if (IsDlgButtonChecked(Hwnd,IDC_WHA_NO_EXPORT_RADIO) == BST_CHECKED) {
  545. Disable_WHA_Export();
  546. }
  547. }
  548. void W3dOptionsDialogClass::WTM_Export_Radio_Changed(void)
  549. {
  550. if (IsDlgButtonChecked(Hwnd, IDC_WTM_EXPORT_RADIO) == BST_CHECKED) {
  551. Enable_WTM_Export();
  552. } else if (IsDlgButtonChecked(Hwnd,IDC_WTM_NO_EXPORT_RADIO) == BST_CHECKED) {
  553. Disable_WTM_Export();
  554. }
  555. }
  556. void W3dOptionsDialogClass::WHA_Compress_Animation_Check_Changed(void)
  557. {
  558. if (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED) {
  559. Enable_CompressAnimationOptions_Export();
  560. } else {
  561. Disable_CompressAnimationOptions_Export();
  562. }
  563. }
  564. void W3dOptionsDialogClass::WHA_Reduce_Animation_Check_Changed(void)
  565. {
  566. if (IsDlgButtonChecked(Hwnd, IDC_REDUCE_ANIMATION_CHECK) == BST_CHECKED) {
  567. Enable_ReduceAnimationOptions_Export();
  568. } else {
  569. Disable_ReduceAnimationOptions_Export();
  570. }
  571. }
  572. void W3dOptionsDialogClass::WHA_Compression_Flavor_Changed()
  573. {
  574. int flavor = ComboBox_GetCurSel(HwndFlavor);
  575. switch (flavor) {
  576. case ANIM_FLAVOR_TIMECODED: {
  577. WHA_Reduce_Animation_Check_Changed();
  578. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), TRUE);
  579. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), TRUE);
  580. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), TRUE);
  581. break;
  582. }
  583. case ANIM_FLAVOR_ADAPTIVE_DELTA: {
  584. // Disable Reduce animation controls
  585. Disable_ReduceAnimationOptions_Export();
  586. EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), FALSE);
  587. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), FALSE);
  588. EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), FALSE);
  589. break;
  590. }
  591. default:
  592. assert(0); // invalid compressed flavor setting
  593. break;
  594. }
  595. }
  596. /***********************************************************************************************
  597. * _options_dialog_proc -- thunks into the Options dialog class's windows message handler *
  598. * *
  599. * INPUT: *
  600. * *
  601. * OUTPUT: *
  602. * *
  603. * WARNINGS: *
  604. * *
  605. * HISTORY: *
  606. * 07/24/1997 GH : Created. *
  607. *=============================================================================================*/
  608. BOOL CALLBACK _options_dialog_proc
  609. (
  610. HWND hwnd,
  611. UINT message,
  612. WPARAM wParam,
  613. LPARAM lParam
  614. )
  615. {
  616. static W3dOptionsDialogClass * optdialog = NULL;
  617. if (message == WM_INITDIALOG) {
  618. optdialog = (W3dOptionsDialogClass *) lParam;
  619. optdialog->Hwnd = hwnd;
  620. }
  621. if (optdialog) {
  622. return optdialog->Dialog_Proc(hwnd, message, wParam, lParam);
  623. } else {
  624. return FALSE;
  625. }
  626. }
  627. /***********************************************************************************************
  628. * _init_ofn -- initialize the OpenFilename struct. *
  629. * *
  630. * INPUT: *
  631. * *
  632. * OUTPUT: *
  633. * *
  634. * WARNINGS: *
  635. * *
  636. * HISTORY: *
  637. * 07/24/1997 GH : Created. *
  638. *=============================================================================================*/
  639. void _init_ofn(void)
  640. {
  641. static char _szhierarchyfilter[] = "W3D Files (*.W3D)\0*.W3D\0WHT Files (*.WHT)\0*.WHT\0\0";
  642. _HierarchyFileOFN.lStructSize = sizeof(OPENFILENAME);
  643. _HierarchyFileOFN.hwndOwner = NULL;
  644. _HierarchyFileOFN.hInstance = NULL;
  645. _HierarchyFileOFN.lpstrFilter = _szhierarchyfilter;
  646. _HierarchyFileOFN.lpstrCustomFilter = NULL;
  647. _HierarchyFileOFN.nMaxCustFilter = 0;
  648. _HierarchyFileOFN.nFilterIndex = 0;
  649. _HierarchyFileOFN.lpstrFile = NULL;
  650. _HierarchyFileOFN.nMaxFile = _MAX_PATH;
  651. _HierarchyFileOFN.lpstrFileTitle = NULL;
  652. _HierarchyFileOFN.nMaxFileTitle = _MAX_FNAME + _MAX_EXT;
  653. _HierarchyFileOFN.lpstrInitialDir = NULL;
  654. _HierarchyFileOFN.lpstrTitle = NULL;
  655. _HierarchyFileOFN.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT;
  656. _HierarchyFileOFN.nFileOffset = 0;
  657. _HierarchyFileOFN.nFileExtension = 0;
  658. _HierarchyFileOFN.lpstrDefExt = "wht";
  659. _HierarchyFileOFN.lCustData = 0L;
  660. _HierarchyFileOFN.lpfnHook = NULL;
  661. _HierarchyFileOFN.lpTemplateName = NULL;
  662. _OfnInited = true;
  663. }