-
Notifications
You must be signed in to change notification settings - Fork 5
/
exp_ExportFlatTexture.inc
76 lines (65 loc) · 2.11 KB
/
exp_ExportFlatTexture.inc
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
procedure ExportFlatTexture;
var
ii, xx, yy: integer;
begin
// Create Palette
for ii := 0 to 255 do
begin
r := options.palette[3 * ii];
if r > 255 then r := 255;
g := options.palette[3 * ii + 1];
if g > 255 then g := 255;
b := options.palette[3 * ii + 2];
if b > 255 then b := 255;
def_palL[ii] := (r shl 16) + (g shl 8) + (b);
end;
if options.flags and ETF_TRUECOLORFLAT <> 0 then
begin
// Create flat - 32 bit color - inside HI_START - HI_END namespace
png := TPngObject.Create;
png.Assign(t.Texture);
ms := TMemoryStream.Create;
png.SaveToStream(ms);
wadwriter.AddSeparator('HI_START');
wadwriter.AddData(options.levelname + 'TER', ms.Memory, ms.Size);
wadwriter.AddSeparator('HI_END');
if options.engine = ENGINE_VAVOOM then
begin
wadwriter.AddString('TEXTURES',
'flat ' + options.levelname + 'TER,' + IntToStr(png.Width) + ',' + IntToStr(png.Height) + #13#10 +
'{' + #13#10 +
' XScale 1.0' + #13#10 +
' YScale 1.0' + #13#10 +
' Patch ' + options.levelname + 'TER, 0, 0' + #13#10 +
'}' + #13#10
);
end;
ms.Free;
png.Free;
end;
// Create flat - 8 bit
bm := t.Texture;
GetMem(flattexture, bm.Width * bm.Height);
ii := 0;
for yy := 0 to t.texturesize - 1 do
begin
scanline := t.Texture.ScanLine[yy];
for xx := 0 to t.texturesize - 1 do
begin
c := scanline[xx];
flattexture[ii] := V_FindAproxColorIndex(@def_palL, c);
inc(ii);
end;
end;
wadwriter.AddSeparator('F_START');
wadwriter.AddData(options.levelname + 'TER', flattexture, bm.Width * bm.Height);
wadwriter.AddSeparator('F_END');
if (options.engine = ENGINE_RAD) and (options.game <> GAME_RADIX) then
wadwriter.AddString('FLATINFO',
'flat ' + options.levelname + 'TER'#13#10 + #13#10 +
'{' + #13#10 +
' SIZE ' + IntToStr(t.texturesize) + #13#10 +
'}' + #13#10
);
FreeMem(flattexture, bm.Width * bm.Height);
end;