-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLuxMaxdlg.cpp
846 lines (736 loc) · 28.6 KB
/
LuxMaxdlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
/***************************************************************************
* Copyright 1998-2015 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxRender. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#include <iostream>
#include "LuxMaxpch.h"
#include "resource.h"
#include "LuxMax.h"
#include <maxscript\maxscript.h>
#include "3dsmaxport.h"
#include <sstream>
#include <string>
extern HINSTANCE hInstance;
static INT_PTR CALLBACK LuxMaxParamDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
class LuxMaxParamDlg : public RendParamDlg {
public:
LuxMax *rend;
IRendParams *ir;
HWND hPanel;
//HWND hDlg;
BOOL prog;
HFONT hFont;
TSTR workFileName;
TSTR vbintervalWstr;
//int workRenderType;
int halttime;
TSTR halttimewstr;// = L"30";
//float LensRadius;
TSTR LensRadiusWstr = L"33";
float LensRadiusFloatTmp = 0.0f;
int rendertype;
int samplerIndex;
TSTR rendertypeWstr;
int filterIndex;
int lightStrategyIndex;
float filterXvalue;
float filterYvalue;
float filterGuassianAlphavalue;
float filterMitchellAvalue;
float filterMitchellBvalue;
float MetropolisLargestEpRatevalue;
int MetropolisMaxConsecutiveRejectvalue;
float MetrolpolisImageMutationRatevalue;
//TSTR vbinterval = L"1";
bool defaultlightchk = true;
bool defaultlightauto = true;
bool enableFileSaverOutput = false;
ISpinnerControl *depthSpinner = NULL;
ISpinnerControl *filterXSpinner = NULL;
ISpinnerControl *filterYSpinner = NULL;
ISpinnerControl *filterGuassianAlphaSpinner = NULL;
ISpinnerControl *filterMitchellASpinner = NULL;
ISpinnerControl *filterMitchellBSpinner = NULL;
ISpinnerControl* metropolisLargestEpRateSpinner = NULL;
ISpinnerControl* metropolisMaxConsecutiveRejectSpinner = NULL;
ISpinnerControl* metropolisImageMutationRateSpinner = NULL;
LuxMaxParamDlg(LuxMax *r, IRendParams *i, BOOL prog);
~LuxMaxParamDlg();
void AcceptParams();
void DeleteThis() { delete this; }
void InitParamDialog(HWND hWnd);
void InitProgDialog(HWND hWnd);
void InitDepthDialog(HWND hWnd);
void InitFilterDialog(HWND hWnd);
void InitSamplerDialog(HWND hWnd);
void ReleaseControls() {}
BOOL FileBrowse();
INT_PTR WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
};
LuxMaxParamDlg::~LuxMaxParamDlg()
{
DeleteObject(hFont);
ir->DeleteRollupPage(hPanel);
}
INT_PTR LuxMaxParamDlg::WndProc(
HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(wParam);
LuxMaxParamDlg *dlg = DLGetWindowLongPtr<LuxMaxParamDlg*>(hWnd);
switch (msg) {
case WM_INITDIALOG:
dlg = (LuxMaxParamDlg*)lParam;
DLSetWindowLongPtr(hWnd, lParam);
if (dlg)
{
// Enable this to get a dialog at the render progress screen.
// Currently disabled because the dialog has no functionality yet. - no reason to show it.
//if (dlg->prog)
//dlg->InitProgDialog(hWnd);
//else
dlg->InitFilterDialog(hWnd);
dlg->InitParamDialog(hWnd);
//init the depth tab gui
dlg->InitSamplerDialog(hWnd);
dlg->InitDepthDialog(hWnd);
}
break;
case WM_DESTROY:
if (!dlg->prog)
{
//ReleaseISpinner(dlg->depthSpinner);
ReleaseControls();
}
break;
default:
return FALSE;
}
return TRUE;
}
void showHideSamplerGUI(HWND hWnd, int index)
{
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LARGEST_EP_RATE_NEW), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_MAX_CONSECUTIVE_REJECT_NEW), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_IMAGE_MUTATION_RATE_NEW), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LARGEST_EP_RATE_SPIN_NEW), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_MAX_CONSECUTIVE_REJECT_SPIN_NEW), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_IMAGE_MUTATION_RATE_SPIN_NEW), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LABEL1), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LABEL2), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LABEL3), SW_HIDE);
if (index == 0)
{
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LARGEST_EP_RATE_NEW), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_MAX_CONSECUTIVE_REJECT_NEW), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_IMAGE_MUTATION_RATE_NEW), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LARGEST_EP_RATE_SPIN_NEW), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_MAX_CONSECUTIVE_REJECT_SPIN_NEW), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_IMAGE_MUTATION_RATE_SPIN_NEW), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LABEL1), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LABEL2), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_METROPOLIS_LABEL3), SW_SHOW);
}
}
void showHideFilterGUI(HWND hWnd, int index)
{
//HIDE ALL ELEMENTS
//ShowWindow(GetDlgItem(hWnd, IDC_FILTERXWIDTH), SW_HIDE);
//ShowWindow(GetDlgItem(hWnd, IDC_FILTERXWIDTH_SPIN), SW_HIDE);
//ShowWindow(GetDlgItem(hWnd, IDC_FILTERYWIDTH), SW_HIDE);
//ShowWindow(GetDlgItem(hWnd, IDC_FILTERYWIDTH_SPIN), SW_HIDE);
//ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_X_WIDTH_LABEL), SW_HIDE);
//ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_Y_WIDTH_LABEL), SW_HIDE);
//ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_REC_RANGE1), SW_HIDE);
//ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_REC_RANGE2), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_GUASSIAN_ALPHA), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_GUASSIAN_ALPHA_SPIN), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_GUASSIAN_FILTER_ALPHA), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_REC_GUASSIAN_RANGE), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_MITCHEL_FRAME), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_A_LABEL), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_B_LABEL), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_A_FLOAT), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_B_FLOAT), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_A_FLOAT_SPIN), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_B_FLOAT_SPIN), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_A_RANGE), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_B_RANGE), SW_HIDE);
if (index == 0)
{
//blackman harris has no settings
}
if (index == 1)
{
}
else if (index == 2)
{
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_GUASSIAN_ALPHA), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_GUASSIAN_ALPHA_SPIN), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_REC_GUASSIAN_RANGE), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_GUASSIAN_FILTER_ALPHA), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_MITCHEL_FRAME), SW_SHOW);
}
else if (index == 3 || index == 4)
{
//mitchell // Mitchell SS
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_MITCHEL_FRAME), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_A_LABEL), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_B_LABEL), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_A_FLOAT), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_B_FLOAT), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_A_FLOAT_SPIN), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_B_FLOAT_SPIN), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_A_RANGE), SW_SHOW);
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_FILTER_MITCHELL_B_RANGE), SW_SHOW);
}
if (index == 5)
{
//Box filter has no separate settings.
}
}
static INT_PTR CALLBACK LuxMaxParamDlgProc(
HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
//LuxMaxParamDlg *info = DLGetWindowLongPtr<LuxMaxParamDlg*>(hWnd);
DisableAccelerators();
LuxMaxParamDlg *dlg = DLGetWindowLongPtr<LuxMaxParamDlg*>(hWnd);
switch (msg)
{
case WM_INITDIALOG:
{
dlg = (LuxMaxParamDlg*)lParam;
DLSetWindowLongPtr(hWnd, lParam);
//BIASPATHCPU does not exist in latest code.
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"BIASPATHCPU");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"BIASPATHOCL");
//Bidir cpu crashes with latest build
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"BIDIRCPU");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"BIDIRHYBRID");
SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"BIDIRVMCPU");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"CBIDIRHYBRID");
SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"LIGHTCPU");
SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"PATHCPU");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"PATHHYBRID");
SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"TILEPATHCPU");
SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"TILEPATHOCL");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"PATHOCLBASE");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"RTBIASPATHOCL");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_ADDSTRING, 0, (LPARAM)L"RTPATHOCL");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_SELECTSTRING, 0, (LPARAM)L"PATHCPU");
//SendDlgItemMessage(hWnd, IDC_RENDERTYPE_NEW, CB_SETCURSEL, 0, (LPARAM)L"PATHCPU");
//store value back into workRenderType = rend->renderType
SendDlgItemMessage(hWnd, IDC_SAMPLER_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Random");
SendDlgItemMessage(hWnd, IDC_SAMPLER_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Sobol");
SendDlgItemMessage(hWnd, IDC_SAMPLER_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Metropolis");
SendDlgItemMessage(hWnd, IDC_SAMPLER_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"TILEPATHSAMPLER");
SendDlgItemMessage(hWnd, IDC_SAMPLER_TYPE_COMBO, CB_SELECTSTRING, 0, (LPARAM)L"Sobol");
//Add filters to the dropdown.
SendDlgItemMessage(hWnd, IDC_FILTERS_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"None");
SendDlgItemMessage(hWnd, IDC_FILTERS_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Blackman Harris");
SendDlgItemMessage(hWnd, IDC_FILTERS_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Box");
SendDlgItemMessage(hWnd, IDC_FILTERS_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Gaussian");
SendDlgItemMessage(hWnd, IDC_FILTERS_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Mitchell");
SendDlgItemMessage(hWnd, IDC_FILTERS_TYPE_COMBO, CB_ADDSTRING, 0, (LPARAM)L"Mitchell ss");
//SendDlgItemMessage(hWnd, IDC_FILTERS_TYPE_COMBO, CB_SELECTSTRING, 0, (LPARAM)L"Box");
//Light strategy dropdown
SendDlgItemMessage(hWnd, IDC_COMBO_LIGHT_STRATEGY, CB_ADDSTRING, 0, (LPARAM)L"UNIFORM");
SendDlgItemMessage(hWnd, IDC_COMBO_LIGHT_STRATEGY, CB_ADDSTRING, 0, (LPARAM)L"POWER");
SendDlgItemMessage(hWnd, IDC_COMBO_LIGHT_STRATEGY, CB_ADDSTRING, 0, (LPARAM)L"LOG_POWER");
SendDlgItemMessage(hWnd, IDC_COMBO_FILM_OUTPUT_TYPE, CB_ADDSTRING, 0, (LPARAM)L"RGBA_TONEMAPPED");
SendDlgItemMessage(hWnd, IDC_COMBO_FILM_OUTPUT_TYPE, CB_ADDSTRING, 0, (LPARAM)L"RGB_TONEMAPPED");
SendDlgItemMessage(hWnd, IDC_COMBO_FILM_OUTPUT_TYPE, CB_SELECTSTRING, 0, (LPARAM)L"RGBA_TONEMAPPED");
CheckDlgButton(hWnd, IDC_CHECK_OPENCL_GPU, BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_CHECK_OPENCL_CPU, BST_CHECKED);
//CheckDlgButton(hWnd, IDC_OUTPUTSCENE, BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_CHECK_DEFAULT_LIGHT, BST_CHECKED);
CheckDlgButton(hWnd, IDC_CHECK_DEFUALT_LIGHT_DISABLE, BST_CHECKED);
CheckDlgButton(hWnd, IDC_CHECK_OVERRIDE_MATTERIALS, BST_UNCHECKED);
break;
}
case WM_LBUTTONDOWN:
{}
case WM_MOUSEMOVE:
{}
case WM_LBUTTONUP:
{
dlg->ir->RollupMouseMessage(hWnd, msg, wParam, lParam);
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_BUTTON1:
{
TCHAR folderName[MAX_PATH] = { 0 };
GetCOREInterface()->ChooseDirectory(GetCOREInterface()->GetMAXHWnd(), L"Browse for output folder", folderName, NULL);
if (_tcscmp(folderName, _T("")) == 0) {
// Cancel
return FALSE;
}
//_tcscpy(folderName, workFileName);
SetDlgItemText(hWnd, IDC_FILENAME, folderName);
dlg->workFileName = folderName;
break;
}
case IDC_HALTTIME:
{
HWND hwndOutput = GetDlgItem(hWnd, IDC_HALTTIME);
dlg->halttimewstr = GetWindowText(hwndOutput);
break;
}
case IDC_VBINTERVAL:
{
HWND hwndOutput = GetDlgItem(hWnd, IDC_VBINTERVAL);
dlg->vbintervalWstr = GetWindowText(hwndOutput);
break;
}
case IDC_FILTERS_TYPE_COMBO:
{
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
{
HWND filterCombo = GetDlgItem(hWnd, IDC_FILTERS_TYPE_COMBO);
dlg->filterIndex = ComboBox_GetCurSel(filterCombo);
//mprintf(_T("\n Selected filter index %i \n"), dlg->filterIndex);
showHideFilterGUI(hWnd, dlg->filterIndex);
SetFocus(hWnd);
break;
}
}
break;
}
case IDC_COMBO_LIGHT_STRATEGY:
{
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
{
HWND lightStrategyCombo = GetDlgItem(hWnd, IDC_COMBO_LIGHT_STRATEGY);
dlg->lightStrategyIndex = ComboBox_GetCurSel(lightStrategyCombo);
SetFocus(hWnd);
break;
}
}
break;
}
case IDC_RENDERTYPE_NEW:
{
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
{
HWND comboCtl = GetDlgItem(hWnd, IDC_RENDERTYPE_NEW);
dlg->rendertype = ComboBox_GetCurSel(comboCtl);
SetFocus(hWnd);
break;
}
}
break;
case IDC_SAMPLER_TYPE_COMBO:
{
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
{
HWND comboCtl = GetDlgItem(hWnd, IDC_SAMPLER_TYPE_COMBO);
dlg->samplerIndex = ComboBox_GetCurSel(comboCtl);
showHideSamplerGUI(hWnd, dlg->samplerIndex);
SetFocus(hWnd);
break;
}
}
}
}
case IDC_CHECK_DEFAULT_LIGHT:
{
dlg->defaultlightchk = (GetCheckBox(hWnd, IDC_CHECK_DEFAULT_LIGHT) != 0);
break;
}
case IDC_CHECK_DEFUALT_LIGHT_DISABLE:
{
dlg->defaultlightauto = (GetCheckBox(hWnd, IDC_CHECK_DEFUALT_LIGHT_DISABLE) != 0);
break;
}
case IDC_OUTPUTSCENE:
{
//IDC_OUTPUTSCENE
dlg->enableFileSaverOutput = (GetCheckBox(hWnd, IDC_OUTPUTSCENE) != 0);
break;
}
}
}
case CC_SPINNER_CHANGE:
switch (LOWORD(wParam)) { // Switch on ID
case IDC_LENSRADIUS_SPIN:
{
dlg->LensRadiusFloatTmp = ((ISpinnerControl *)lParam)->GetFVal();
break;
}
case IDC_FILTERXWIDTH_SPIN:
{
dlg->filterXvalue = ((ISpinnerControl*)lParam)->GetFVal();
break;
}
case IDC_FILTERYWIDTH_SPIN:
{
dlg->filterYvalue = ((ISpinnerControl*)lParam)->GetFVal();
break;
}
case IDC_FILTER_GUASSIAN_ALPHA_SPIN:
{
dlg->filterGuassianAlphavalue = ((ISpinnerControl*)lParam)->GetFVal();
break;
}
case IDC_FILTER_MITCHEL_A_FLOAT_SPIN:
{
dlg->filterMitchellAvalue = ((ISpinnerControl*)lParam)->GetFVal();
break;
}
case IDC_FILTER_MITCHEL_B_FLOAT_SPIN:
{
dlg->filterMitchellBvalue = ((ISpinnerControl*)lParam)->GetFVal();
break;
}
case IDC_METROPOLIS_LARGEST_EP_RATE_SPIN_NEW:
{
dlg->MetropolisLargestEpRatevalue = ((ISpinnerControl*)lParam)->GetFVal();
break;
}
case IDC_MAX_CONSECUTIVE_REJECT_SPIN_NEW:
{
dlg->MetropolisMaxConsecutiveRejectvalue = ((ISpinnerControl*)lParam)->GetIVal();
break;
}
case IDC_IMAGE_MUTATION_RATE_SPIN_NEW:
{
dlg->MetrolpolisImageMutationRatevalue = ((ISpinnerControl*)lParam)->GetFVal();
break;
}
};
break;
break;
}
if (dlg) return dlg->WndProc(hWnd, msg, wParam, lParam);
else return FALSE;
}
LuxMaxParamDlg::LuxMaxParamDlg(
LuxMax *r, IRendParams *i, BOOL prog)
{
hFont = hFont = CreateFont(14, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH | FF_SWISS, _T(""));
rend = r;
ir = i;
this->prog = prog;
//Enable this to add dialog at the 'render' panel during rendering.
//Disabled for now since we do not have any useful info there.
if (prog) {
// hPanel = ir->AddRollupPage(
// hInstance,
// MAKEINTRESOURCE(IDD_RENDER_PROG),
// LuxMaxParamDlgProc,
// GetString(IDS_VRENDTITLE),
// (LPARAM)this);
}
else {
hPanel = ir->AddRollupPage(
hInstance,
MAKEINTRESOURCE(IDD_RENDER_PARAMS),
LuxMaxParamDlgProc,
GetString(IDS_VRENDTITLE),
(LPARAM)this);
hPanel = ir->AddRollupPage(
hInstance,
MAKEINTRESOURCE(IDD_RENDER_SAMPLER),
LuxMaxParamDlgProc,
GetString(IDS_SAMPLER),
(LPARAM)this);
hPanel = ir->AddRollupPage(
hInstance,
MAKEINTRESOURCE(IDD_RENDER_FILTER),
LuxMaxParamDlgProc,
GetString(IDS_FILTERS),
(LPARAM)this);
hPanel = ir->AddRollupPage(
hInstance,
MAKEINTRESOURCE(IDD_DEPTH),
LuxMaxParamDlgProc,
GetString(IDS_DEPTH),
(LPARAM)this);
}
}
void LuxMaxParamDlg::InitParamDialog(HWND hWnd) {
workFileName = rend->FileName;
HWND hwndOutput = GetDlgItem(hWnd, IDC_FILENAME);
SetWindowText(hwndOutput, rend->FileName);
halttimewstr = rend->halttimewstr;
defaultlightchk = rend->defaultlightchk;
defaultlightauto = rend->defaultlightauto;
vbintervalWstr = rend->vbinterval;
filterIndex = (int)_wtoi(rend->FilterIndexWstr);
rendertype = (int)_wtoi(rend->RenderTypeWstr);
lightStrategyIndex = (int)_wtoi(rend->LightStrategyIndexWstr);
hwndOutput = GetDlgItem(hWnd, IDC_HALTTIME);
SetWindowText(hwndOutput, rend->halttimewstr);
hwndOutput = GetDlgItem(hWnd, IDC_VBINTERVAL);
SetWindowText(hwndOutput, rend->vbinterval);
hwndOutput = GetDlgItem(hWnd, IDC_FILTERS_TYPE_COMBO);
ComboBox_SetCurSel(hwndOutput,filterIndex);
hwndOutput = GetDlgItem(hWnd, IDC_RENDERTYPE_NEW);
ComboBox_SetCurSel(hwndOutput, rendertype);
hwndOutput = GetDlgItem(hWnd, IDC_COMBO_LIGHT_STRATEGY);
ComboBox_SetCurSel(hwndOutput,lightStrategyIndex);
enableFileSaverOutput = rend->enableFileSaverOutput;
int tmpEnableFileSaverOutputValue = (int)_wtoi(rend->enableFileSaverOutoutWstr);
SetCheckBox(hWnd, IDC_OUTPUTSCENE, tmpEnableFileSaverOutputValue);
//hwndOutput = GetDlgItem(hWnd, IDC_FILTER_GUASSIAN_ALPHA);
//SetWindowText(hwndOutput, rend->FilterGuassianAlphaWstr);
}
void LuxMaxParamDlg::InitDepthDialog(HWND hWnd)
{
depthSpinner = GetISpinner(GetDlgItem(hWnd, IDC_LENSRADIUS_SPIN));
if (depthSpinner != NULL)
{
depthSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_LENSRADIUS), EDITTYPE_FLOAT);
depthSpinner->SetLimits(0, 100, false);
depthSpinner->SetResetValue(0.0f);
depthSpinner->SetScale(0.1f);
depthSpinner->SetValue((float)_wtof(rend->LensRadiusstr), TRUE);
ReleaseISpinner(depthSpinner);
}
}
void LuxMaxParamDlg::InitSamplerDialog(HWND hWnd)
{
samplerIndex = (int)_wtoi(rend->SamplerIndexWstr);
metropolisLargestEpRateSpinner = GetISpinner(GetDlgItem(hWnd, IDC_METROPOLIS_LARGEST_EP_RATE_SPIN_NEW));
if (metropolisLargestEpRateSpinner != NULL)
{
metropolisLargestEpRateSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_METROPOLIS_LARGEST_EP_RATE_NEW), EDITTYPE_FLOAT);
metropolisLargestEpRateSpinner->SetLimits(0, 1, false);
metropolisLargestEpRateSpinner->SetResetValue(0.4f);
metropolisLargestEpRateSpinner->SetScale(0.4f);
metropolisLargestEpRateSpinner->SetValue((float)_wtof(rend->MetropolisLargestEpRateWstr), TRUE);
ReleaseISpinner(metropolisLargestEpRateSpinner);
}
metropolisMaxConsecutiveRejectSpinner = GetISpinner(GetDlgItem(hWnd, IDC_MAX_CONSECUTIVE_REJECT_SPIN_NEW));
if (metropolisMaxConsecutiveRejectSpinner != NULL)
{
metropolisMaxConsecutiveRejectSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_MAX_CONSECUTIVE_REJECT_NEW), EDITTYPE_INT);
metropolisMaxConsecutiveRejectSpinner->SetLimits(0, 32768, false);
metropolisMaxConsecutiveRejectSpinner->SetResetValue(512);
metropolisMaxConsecutiveRejectSpinner->SetScale(1);
metropolisMaxConsecutiveRejectSpinner->SetValue((int)_wtof(rend->MetropolisMaxConsecutiveRejectWstr), TRUE);
ReleaseISpinner(metropolisMaxConsecutiveRejectSpinner);
}
metropolisImageMutationRateSpinner = GetISpinner(GetDlgItem(hWnd, IDC_IMAGE_MUTATION_RATE_SPIN_NEW));
if (metropolisImageMutationRateSpinner != NULL)
{
metropolisImageMutationRateSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_IMAGE_MUTATION_RATE_NEW), EDITTYPE_FLOAT);
metropolisImageMutationRateSpinner->SetLimits(0, 1, false);
metropolisImageMutationRateSpinner->SetResetValue(0.1f);
metropolisImageMutationRateSpinner->SetScale(0.1f);
metropolisImageMutationRateSpinner->SetValue((float)_wtof(rend->MetrolpolisImageMutationRateWstr), TRUE);
ReleaseISpinner(metropolisImageMutationRateSpinner);
}
HWND hwndSampler = GetDlgItem(hWnd, IDC_SAMPLER_TYPE_COMBO);
ComboBox_SetCurSel(hwndSampler, samplerIndex);
showHideSamplerGUI(hWnd,samplerIndex);
}
void LuxMaxParamDlg::InitFilterDialog(HWND hWnd)
{
filterXSpinner = GetISpinner(GetDlgItem(hWnd, IDC_FILTERXWIDTH_SPIN));
if (filterXSpinner != NULL)
{
filterXSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_FILTERXWIDTH), EDITTYPE_FLOAT);
filterXSpinner->SetLimits(0, 10, false);
filterXSpinner->SetResetValue(2.0f);
filterXSpinner->SetScale(1.0f);
filterXSpinner->SetValue((float)_wtof(rend->FilterXWidthWst), TRUE);
ReleaseISpinner(filterXSpinner);
}
filterYSpinner = GetISpinner(GetDlgItem(hWnd, IDC_FILTERYWIDTH_SPIN));
if (filterYSpinner != NULL)
{
filterYSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_FILTERYWIDTH), EDITTYPE_FLOAT);
filterYSpinner->SetLimits(0, 10, false);
filterYSpinner->SetResetValue(2.0f);
filterYSpinner->SetScale(1.0f);
filterYSpinner->SetValue((float)_wtof(rend->FilterYWidthWst), TRUE);
ReleaseISpinner(filterYSpinner);
}
filterGuassianAlphaSpinner = GetISpinner(GetDlgItem(hWnd, IDC_FILTER_GUASSIAN_ALPHA_SPIN));
if (filterGuassianAlphaSpinner != NULL)
{
filterGuassianAlphaSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_FILTER_GUASSIAN_ALPHA),EDITTYPE_FLOAT);
filterGuassianAlphaSpinner->SetLimits(0.1, 10,FALSE);
filterGuassianAlphaSpinner->SetResetValue(0.1f);
filterGuassianAlphaSpinner->SetScale(0.1f);
filterGuassianAlphaSpinner->SetValue((float)_wtof(rend->FilterGuassianAlphaWstr), TRUE);
ReleaseISpinner(filterGuassianAlphaSpinner);
}
filterMitchellASpinner = GetISpinner(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_A_FLOAT_SPIN));
if (filterMitchellASpinner != NULL)
{
filterMitchellASpinner->LinkToEdit(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_A_FLOAT), EDITTYPE_FLOAT);
filterMitchellASpinner->SetLimits(0, 1);
filterMitchellASpinner->SetResetValue(1.0f);
filterMitchellASpinner->SetScale(0.1f);
filterMitchellASpinner->SetValue((float)_wtof(rend->FilterMitchellAWstr),true);
ReleaseISpinner(filterMitchellASpinner);
}
filterMitchellBSpinner = GetISpinner(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_B_FLOAT_SPIN));
if (filterMitchellBSpinner != NULL)
{
filterMitchellBSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_FILTER_MITCHEL_B_FLOAT), EDITTYPE_FLOAT);
filterMitchellBSpinner->SetLimits(0, 1);
filterMitchellBSpinner->SetResetValue(1.0f);
filterMitchellBSpinner->SetScale(0.1f);
filterMitchellBSpinner->SetValue((float)_wtof(rend->FilterMitchellBWstr), true);
ReleaseISpinner(filterMitchellBSpinner);
}
showHideFilterGUI(hWnd, filterIndex);
}
void LuxMaxParamDlg::InitProgDialog(HWND hWnd) {
}
void LuxMaxParamDlg::AcceptParams() {
rend->FileName = workFileName;
//rend->renderType = rendertype;
rend->halttimewstr = halttimewstr;
rend->LensRadiusstr = std::to_wstring(LensRadiusFloatTmp).c_str();
rend->vbinterval = vbintervalWstr;
rend->defaultlightchk = defaultlightchk;
rend->defaultlightauto = defaultlightauto;
rend->FilterIndexWstr = std::to_wstring(filterIndex).c_str();
rend->FilterXWidthWst = std::to_wstring(filterXvalue).c_str();
rend->FilterYWidthWst = std::to_wstring(filterYvalue).c_str();
rend->RenderTypeWstr = std::to_wstring(rendertype).c_str();
rend->FilterGuassianAlphaWstr = std::to_wstring(filterGuassianAlphavalue).c_str();
rend->FilterMitchellAWstr = std::to_wstring(filterMitchellAvalue).c_str();
rend->FilterMitchellBWstr = std::to_wstring(filterMitchellBvalue).c_str();
rend->LightStrategyIndexWstr = std::to_wstring(lightStrategyIndex).c_str();
rend->MetrolpolisImageMutationRateWstr = std::to_wstring(MetrolpolisImageMutationRatevalue).c_str();
rend->MetropolisLargestEpRateWstr = std::to_wstring(MetropolisLargestEpRatevalue).c_str();
rend->MetropolisMaxConsecutiveRejectWstr = std::to_wstring(MetropolisMaxConsecutiveRejectvalue).c_str();
rend->SamplerIndexWstr = std::to_wstring(samplerIndex).c_str();
rend->enableFileSaverOutoutWstr = std::to_wstring(enableFileSaverOutput).c_str();
}
RendParamDlg * LuxMax::CreateParamDialog(IRendParams *ir, BOOL prog) {
return new LuxMaxParamDlg(this, ir, prog);
}
// File Browse ------------------------------------------------------------
BOOL FileExists(const TCHAR *filename) {
HANDLE findhandle;
WIN32_FIND_DATA file;
findhandle = FindFirstFile(filename, &file);
FindClose(findhandle);
if (findhandle == INVALID_HANDLE_VALUE)
return(FALSE);
else
return(TRUE);
}
BOOL RunningNewShell()
{
//OSVERSIONINFO os;
//os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
//GetVersionEx(&os);
// if (os.dwPlatformId == VER_PLATFORM_WIN32_NT && os.dwMajorVersion < 4)
return FALSE;
//return TRUE;
}
#define FileEXT _T(".png")
#define FileFILTER _T("*.png")
void FixFileExt(OPENFILENAME &ofn, TCHAR* ext = FileEXT) {
int l = static_cast<int>(_tcslen(ofn.lpstrFile)); // SR DCAST64: Downcast to 2G limit.
int e = static_cast<int>(_tcslen(ext)); // SR DCAST64: Downcast to 2G limit.
if (_tcsicmp(ofn.lpstrFile + l - e, ext)) {
_tcscat(ofn.lpstrFile, ext);
}
}
#if 0
UINT_PTR WINAPI FileHook( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
SetDlgItemText(hDlg, IDOK, _T("OK"));
break;
case WM_COMMAND:{
}
break;
}
return FALSE;
}
UINT_PTR PMFileHook(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
SetDlgItemText(hWnd, IDOK, _T("OK"));
break;
case WM_COMMAND:{
}
break;
}
return 0;
}
#endif
BOOL LuxMaxParamDlg::FileBrowse() {
FilterList filterList;
HWND hWnd = hPanel;
static int filterIndex = 1;
OPENFILENAME ofn;
TSTR filename;
TCHAR fname[512];
TCHAR saveDir[1024];
{
TSTR dir;
SplitFilename(workFileName, &dir, &filename, NULL);
_tcscpy(saveDir, dir.data());
}
_tcscpy(fname, filename.data());
_tcscat(fname, FileEXT);
filterList.Append(GetString(IDS_FILE));
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = hInstance;
ofn.nFilterIndex = filterIndex;
ofn.lpstrFilter = filterList;
ofn.lpstrTitle = GetString(IDS_WRITE_FILE);
ofn.lpstrFile = fname;
ofn.nMaxFile = _countof(fname);
Interface *iface = GetCOREInterface();
if (saveDir[0])
ofn.lpstrInitialDir = saveDir;
else
ofn.lpstrInitialDir = iface->GetDir(APP_SCENE_DIR);
if (RunningNewShell()) {
ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING;
ofn.lpfnHook = NULL;
ofn.lCustData = 0; // 0 for save, 1 for open
}
else {
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING;
ofn.lpfnHook = NULL;
ofn.lCustData = 0;
}
FixFileExt(ofn, FileEXT);
while (GetSaveFileName(&ofn)) {
//while ((&ofn)){
FixFileExt(ofn, FileEXT); // add ".vue" if absent
workFileName = ofn.lpstrFile;
return TRUE;
}
return FALSE;
}