-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnit1.pas
8077 lines (7579 loc) · 270 KB
/
Unit1.pas
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
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls,
AppEvnts, Menus, ActnList, ZipForge, CheckLst,
uMD3, uMDM,uMDX, uMDS, uCollapseMap, uMS3D, uMap, uASE,
u3DTypes, uOpenGL, uFont, uQ3Shaders, Buttons, Spin, ImgList;
const
MSG_MD3_LOADED = 'MD3 loaded';
MSG_MDMMDX_LOADED = 'MDM/MDX loaded';
MSG_MDM_LOADED = 'MDM loaded';
MSG_MDX_LOADED = 'MDX loaded';
MSG_MDX_BONES_LOADED = 'MDX bones loaded';
MSG_MDX_FRAMES_LOADED = 'MDX frames loaded';
MSG_MDX_TAGS_LOADED = 'MDX tags loaded';
MSG_MDS_LOADED = 'MDS loaded and converted to MDM/MDX';
MSG_MAP_LOADED = 'MAP loaded and converted to MD3';
MSG_SKIN_LOADED = 'Skin loaded';
MSG_MS3D_LOADED_MD3 = 'MS3D loaded and converted to MD3';
MSG_MS3D_LOADED_MDMMDX = 'MS3D loaded and converted to MDM/MDX';
MSG_ASE_LOADED = 'ASE loaded and converted to MD3';
type
{TLoadedFrom = (lfNone, lfGame, lfPK3, lfFile);} // verplaatst naar unit uQ3Shaders
TLoadedType = (ltNone,
ltMD3, ltMap, ltASE, ltMS3D_MD3,
ltMDMMDX, ltMDS, ltMS3D_MDMMDX,
ltMDC, ltASC, lt3DS, ltOBJ,
ltTag, ltSkin, ltShader);
{
// tbv de PAKs combobox objecten
TStrObject = class(TObject)
public
FullPath,
ShortName,
TmpDir: string;
hasTextures,
hasShaders,
hasModels: boolean;
end;
}
TForm1 = class(TForm)
gbModel: TGroupBox;
OpenDialog: TOpenDialog;
TagOpenDialog: TOpenDialog;
StatusBar: TStatusBar;
pcTabs: TPageControl;
tabGeneral: TTabSheet;
leName: TLabeledEdit;
tabAnimation: TTabSheet;
cbNamesFrames: TComboBox;
leNumFrames: TLabeledEdit;
gbCopyFrames: TGroupBox;
leModelFilename: TLabeledEdit;
bModelFilename: TButton;
tabTags: TTabSheet;
Label1: TLabel;
leNumTags: TLabeledEdit;
cbNamesTags: TComboBox;
cbTagOrigins: TComboBox;
gbInsertTags: TGroupBox;
leTagFilename: TLabeledEdit;
bTagFilename: TButton;
tabSurfaces: TTabSheet;
cbNamesSurfaces: TComboBox;
leNumSurfaces: TLabeledEdit;
cbNamesShaders: TComboBox;
leNumShaders: TLabeledEdit;
tabView: TTabSheet;
gbOGL: TGroupBox;
cbTagAxis: TComboBox;
Label2: TLabel;
gbTagManually: TGroupBox;
leTagOriginX: TLabeledEdit;
leTagOriginY: TLabeledEdit;
leTagOriginZ: TLabeledEdit;
bTagAddManually: TButton;
leTagName: TLabeledEdit;
cbBBMinFrames: TComboBox;
cbBBMaxFrames: TComboBox;
cbOriginFrames: TComboBox;
cbRadiusFrames: TComboBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
leNumVerts: TLabeledEdit;
leNumTriangles: TLabeledEdit;
cbTagFrameNr: TComboBox;
Label9: TLabel;
SaveAsDialog: TSaveDialog;
gbOGLtris: TGroupBox;
ApplicationEvents: TApplicationEvents;
TimerFPS: TTimer;
Shape1: TShape;
Shape4: TShape;
shapeShaderFile: TShape;
MainMenu: TMainMenu;
menuFile: TMenuItem;
menuFileLoad: TMenuItem;
menuFileSave: TMenuItem;
menuFileExit: TMenuItem;
menuModel: TMenuItem;
menuModelClear: TMenuItem;
menuModelAnimation: TMenuItem;
menuModelTags: TMenuItem;
menuModelSurfaces: TMenuItem;
menuModelSurfacesChangeshadername: TMenuItem;
menuView: TMenuItem;
menuViewLighting: TMenuItem;
menuSettings: TMenuItem;
N2: TMenuItem;
menuModelSurfacesChangesurfacename: TMenuItem;
menuSettingsGamedir: TMenuItem;
gbSettings: TGroupBox;
cbLightingEnabled: TCheckBox;
gbShaderFile: TGroupBox;
Label14: TLabel;
cbShaderFile: TComboBox;
menuFileLoadfrompk3: TMenuItem;
gbTextures: TGroupBox;
Label12: TLabel;
lNumTextures: TLabel;
cbShaderTextures: TComboBox;
Zip: TZipForge;
gbSkin: TGroupBox;
leSkinFile: TLabeledEdit;
SkinOpenDialog: TOpenDialog;
N4: TMenuItem;
menuFileSkin: TMenuItem;
menuFileSkinLoad: TMenuItem;
menuFileSkinLoadfrompk3: TMenuItem;
menuModelSkinClear: TMenuItem;
N5: TMenuItem;
shapeShaderTexture: TShape;
shapeSkinTexture: TShape;
shapeSkinFile: TLabel;
shapeShaderFileOut: TLabel;
shapeShaderFileIn: TLabel;
shapeTextureFile: TShape;
shapeSkinShader: TShape;
leSkin: TLabeledEdit;
cbShowTags: TCheckBox;
menuViewShowtags: TMenuItem;
cbHasAlpha: TCheckBox;
pShaderProps: TPanel;
leCull: TLabeledEdit;
cbAlphaFunc: TCheckBox;
cbEnvironmentMap: TCheckBox;
cbClamped: TCheckBox;
Panel1: TPanel;
Panel2: TPanel;
gbAnimationControls: TGroupBox;
Panel3: TPanel;
gbViewOptions: TGroupBox;
cbTagPivots: TComboBox;
ShaderOpenDialog: TOpenDialog;
N6: TMenuItem;
menuFileShaderlist: TMenuItem;
menuFileShaderlistAdd: TMenuItem;
menuFileShaderlistClear: TMenuItem;
menuHelp: TMenuItem;
menuFileLoadfrommappk3: TMenuItem;
tabHelp: TTabSheet;
MemoHelp: TMemo;
menuViewGammaSW: TMenuItem;
menuViewGammaSW1: TMenuItem;
menuViewGammaSW1_5: TMenuItem;
menuViewGammaSW2: TMenuItem;
menuViewGammaSW2_5: TMenuItem;
menuViewGammaSW3: TMenuItem;
menuViewGammaSW3_5: TMenuItem;
menuViewGammaSW4: TMenuItem;
menuViewGammaSW4_5: TMenuItem;
menuViewGammaSW5: TMenuItem;
gbShaderList: TGroupBox;
Label7: TLabel;
cbShaderList: TComboBox;
Label10: TLabel;
N9: TMenuItem;
N3: TMenuItem;
cbShaderNameFound: TComboBox;
Label11: TLabel;
shapeSkinShaderlist: TShape;
shapeShaderlistIn: TLabel;
shapeShaderlistOut: TLabel;
shapeShaderlistShader: TShape;
shapeShaderlistTexture: TShape;
shapeShaderlist: TShape;
img3DView: TImage;
Label13: TLabel;
Label18: TLabel;
Label19: TLabel;
cbAnimMap: TCheckBox;
Label20: TLabel;
Label21: TLabel;
cbVideoMap: TCheckBox;
shapeSurfaceShader: TShape;
leSurfaceFlags: TLabeledEdit;
gbHeader: TGroupBox;
leHeaderFlags: TLabeledEdit;
leHeaderIdent: TLabeledEdit;
leVersion: TLabeledEdit;
leHeaderName: TLabeledEdit;
menuModelAnimationAddframe: TMenuItem;
cbCleanUp: TCheckBox;
ActionList: TActionList;
actionViewLighting: TAction;
actionModelClear: TAction;
actionFileLoadfrompk3: TAction;
actionFileLoad: TAction;
actionFileSaveAs: TAction;
actionFileExit: TAction;
actionSettingsGamedir: TAction;
actionFileSelectSkin: TAction;
actionFileClearSkin: TAction;
actionFileSelectSkinfrompk3: TAction;
actionViewShowtags: TAction;
actionFileAddtoshaderlist: TAction;
actionFileClearshaderlist: TAction;
actionHelp: TAction;
actionFileLoadfrommappk3: TAction;
actionFileAddframe: TAction;
actionModelDeleteframe: TAction;
menuModelAnimationDelframe: TMenuItem;
N7: TMenuItem;
menuFileLoadfromgameMDMMDX: TMenuItem;
TabBones: TTabSheet;
tvBones: TTreeView;
actionModelMDMMDXframesToMD3: TAction;
menuFileExportFramesrangeToMD3: TMenuItem;
cbShowSkeleton: TCheckBox;
actionFileLoadfromgameMDMMDX: TAction;
actionFileLoadMDMMDX: TAction;
menuFileLoadMDMMDX: TMenuItem;
MDMOpenDialog: TOpenDialog;
MDXOpenDialog: TOpenDialog;
MDSOpenDialog: TOpenDialog;
actionFileLoadMDS: TAction;
menuFileLoadMDS: TMenuItem;
N11: TMenuItem;
bSelectSkinfrompk3: TBitBtn;
bSelectSkin: TBitBtn;
bClearSkin: TBitBtn;
bSelectShaderFile: TBitBtn;
bClearShaderList: TBitBtn;
bAddGamePAK: TBitBtn;
Label22: TLabel;
actionModelMDMMDXCalculateLOD: TAction;
menuModelCalcLOD: TMenuItem;
Panel4: TPanel;
gbLOD: TGroupBox;
cbLODEnabled: TCheckBox;
tbLODMinimum: TTrackBar;
Label23: TLabel;
seLODSurfaceNr: TSpinEdit;
Label24: TLabel;
Panel5: TPanel;
Panel6: TPanel;
Panel7: TPanel;
Label15: TLabel;
Label16: TLabel;
tbStartFrame: TTrackBar;
tbCurrentFrame: TTrackBar;
tbEndFrame: TTrackBar;
lEndFrame: TLabel;
lCurrentFrame: TLabel;
lStartFrame: TLabel;
cbPlay: TCheckBox;
cbLoop: TCheckBox;
Label17: TLabel;
eFPS: TEdit;
udFPS: TUpDown;
tLODpresence: TLabel;
N12: TMenuItem;
menuModelAnimationAddframesSequence: TMenuItem;
cbAnimName: TComboBox;
tLODSurfacename: TLabel;
actionModelMDMMDXScaleBones: TAction;
menuModelScaleskeleton: TMenuItem;
menuViewSkycolors: TMenuItem;
menuViewShowskybox: TMenuItem;
menuViewSkycolortop: TMenuItem;
menuViewSkycolorbottom: TMenuItem;
ImageList: TImageList;
ColorDialog: TColorDialog;
actionFileAddframesequence: TAction;
OpenDialogMD3s: TOpenDialog;
menuTexturing: TMenuItem;
MDXSaveDialog: TSaveDialog;
actionFileLoadMDX: TAction;
menuFileLoadMDX: TMenuItem;
actionModelMD3Scale: TAction;
menuModelScalemd3: TMenuItem;
actionFileLoadMDXbones: TAction;
menuFileLoadMDXbones: TMenuItem;
actionModelSkinpermanent: TAction;
menuSkinToModel: TMenuItem;
N1: TMenuItem;
actionModelMDMMDXRenameBones: TAction;
menuModelBones: TMenuItem;
menuModelBonesDefaultNames: TMenuItem;
actionFileLoadMDMtags: TAction;
menuFileLoadMDMtags: TMenuItem;
actionFileLoadMDXframes: TAction;
menuFileLoadMDXframes: TMenuItem;
MS3DOpenDialog: TOpenDialog;
actionFileLoadMS3D: TAction;
N8: TMenuItem;
menuFileLoadMS3D: TMenuItem;
N15: TMenuItem;
actionFileAddframes: TAction;
menuModelAnimationAddframes: TMenuItem;
cbLockView: TCheckBox;
bPrtScr: TButton;
menuTools: TMenuItem;
menuToolsColorconvert: TMenuItem;
menuToolsColorconvertRadiant: TMenuItem;
actionFileImportMapAsMD3: TAction;
menuFileImportMapAsMD3: TMenuItem;
MapOpenDialog: TOpenDialog;
N14: TMenuItem;
menuFileLoadAnyFromGame: TMenuItem;
menuFileLoadAnyFromPK3: TMenuItem;
menuFileLoadAnyFromFile: TMenuItem;
OpenDialogAnyFromFile: TOpenDialog;
actionFileLoadAnyFromFile: TAction;
cbAlphaPreview: TCheckBox;
leTextureDimensions: TLabeledEdit;
actionViewShowalphapreview: TAction;
menuViewShowAlphapreview: TMenuItem;
actionViewShowskeleton: TAction;
menuViewShowskeleton: TMenuItem;
actionSettingsCleanup: TAction;
menuSettingsCleanup: TMenuItem;
menuModelTagsInvertX: TMenuItem;
menuModelTagsInvertY: TMenuItem;
menuModelTagsInvertZ: TMenuItem;
menuModelTagsSwapXY: TMenuItem;
menuModelTagsSwapXZ: TMenuItem;
menuModelTagsSwapYZ: TMenuItem;
cbCenterModel: TCheckBox;
N16: TMenuItem;
actionFileSaveMDX: TAction;
actionFileSaveMDM: TAction;
Label26: TLabel;
N17: TMenuItem;
menuModelMD3FlipZ: TMenuItem;
N19: TMenuItem;
actionModelMD3FlipZ: TAction;
actionModelMD3FlipNormals: TAction;
menuModelMD3FlipNormals: TMenuItem;
actionModelMD3FlipX: TAction;
actionModelMD3FlipY: TAction;
menuModelMD3FlipX: TMenuItem;
menuModelMD3FlipY: TMenuItem;
cbShowNormals: TCheckBox;
actionModelMD3FixCracksGaps: TAction;
actionModelMD3SmoothSurface: TAction;
N20: TMenuItem;
menuModelMD3Fixcracksgaps: TMenuItem;
menuModelSmoothSurface: TMenuItem;
actionModelMD3TagAsOrigin: TAction;
menuModelMD3TagAsOrigin: TMenuItem;
actionViewCenterModel: TAction;
menuViewCenterModel: TMenuItem;
actionModelMD3RotateX: TAction;
actionModelMD3RotateY: TAction;
actionModelMD3RotateZ: TAction;
menuModelRotateX: TMenuItem;
menuModelRotateY: TMenuItem;
menuModelRotateZ: TMenuItem;
N22: TMenuItem;
gbTagSave: TGroupBox;
bSaveTags: TButton;
actionModelMD3FlipWinding: TAction;
menuModelMD3FlipWinding: TMenuItem;
cbWireframe: TCheckBox;
actionViewWireframe: TAction;
cbTwoSided: TCheckBox;
actionViewTwoSided: TAction;
cbSmoothFlat: TCheckBox;
actionViewSmoothFlat: TAction;
actionFileLoadASE: TAction;
menuFileLoadASE: TMenuItem;
ASEOpenDialog: TOpenDialog;
cbMouseControl: TCheckBox;
actionViewMouseControl: TAction;
menuViewWireFrame: TMenuItem;
menuViewTwoSided: TMenuItem;
menuViewFlatShading: TMenuItem;
menuViewMouseControl: TMenuItem;
N10: TMenuItem;
TimerOGLFPS: TTimer;
cbPAKsList: TComboBox;
Label25: TLabel;
PK3OpenDialog: TOpenDialog;
bDelGamePAK: TBitBtn;
actionModelCalculateNormals: TAction;
menuModelCalcNormals: TMenuItem;
actionModelMDMMDXSmoothSurface: TAction;
Label27: TLabel;
Label28: TLabel;
eTagAxis0X: TEdit;
eTagAxis0Z: TEdit;
eTagAxis0Y: TEdit;
eTagAxis1Z: TEdit;
eTagAxis1Y: TEdit;
eTagAxis1X: TEdit;
eTagAxis2Z: TEdit;
eTagAxis2Y: TEdit;
eTagAxis2X: TEdit;
cbShowGroundplane: TCheckBox;
cbShowAxis: TCheckBox;
menuViewShowNormals: TMenuItem;
menuViewShowGroundplane: TMenuItem;
menuViewShowAxis: TMenuItem;
actionViewGroundplane: TAction;
actionViewAxis: TAction;
menuModelSurfacesSwapUVST: TMenuItem;
N13: TMenuItem;
actionModelMD3SwapUVST: TAction;
actionModelMD3RemoveSurface: TAction;
menumodelsurfaceRemove: TMenuItem;
menuModelSurfacesCompact: TMenuItem;
actionModelMD3SurfacesCompact: TAction;
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormDestroy(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure TimerFPSTimer(Sender: TObject);
procedure cbNamesSurfacesChange(Sender: TObject);
procedure bTagFilenameClick(Sender: TObject);
procedure cbNamesTagsSelect(Sender: TObject);
procedure cbTagOriginsSelect(Sender: TObject);
procedure cbNamesShadersKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure cbTagAxisSelect(Sender: TObject);
procedure bTagAddManuallyClick(Sender: TObject);
procedure cbNamesFramesSelect(Sender: TObject);
procedure cbBBMinFramesSelect(Sender: TObject);
procedure cbBBMaxFramesSelect(Sender: TObject);
procedure cbOriginFramesSelect(Sender: TObject);
procedure cbRadiusFramesSelect(Sender: TObject);
procedure cbTagFrameNrSelect(Sender: TObject);
procedure gbOGLMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure tbStartFrameChange(Sender: TObject);
procedure tbEndFrameChange(Sender: TObject);
procedure eFPSChange(Sender: TObject);
procedure tbCurrentFrameChange(Sender: TObject);
procedure pcTabsChange(Sender: TObject);
procedure actionViewLightingExecute(Sender: TObject);
procedure actionModelClearExecute(Sender: TObject);
procedure actionFileLoadExecute(Sender: TObject);
procedure actionFileSaveAsExecute(Sender: TObject);
procedure actionFileExitExecute(Sender: TObject);
procedure actionSettingsGamedirExecute(Sender: TObject);
procedure actionFileLoadfrompk3Execute(Sender: TObject);
procedure actionFileSelectSkinExecute(Sender: TObject);
procedure actionFileClearSkinExecute(Sender: TObject);
procedure actionFileSelectSkinfrompk3Execute(Sender: TObject);
procedure actionViewShowtagsExecute(Sender: TObject);
procedure cbShaderTexturesChange(Sender: TObject);
procedure gbOGLDblClick(Sender: TObject);
procedure cbTagPivotsChange(Sender: TObject);
procedure actionFileAddtoshaderlistExecute(Sender: TObject);
procedure actionFileClearshaderlistExecute(Sender: TObject);
procedure actionFileLoadfrommappk3Execute(Sender: TObject);
procedure actionHelpExecute(Sender: TObject);
procedure MemoHelpClick(Sender: TObject);
procedure menuViewGammaSW1Click(Sender: TObject);
procedure menuViewGammaSW1_5Click(Sender: TObject);
procedure menuViewGammaSW2Click(Sender: TObject);
procedure menuViewGammaSW2_5Click(Sender: TObject);
procedure menuViewGammaSW3Click(Sender: TObject);
procedure menuViewGammaSW3_5Click(Sender: TObject);
procedure menuViewGammaSW4Click(Sender: TObject);
procedure menuViewGammaSW4_5Click(Sender: TObject);
procedure menuViewGammaSW5Click(Sender: TObject);
procedure actionFileAddframeExecute(Sender: TObject);
procedure actionModelDeleteframeExecute(Sender: TObject);
procedure ApplicationEventsActivate(Sender: TObject);
procedure actionFileLoadfromgameMDMMDXExecute(Sender: TObject);
procedure actionModelMDMMDXframesToMD3Execute(Sender: TObject);
procedure actionFileLoadMDMMDXExecute(Sender: TObject);
procedure actionFileLoadMDSExecute(Sender: TObject);
procedure tbLODMinimumChange(Sender: TObject);
procedure actionModelMDMMDXCalculateLODExecute(Sender: TObject);
procedure cbLODEnabledClick(Sender: TObject);
procedure cbAnimNameChange(Sender: TObject);
procedure seLODSurfaceNrChange(Sender: TObject);
procedure actionModelMDMMDXScaleBonesExecute(Sender: TObject);
procedure menuViewShowskyboxClick(Sender: TObject);
procedure menuViewSkycolortopAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
procedure menuViewSkycolorbottomAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
procedure menuViewSkycolortopClick(Sender: TObject);
procedure menuViewSkycolorbottomClick(Sender: TObject);
procedure menuToolsColorconvertRadiantAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
procedure menuToolsColorconvertRadiantClick(Sender: TObject);
procedure actionFileAddframesequenceExecute(Sender: TObject);
procedure actionFileLoadMDXExecute(Sender: TObject);
procedure actionModelMD3ScaleExecute(Sender: TObject);
procedure actionFileLoadMDXbonesExecute(Sender: TObject);
procedure actionModelSkinpermanentExecute(Sender: TObject);
procedure actionModelMDMMDXRenameBonesExecute(Sender: TObject);
procedure actionFileLoadMDMtagsExecute(Sender: TObject);
procedure actionFileLoadMDXframesExecute(Sender: TObject);
procedure actionFileLoadMS3DExecute(Sender: TObject);
procedure actionFileAddframesExecute(Sender: TObject);
procedure bPrtScrClick(Sender: TObject);
procedure actionFileImportMapAsMD3Execute(Sender: TObject);
procedure cbPlayClick(Sender: TObject);
procedure actionFileLoadAnyFromFileExecute(Sender: TObject);
procedure actionViewShowalphapreviewExecute(Sender: TObject);
procedure actionViewShowskeletonExecute(Sender: TObject);
procedure actionSettingsCleanupExecute(Sender: TObject);
procedure menuModelTagsInvertXClick(Sender: TObject);
procedure menuModelTagsInvertYClick(Sender: TObject);
procedure menuModelTagsInvertZClick(Sender: TObject);
procedure menuModelTagsSwapXYClick(Sender: TObject);
procedure menuModelTagsSwapXZClick(Sender: TObject);
procedure menuModelTagsSwapYZClick(Sender: TObject);
procedure actionFileSaveMDXExecute(Sender: TObject);
procedure actionFileSaveMDMExecute(Sender: TObject);
procedure lStartFrameDblClick(Sender: TObject);
procedure lEndFrameDblClick(Sender: TObject);
procedure lCurrentFrameDblClick(Sender: TObject);
procedure actionModelMD3FlipZExecute(Sender: TObject);
procedure actionModelMD3FlipNormalsExecute(Sender: TObject);
procedure actionModelMD3FlipXExecute(Sender: TObject);
procedure actionModelMD3FlipYExecute(Sender: TObject);
procedure actionModelMD3FixCracksGapsExecute(Sender: TObject);
procedure actionModelMD3SmoothSurfaceExecute(Sender: TObject);
procedure actionModelMD3TagAsOriginExecute(Sender: TObject);
procedure actionViewCenterModelExecute(Sender: TObject);
procedure actionModelMD3RotateXExecute(Sender: TObject);
procedure actionModelMD3RotateYExecute(Sender: TObject);
procedure actionModelMD3RotateZExecute(Sender: TObject);
procedure bSaveTagsClick(Sender: TObject);
procedure actionModelMD3FlipWindingExecute(Sender: TObject);
procedure actionViewWireframeExecute(Sender: TObject);
procedure actionViewTwoSidedExecute(Sender: TObject);
procedure actionViewSmoothFlatExecute(Sender: TObject);
procedure actionFileLoadASEExecute(Sender: TObject);
procedure cbNamesSurfacesSelect(Sender: TObject);
procedure cbNamesSurfacesKeyDown(Sender:TObject; var Key:Word; Shift:TShiftState);
procedure actionViewMouseControlExecute(Sender: TObject);
procedure TimerOGLFPSTimer(Sender: TObject);
procedure bAddGamePAKClick(Sender: TObject);
procedure cbPAKsListSelect(Sender: TObject);
procedure bDelGamePAKClick(Sender: TObject);
procedure actionModelCalculateNormalsExecute(Sender: TObject);
procedure actionModelMDMMDXSmoothSurfaceExecute(Sender: TObject);
procedure menuModelSmoothSurfaceClick(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure actionViewGroundplaneExecute(Sender: TObject);
procedure actionViewAxisExecute(Sender: TObject);
procedure actionModelMD3SwapUVSTExecute(Sender: TObject);
procedure actionModelMD3RemoveSurfaceExecute(Sender: TObject);
procedure actionModelMD3SurfacesCompactExecute(Sender: TObject);
(*
protected
procedure CreateParams(var Params: TCreateParams); override;
*)
private
TotalGameShaders, //totaal aantal shaders in alle shaderfiles in gamedir/etmain/scripts
TotalGameShaderFiles: integer; //totaal aantal shaderfiles in gamedir/etmain/scripts
ShaderResource: TTextureResource;
LastX, LastY: Integer; //vorige muiscursor-positie
DeltaX, DeltaY, DeltaZ: Single; //laatste verschillen in cursor-positie.
Model_Matrix: TMatrix4x4;
Model_Rotation, //verdraaid goed..
Model_Position, //op de plaats rust..
Model_Offset: TVector; //pivot-offset
Current_Frame: integer;
ZoomDistance: integer;
{ OGL: TOGL; // tab view}
MaxTU: integer;
Gamma: Single;
CenterX,CenterY,CenterZ: Single;
SkyColorTop, SkyColorBottom, ConvertColor: TColor;
ModelIsScaled: boolean;
HeadModel: TMD3;
TakingScreenshot,
InterruptPlayback,
IsDragDropped: boolean;
tmpSurfaceIndex: integer;
//
procedure WMEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;
//
procedure OGL_MDMMDX_RenderFrame;
procedure OGL_MD3_RenderFrame;
procedure OGL_RenderFrame;
procedure OGL_CreateTextures;
procedure InitLighting;
procedure DeleteTextures;
//
function DelTree(DirName : string): Boolean;
procedure SetHWGamma(Gamma: Single);
//
procedure SetupAnimation;
procedure ResetModelTransform;
procedure AutoZoom;
//
procedure ClearGameShaders;
procedure LoadGameShaders;
procedure ClearMapShaders;
procedure LoadMapShaders;
procedure ClearShaderListShaders;
procedure LoadShaderListShaders;
function FindShaders(const ShaderResource: TTextureResource; const sIndex: integer) : boolean;
procedure LoadSkinFile(Filename:string; DoUpdateShaders:boolean=true);
procedure UpdateShaders;
procedure UpdateGamma;
//
procedure ClearMD3Info;
procedure ShowMD3HeaderInfo;
procedure ShowMD3FramesInfo;
procedure ShowMD3TagsInfo;
procedure ShowMD3SurfacesInfo;
procedure ShowMD3Info;
procedure TagPivotMD3;
//
procedure ClearMDMMDXInfo;
procedure ShowMDMMDXBoneInfo;
procedure ShowMDMMDXTagsInfo;
procedure ShowMDMMDXSurfaceInfo;
procedure ShowMDMMDXInfo;
procedure TagPivotMDMMDX;
//
procedure SurfaceToForm(Index: integer); //Index in cbNamesSurfaces
procedure TextureToForm(SurfaceIndex, TextureIndex: integer);
procedure ShaderToTextureGraph(const Value: TTextureResource); //Value="Texture komt uit": shader-, texture- of skin-file
procedure TextureToImg(SurfaceIndex, TextureIndex: integer);
procedure Screenshot(TransparentBackground:boolean);
procedure SetGameDir(const Path: string);
procedure ReadINI;
procedure WriteINI;
procedure ShowHelp;
procedure HideHelp;
procedure ShowTabsNone;
procedure ShowTabsMD3;
procedure ShowTabsMDMMDX;
procedure ShowMenuNone;
procedure ShowMenuMD3;
procedure ShowMenuMDMMDX;
procedure ShowNone;
//
procedure LoadHeadModel;
//
function AddPAK(Filename:string) : integer;
function DeletePAK(Index:integer) : boolean;
procedure DeletePAKsList;
public
LoadedFrom: TLoadedFrom; //(lfGame, lfPK3, lfFile)
LoadedType: TLoadedType; //(ltMD3, ltMDMMDX, ltMS3D, ltMDS, ltMDC, ltASE, ltASC, lt3DS, ltOBJ)
AppPath, //pad naar App.exe
GameDir, //pad naar game-directory
TmpDir, //pad naar temp. dir.
ModelDir: string; //pad naar laatst geladen model
{PAKsList: array of TStrObject;}
procedure AcceptFiles(var msg:TMessage); message WM_DROPFILES;
function FileInUse(FileName: string): Boolean;
end;
var
Form1: TForm1;
(*
//test
procedure SaveData(SurfaceNr:integer; Filename:string);
*)
implementation
uses uConst, uCalc, OpenGL, uTexture,
StrUtils, FileCtrl, ShellAPI, IniFiles, Math,
Unit2;
{$R *.dfm}
(*
procedure TForm1.CreateParams(var Params: TCreateParams);
// CS_DROPSHADOW = $00020000;
var Mask: cardinal;
begin
inherited;
Mask := (CS_DROPSHADOW xor $FFFFFFFF);
Params.WindowClass.Style := (Params.WindowClass.Style and Mask);
end;
*)
procedure TForm1.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := 1; //form achtergrond paint-event als "klaar" markeren..
end;
procedure TForm1.FormCreate(Sender: TObject);
var sa: SECURITY_ATTRIBUTES;
s: PAnsiChar;
gp: integer;
//hprocessID, processHandle: cardinal;
begin
//GetWindowThreadProcessID(Form1.Handle, @hprocessID);
//processHandle := OpenProcess({PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION}PROCESS_SET_INFORMATION, false, hprocessID);
//SetProcessAffinityMask(processHandle, 2);
// objecten
HeadModel := TMD3.Create;
//
DecimalSeparator := '.';
Application.ShowHint := true;
AppPath := ExtractFilePath(Application.ExeName);
// controleer of de app. wel is geïnstalleerd in zijn eigen directory
if not DirectoryExists(AppPath+'textures') then begin
ShowMessage('This application is not installed correctly.'#13#10'Copy the .exe and the subdirectory "textures" into its own directory');
PostQuitMessage(1);
end;
//
GameDir := '';
ModelDir := '';
// een tijdelijke dir. maken tbv. unzippen pk3's
s := PChar(AppPath +'tmp\');
if not DirectoryExists(s) then begin
sa.nLength := SizeOf(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor := nil;
sa.bInheritHandle := false;
CreateDirectory(s,@sa);
end;
TmpDir := string(s);
Zip.TempDir := TmpDir;
(*
DelTree(TmpDir);
*)
// een tijdelijke map maken tbv. unzippen map.pk3's
s := PChar(AppPath +'tmp\tmpmap');
if not DirectoryExists(s) then begin
sa.nLength := SizeOf(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor := nil;
sa.bInheritHandle := false;
Createdirectory(s,@sa);
end;
Gamma := 1.0; //[0.0 .. maxfloat]
SkyColorTop := $00CB8B64; //clHotLight;
SkyColorBottom := $00F0CAA6; //clSkyBlue;
// INI lezen
ReadINI;
// controleer of de pak0.pk3 al in gebruik is, zoja: afbreken..
// if GameDir<>'' then
for gp:=0 to Length(PAKsList)-1 do
// if FileInUse(GameDir+'etmain\pak0.pk3') then begin
if FileInUse(PAKsList[gp].FullPath) then begin
ShowMessage('The game-files are already in use by another application.'#13#10'This tool will halt..');
{Assert(false);}
Application.Terminate;
PostQuitMessage(1);
Exit;
end;
ConvertColor := $00000000;
{ gbOGLtris.Color := Form1.Color; //$00E3DFE0;}
// een tijdelijke dir. maken tbv. unzippen game-pack's
for gp:=0 to Length(PAKsList)-1 do begin
s := PChar(PAKsList[gp].TmpDir);
if not DirectoryExists(s) then begin
sa.nLength := SizeOf(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor := nil;
sa.bInheritHandle := false;
CreateDirectory(s,@sa);
end;
end;
// SendMessage(tbStartFrame.Handle, PBM_SETBARCOLOR, 0, clBlue);
// tell Windows that you're accepting drag and drop files
DragAcceptFiles(Handle, True);
// tbv. tijdelijke onderbrekingen, zoals tijdens laden, afbeelden dialogs..
InterruptPlayback := false;
// de timer
TimerFPS.Interval := Round(1/20*1000);
//
LoadedFrom := lfNone;
LoadedType := ltNone;
ModelIsScaled := false;
// de shaderlist
LoadShaderListShaders;
//
Current_Frame := 0;
ZoomDistance := 500;
Model_Matrix := IdentityMatrix4x4;
Model_Rotation := NullVector;
Model_Position := NullVector;
Model_Offset := NullVector;
//
tabGeneral.TabVisible := false;
tabAnimation.TabVisible := false;
tabTags.TabVisible := false;
tabSurfaces.TabVisible := false;
gbCopyFrames.Visible := false;
{!!!!!DEBUG!!!!!
gbInsertTags.Visible := false;}
gbInsertTags.Visible := true;
//bTagFilename.Enabled := false; //vooralsnog geen tags toevoegen uit een .tag-bestand..
tbCurrentFrame.SelEnd := tbEndFrame.Position;
ShaderToTextureGraph(trNone);
menuViewSkycolors.Enabled := not menuViewShowskybox.Checked;
ShowNone;
// OpenGL objects
{ OGL := TOGL.Create; // tab view}
OGL.Textures.AddSearchDir(AppPath +'textures\BG\');
OGL.Textures.AddSearchDir(AppPath +'textures\');
OGL.Textures.AddSearchDir(AppPath);
OGL.Textures.AddSearchDir(TmpDir);
// de standaard camera gebruiken
OGL.Camera.Default;
OGL.Camera.Floating := false;
//OGL.Camera.SetPositionY(20.0);
{ // hoofd model laden..
LoadHeadModel;}
end;
procedure TForm1.FormShow(Sender: TObject);
begin
// OpenGL objects
if not OGL.Active then begin
OGL.Enable(gbOGL.Handle);
MaxTU := OGL.GetMaxTextureUnits;
// de camera wat bewegen, anders kan de speler niet rondsturen..
OGL.Camera.Position := Vector(0,0,ZoomDistance);
OGL.Camera.Target := Vector(0,0,0);
OGL.Camera.Move(0.00001);
OGL.Camera.Target := Vector(0,0,0); //inzoom bugfix
// Vertical retrace aan
// OGL.SetVSync(true);
// SkyBox
{OGL.SkyBox.Active := OGL.SkyBox.InitTextures('Terra');}
{OGL.SkyBox.Active := OGL.SkyBox.InitTextures('sky2');}
OGL.SkyBox.Active := OGL.SkyBox.InitTextures('sky');
OGL.SkyBox.Active := menuViewShowskybox.Checked;
InitLighting;
// form bijwerken
if GameDir<>'' then begin
SetGameDir(GameDir);
HideHelp;
end else begin
actionSettingsGamedirExecute(nil);
ShowHelp;
end;
actionFileLoadfrompk3.Enabled := (GameDir<>'');
actionFileSelectSkinfrompk3.Enabled := (GameDir<>'');
// een beeld tekenen
OGL_RenderFrame;
end;
end;
procedure TForm1.ApplicationEventsActivate(Sender: TObject);
begin
if Application.Terminated then Exit;
{if not cbPlay.Checked then} OGL_RenderFrame;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
// OpenGL projectie
OGL.Resize(gbOGL.Width, gbOGL.Height);
// frame renderen
if OGL.Active then begin
//InitLighting;
OGL_RenderFrame;
end;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
// INI schrijven
WriteINI;
// OpenGL uitschakelen
if OGL.Active then OGL.Disable;
(*
// wis de TmpDir
if cbCleanUp.Checked then begin
StatusBar.SimpleText := 'Cleaning-up... Please wait';
{ pcTabs.ActivePage := TabHelp;
MemoHelp.Lines.Clear;
MemoHelp.Lines.Add('Cleaning-up... Please wait');}
if DelTree(TmpDir) then RemoveDir(TmpDir);
end;
*)
// objecten
HeadModel.Free;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
// OpenGL objects
{ OGL.Free;}
// shaders verwijderen
ClearGameShaders;
ClearMapShaders;
ClearShaderListShaders;
// GAME-PAK referenties verwijderen
DeletePAKsList;
end;
procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
if (MousePos.X>gbOGL.ClientOrigin.X) and (MousePos.X<gbOGL.ClientOrigin.X+gbOGL.Width) and
(MousePos.Y>gbOGL.ClientOrigin.Y) and (MousePos.Y<gbOGL.ClientOrigin.Y+gbOGL.Height) then begin
if pcTabs.ActivePage <> tabView then Exit;
if cbLockView.Checked then Exit;
if ZoomDistance>=5000 then Exit;
Inc(ZoomDistance, 5);
OGL.Camera.Position := Vector(0,0,ZoomDistance);
OGL_RenderFrame;
Handled := true;
end;
end;
procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
if (MousePos.X>gbOGL.ClientOrigin.X) and (MousePos.X<gbOGL.ClientOrigin.X+gbOGL.Width) and
(MousePos.Y>gbOGL.ClientOrigin.Y) and (MousePos.Y<gbOGL.ClientOrigin.Y+gbOGL.Height) then begin
if pcTabs.ActivePage <> tabView then Exit;
if cbLockView.Checked then Exit;
if ZoomDistance<=10 then Exit;
Dec(ZoomDistance, 5);
OGL.Camera.Position := Vector(0,0,ZoomDistance);
OGL_RenderFrame;
Handled := true;
end;
end;
procedure TForm1.gbOGLMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
var vX,vY: TVector;
M1,M2,M3: TMatrix4x4;
Q1,Q2: TQuaternion;
Axis: TVector;
Angle: single;
begin
if pcTabs.ActivePage <> tabView then Exit;
if cbLockView.Checked then Exit;
DeltaX := (X - LastX)*2;
DeltaY := (Y - LastY)*2;
// rekening houden met de bewegings-gevoeligheid
DeltaX := DeltaX * OGL.Camera.SensitivityX;
DeltaY := DeltaY * OGL.Camera.SensitivityY;
// muisknoppen controleren
if (ssLeft in Shift) then begin
// transleren of roteren??
if (ssShift in Shift) then begin
// schuiven
vX := SubVector(OGL.Camera.NextStrafe_Position(-DeltaX), OGL.Camera.Position);
vY := SubVector(OGL.Camera.NextStrafeUpDown_Position(-DeltaY), OGL.Camera.Position);
Model_Position := AddVector(Model_Position, vX);
Model_Position := AddVector(Model_Position, vY);
end else
if (ssCtrl in Shift) then begin
// roteer de camera rond om zijn target
OGL.Camera.RotateAboutTarget(Vector(DeltaY, DeltaX, 0.0));
// Model_Offset := AddVector(Model_Offset, Vector(DeltaX, DeltaY, 0.0));
end else begin
// roteer model
// control type 2
M1 := MultiplyMatrix(MultiplyMatrix(XRotationMatrix(-DeltaY),YRotationMatrix(-DeltaX)),ZRotationMatrix(0));
Model_Matrix := MultiplyMatrix(Model_Matrix, M1);
// control type 1
Model_Rotation := AddVector(Model_Rotation, Vector(DeltaY, DeltaX, 0.0));
//
OGL.Camera.Target := Vector(0,0,0);
end;
end else
if (ssRight in Shift) then begin
// roteer model
// control type 2
M1 := MultiplyMatrix(MultiplyMatrix(XRotationMatrix(DeltaX),YRotationMatrix(0)),ZRotationMatrix(-DeltaY));
Model_Matrix := MultiplyMatrix(M1,Model_Matrix);
// control type 1