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
|
/*
model/layers.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MODEL_LAYER_H__
#define __INCLUDED_MODEL_LAYER_H__
#include "math/vector2f.h"
#include "math/color.h"
namespace model
{
/**
* @brief a single layer within a material
* */
class Layer {
public:
/**
* @brief color generation type definition
* */
enum RGBGen {
RGBGenIdentity = 1, // unmodified
RGBGenColor = 2, // modified by layer color
RGBGenEngine = 3, // modified by engine color
RGBGenPrimary = 4, // modified by primary entity color
RGBGenSecondary = 5, // modified by secondary entity color
RGBGenTertiary = 6 // modified by tertiary entity color
};
/**
* @brief texture map type definition
* */
enum TexMap {
TexMapNone = 0, // no texture map
TexMapImage = 1, // texture map from image
TexMapEnvironment = 2, // texture map with skybox
TexMapLogo = 3 // use current logo texture
};
/**
* @brief texture coordinate generation type definition
* */
enum TCGen {
TCGenBase = 1, // use texture coordinates from vertex array
TCGenEnvironment = 2 // texture coordinates generated by GL_SPHERE_MAP/GL_REFLECTION_MAP
};
/**
* @brief blend functions definition
* */
enum BlendFunc {
BlendFuncNone = 0, // no blending
BlendFuncAdd = 1, // GL_ONE GL_OME
BlendFuncBlend = 2 // GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
};
/**
* @brief default constructor
* */
Layer();
/**
* @brief default destructor
* */
~Layer();
/* ---- inspectors ----------------------------------------- */
/**
* @brief size of the layer, in pixels
*/
inline const math::Vector2f & size() const
{
return layer_size;
}
/**
* @brief rgb color generation source for this material layer
* */
inline const RGBGen rgbgen() const
{
return layer_rgbgen;
}
/**
* @brief layer color
* The layer color is used if color source if rgbgen() is set to RGBGenColor
* */
inline const math::Color & color() const
{
return layer_color;
}
/**
* @brief layer specular color
* The specular color is used in lighting calculations.
* */
inline const math::Color & specular() const
{
return layer_color_specular;
}
/**
* @brief layer shininess
* The shininess value is used to control the GL_SHININESS of the layer.
* */
inline const math::Color & shininess() const
{
return layer_shininess;
}
/**
* @brief layer texture map
*/
const TexMap texmap() const
{
return layer_texmap;
}
/**
* @brief layer texture map name
* The layer texture mapa name is used if texmap() is set to TexMapTexture
* */
inline const std::string &texture() const
{
return layer_texture_name;
}
/**
* @brief layer texture map renderer id
* */
inline const size_t texture_id() const
{
return layer_texture_id;
}
/**
* @brief texture coordinates generation source for this material layer
* */
inline const TCGen tcgen() const
{
return layer_tcgen;
}
/**
* @brief returns true if lighting calculations should be disabled for this layer
* */
inline const bool fullbright() const
{
return layer_fullbright;
}
/**
* @brief returns the current alpha blending function
* */
inline const BlendFunc blendfunc() const
{
return layer_blendfunc;
}
/* ---- mutators ------------------------------------------- */
/**
* @brief set rgb color generation source
* */
void set_rgbgen(const RGBGen rgbgen);
/**
* @brief set layer color
* */
void set_color(const math::Color & color);
/**
* @brief set layer specular color
* This value is used in lighting calculations
* */
void set_specular(const math::Color & specular);
/**
* @brief set layer specular color
* This value is used in lighting calculations
* */
void set_shininess(const math::Color & shininess);
/**
* @brief set the texture map type
* */
void set_texmap(const TexMap texmap);
/**
* @brief set the texture map name
* */
void set_texture(const std::string & texture);
/**
* @brief set the renderer texture id
* */
void set_texture_id(const size_t id);
/**
* @brief set texture coordinates generation source
* */
void set_tcgen(const TCGen tcgen);
/**
* @brief enable or disable lighting calculations on this layer
* If set to true, lighting is disabled.
* */
void set_fullbright(const bool fullbright);
/**
* @brief set the layer size, in pixels
* */
void set_size(const math::Vector2f & size);
/**
* @brief set alpha blending function
* */
void set_blendfunc(const BlendFunc blendfunc);
private:
math::Vector2f layer_size;
RGBGen layer_rgbgen;
math::Color layer_color;
math::Color layer_color_specular;
math::Color layer_shininess;
TexMap layer_texmap;
std::string layer_texture_name;
size_t layer_texture_id;
TCGen layer_tcgen;
bool layer_fullbright;
BlendFunc layer_blendfunc;
};
} // namespace model
#endif // __INCLUDED_MODEL_LAYER_H__
|