forked from themrdemonized/xray-monolith
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathETextureParams.h
More file actions
214 lines (188 loc) · 4.12 KB
/
ETextureParams.h
File metadata and controls
214 lines (188 loc) · 4.12 KB
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
#ifndef ETextureParamsH
#define ETextureParamsH
#pragma pack(push,1)
struct ECORE_API STextureParams
{
enum ETType
{
ttImage = 0,
ttCubeMap,
ttBumpMap,
ttNormalMap,
ttTerrain,
ttForceU32 = u32(-1)
};
enum ETFormat
{
tfDXT1 = 0,
tfADXT1,
tfDXT3,
tfDXT5,
tf4444,
tf1555,
tf565,
tfRGB,
tfRGBA,
tfNVHS,
tfNVHU,
tfA8,
tfL8,
tfA8L8,
tfForceU32 = u32(-1)
};
enum ETBumpMode
{
tbmResereved = 0,
tbmNone,
tbmUse,
tbmUseParallax,
tbmForceU32 = u32(-1)
};
enum ETMaterial
{
tmOrenNayar_Blin = 0,
tmBlin_Phong,
tmPhong_Metal,
tmMetal_OrenNayar,
tmForceU32 = u32(-1)
};
enum
{
kMIPFilterAdvanced = 5,
kMIPFilterPoint = 2,
kMIPFilterBox = 0,
kMIPFilterTriangle = 3,
kMIPFilterQuadratic = 4,
kMIPFilterCubic = 1,
kMIPFilterCatrom = 6,
kMIPFilterMitchell = 7,
kMIPFilterGaussian = 8,
kMIPFilterSinc = 9,
kMIPFilterBessel = 10,
kMIPFilterHanning = 11,
kMIPFilterHamming = 12,
kMIPFilterBlackman = 13,
kMIPFilterKaiser = 14,
};
enum
{
flGenerateMipMaps = (1 << 0),
flBinaryAlpha = (1 << 1),
flAlphaBorder = (1 << 4),
flColorBorder = (1 << 5),
flFadeToColor = (1 << 6),
flFadeToAlpha = (1 << 7),
flDitherColor = (1 << 8),
flDitherEachMIPLevel= (1 << 9),
// flGreyScale = (1<<10), // obsolette
flDiffuseDetail = (1 << 23),
flImplicitLighted = (1 << 24),
flHasAlpha = (1 << 25),
flBumpDetail = (1 << 26),
flForceU32 = u32(-1)
};
// texture part
ETFormat fmt;
Flags32 flags;
u32 border_color;
u32 fade_color;
u32 fade_amount;
u8 fade_delay;
u32 mip_filter;
int width;
int height;
// detail ext
shared_str detail_name;
float detail_scale;
ETType type;
// material
/*ETMaterial*/ u32 material;
float material_weight;
// bump
float bump_virtual_height;
ETBumpMode bump_mode;
shared_str bump_name;
shared_str ext_normal_map_name;
STextureParams()
{
Clear();
}
IC void destroy_shared_str(shared_str& object)
{
object.~shared_str();
}
IC void construct_shared_str(shared_str& object)
{
::new(&object) shared_str();
}
IC void Clear()
{
destroy_shared_str(detail_name);
destroy_shared_str(bump_name);
destroy_shared_str(ext_normal_map_name);
ZeroMemory(this, sizeof(STextureParams));
construct_shared_str(detail_name);
construct_shared_str(bump_name);
construct_shared_str(ext_normal_map_name);
flags.set(flGenerateMipMaps | flDitherColor,TRUE);
mip_filter = kMIPFilterBox;
width = 0;
height = 0;
detail_scale = 1;
bump_mode = tbmNone;
material = tmBlin_Phong;
bump_virtual_height = 0.05f;
}
IC BOOL HasAlpha()
{
// исходная текстура содержит альфа канал
return flags.is(flHasAlpha);
}
IC BOOL HasAlphaChannel() // игровая текстура содержит альфа канал
{
switch (fmt)
{
case tfADXT1:
case tfDXT3:
case tfDXT5:
case tf4444:
case tf1555:
case tfRGBA:
return TRUE;
default:
return FALSE;
}
}
void Load(IReader& F);
void Save(IWriter& F);
#ifdef _EDITOR
PropValue::TOnChange OnTypeChangeEvent;
void __stdcall OnTypeChange (PropValue* v);
void FillProp (LPCSTR base_name, PropItemVec& items, PropValue::TOnChange OnChangeEvent);
LPCSTR FormatString ();
u32 MemoryUsage (LPCSTR base_name);
BOOL similar (STextureParams& tp1, xr_vector<AnsiString>& sel_params);
#endif
};
#pragma pack( pop )
struct xr_token;
extern xr_token tparam_token[];
extern xr_token tfmt_token[];
extern xr_token ttype_token[];
//----------------------------------------------------
#define THM_CHUNK_VERSION 0x0810
#define THM_CHUNK_DATA 0x0811
#define THM_CHUNK_TEXTUREPARAM 0x0812
#define THM_CHUNK_TYPE 0x0813
#define THM_CHUNK_TEXTURE_TYPE 0x0814
#define THM_CHUNK_DETAIL_EXT 0x0815
#define THM_CHUNK_MATERIAL 0x0816
#define THM_CHUNK_BUMP 0x0817
#define THM_CHUNK_EXT_NORMALMAP 0x0818
#define THM_CHUNK_FADE_DELAY 0x0819
//----------------------------------------------------
#define THUMB_WIDTH 128
#define THUMB_HEIGHT 128
#define THUMB_SIZE THUMB_HEIGHT*THUMB_WIDTH
//----------------------------------------------------
#endif /*_INCDEF_TextureParams_H_*/