diff options
Diffstat (limited to 'libraries/irrlicht-1.8.1/include/SVertexManipulator.h')
-rw-r--r-- | libraries/irrlicht-1.8.1/include/SVertexManipulator.h | 292 |
1 files changed, 0 insertions, 292 deletions
diff --git a/libraries/irrlicht-1.8.1/include/SVertexManipulator.h b/libraries/irrlicht-1.8.1/include/SVertexManipulator.h deleted file mode 100644 index 6696ad0..0000000 --- a/libraries/irrlicht-1.8.1/include/SVertexManipulator.h +++ /dev/null | |||
@@ -1,292 +0,0 @@ | |||
1 | // Copyright (C) 2009-2012 Christian Stehno | ||
2 | // This file is part of the "Irrlicht Engine". | ||
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
4 | |||
5 | #ifndef __S_VERTEX_MANIPULATOR_H_INCLUDED__ | ||
6 | #define __S_VERTEX_MANIPULATOR_H_INCLUDED__ | ||
7 | |||
8 | #include "S3DVertex.h" | ||
9 | #include "SColor.h" | ||
10 | |||
11 | namespace irr | ||
12 | { | ||
13 | namespace scene | ||
14 | { | ||
15 | |||
16 | class IMesh; | ||
17 | class IMeshBuffer; | ||
18 | struct SMesh; | ||
19 | |||
20 | //! Interface for vertex manipulators. | ||
21 | /** You should derive your manipulator from this class if it shall be called for every vertex, getting as parameter just the vertex. | ||
22 | */ | ||
23 | struct IVertexManipulator | ||
24 | { | ||
25 | }; | ||
26 | //! Vertex manipulator to set color to a fixed color for all vertices | ||
27 | class SVertexColorSetManipulator : public IVertexManipulator | ||
28 | { | ||
29 | public: | ||
30 | SVertexColorSetManipulator(video::SColor color) : Color(color) {} | ||
31 | void operator()(video::S3DVertex& vertex) const | ||
32 | { | ||
33 | vertex.Color=Color; | ||
34 | } | ||
35 | private: | ||
36 | video::SColor Color; | ||
37 | }; | ||
38 | //! Vertex manipulator to set the alpha value of the vertex color to a fixed value | ||
39 | class SVertexColorSetAlphaManipulator : public IVertexManipulator | ||
40 | { | ||
41 | public: | ||
42 | SVertexColorSetAlphaManipulator(u32 alpha) : Alpha(alpha) {} | ||
43 | void operator()(video::S3DVertex& vertex) const | ||
44 | { | ||
45 | vertex.Color.setAlpha(Alpha); | ||
46 | } | ||
47 | private: | ||
48 | u32 Alpha; | ||
49 | }; | ||
50 | //! Vertex manipulator which invertes the RGB values | ||
51 | class SVertexColorInvertManipulator : public IVertexManipulator | ||
52 | { | ||
53 | public: | ||
54 | void operator()(video::S3DVertex& vertex) const | ||
55 | { | ||
56 | vertex.Color.setRed(255-vertex.Color.getRed()); | ||
57 | vertex.Color.setGreen(255-vertex.Color.getGreen()); | ||
58 | vertex.Color.setBlue(255-vertex.Color.getBlue()); | ||
59 | } | ||
60 | }; | ||
61 | //! Vertex manipulator to set vertex color to one of two values depending on a given threshold | ||
62 | /** If average of the color value is >Threshold the High color is chosen, else Low. */ | ||
63 | class SVertexColorThresholdManipulator : public IVertexManipulator | ||
64 | { | ||
65 | public: | ||
66 | SVertexColorThresholdManipulator(u8 threshold, video::SColor low, | ||
67 | video::SColor high) : Threshold(threshold), Low(low), High(high) {} | ||
68 | void operator()(video::S3DVertex& vertex) const | ||
69 | { | ||
70 | vertex.Color = ((u8)vertex.Color.getAverage()>Threshold)?High:Low; | ||
71 | } | ||
72 | private: | ||
73 | u8 Threshold; | ||
74 | video::SColor Low; | ||
75 | video::SColor High; | ||
76 | }; | ||
77 | //! Vertex manipulator which adjusts the brightness by the given amount | ||
78 | /** A positive value increases brightness, a negative value darkens the colors. */ | ||
79 | class SVertexColorBrightnessManipulator : public IVertexManipulator | ||
80 | { | ||
81 | public: | ||
82 | SVertexColorBrightnessManipulator(s32 amount) : Amount(amount) {} | ||
83 | void operator()(video::S3DVertex& vertex) const | ||
84 | { | ||
85 | vertex.Color.setRed(core::clamp(vertex.Color.getRed()+Amount, 0u, 255u)); | ||
86 | vertex.Color.setGreen(core::clamp(vertex.Color.getGreen()+Amount, 0u, 255u)); | ||
87 | vertex.Color.setBlue(core::clamp(vertex.Color.getBlue()+Amount, 0u, 255u)); | ||
88 | } | ||
89 | private: | ||
90 | s32 Amount; | ||
91 | }; | ||
92 | //! Vertex manipulator which adjusts the contrast by the given factor | ||
93 | /** Factors over 1 increase contrast, below 1 reduce it. */ | ||
94 | class SVertexColorContrastManipulator : public IVertexManipulator | ||
95 | { | ||
96 | public: | ||
97 | SVertexColorContrastManipulator(f32 factor) : Factor(factor) {} | ||
98 | void operator()(video::S3DVertex& vertex) const | ||
99 | { | ||
100 | vertex.Color.setRed(core::clamp(core::round32((vertex.Color.getRed()-128)*Factor)+128, 0, 255)); | ||
101 | vertex.Color.setGreen(core::clamp(core::round32((vertex.Color.getGreen()-128)*Factor)+128, 0, 255)); | ||
102 | vertex.Color.setBlue(core::clamp(core::round32((vertex.Color.getBlue()-128)*Factor)+128, 0, 255)); | ||
103 | } | ||
104 | private: | ||
105 | f32 Factor; | ||
106 | }; | ||
107 | //! Vertex manipulator which adjusts the contrast by the given factor and brightness by a signed amount. | ||
108 | /** Factors over 1 increase contrast, below 1 reduce it. | ||
109 | A positive amount increases brightness, a negative one darkens the colors. */ | ||
110 | class SVertexColorContrastBrightnessManipulator : public IVertexManipulator | ||
111 | { | ||
112 | public: | ||
113 | SVertexColorContrastBrightnessManipulator(f32 factor, s32 amount) : Factor(factor), Amount(amount+128) {} | ||
114 | void operator()(video::S3DVertex& vertex) const | ||
115 | { | ||
116 | vertex.Color.setRed(core::clamp(core::round32((vertex.Color.getRed()-128)*Factor)+Amount, 0, 255)); | ||
117 | vertex.Color.setGreen(core::clamp(core::round32((vertex.Color.getGreen()-128)*Factor)+Amount, 0, 255)); | ||
118 | vertex.Color.setBlue(core::clamp(core::round32((vertex.Color.getBlue()-128)*Factor)+Amount, 0, 255)); | ||
119 | } | ||
120 | private: | ||
121 | f32 Factor; | ||
122 | s32 Amount; | ||
123 | }; | ||
124 | //! Vertex manipulator which adjusts the brightness by a gamma operation | ||
125 | /** A value over one increases brightness, one below darkens the colors. */ | ||
126 | class SVertexColorGammaManipulator : public IVertexManipulator | ||
127 | { | ||
128 | public: | ||
129 | SVertexColorGammaManipulator(f32 gamma) : Gamma(1.f) | ||
130 | { | ||
131 | if (gamma != 0.f) | ||
132 | Gamma = 1.f/gamma; | ||
133 | } | ||
134 | void operator()(video::S3DVertex& vertex) const | ||
135 | { | ||
136 | vertex.Color.setRed(core::clamp(core::round32(powf((f32)(vertex.Color.getRed()),Gamma)), 0, 255)); | ||
137 | vertex.Color.setGreen(core::clamp(core::round32(powf((f32)(vertex.Color.getGreen()),Gamma)), 0, 255)); | ||
138 | vertex.Color.setBlue(core::clamp(core::round32(powf((f32)(vertex.Color.getBlue()),Gamma)), 0, 255)); | ||
139 | } | ||
140 | private: | ||
141 | f32 Gamma; | ||
142 | }; | ||
143 | //! Vertex manipulator which scales the color values | ||
144 | /** Can e.g be used for white balance, factor would be 255.f/brightest color. */ | ||
145 | class SVertexColorScaleManipulator : public IVertexManipulator | ||
146 | { | ||
147 | public: | ||
148 | SVertexColorScaleManipulator(f32 factor) : Factor(factor) {} | ||
149 | void operator()(video::S3DVertex& vertex) const | ||
150 | { | ||
151 | vertex.Color.setRed(core::clamp(core::round32(vertex.Color.getRed()*Factor), 0, 255)); | ||
152 | vertex.Color.setGreen(core::clamp(core::round32(vertex.Color.getGreen()*Factor), 0, 255)); | ||
153 | vertex.Color.setBlue(core::clamp(core::round32(vertex.Color.getBlue()*Factor), 0, 255)); | ||
154 | } | ||
155 | private: | ||
156 | f32 Factor; | ||
157 | }; | ||
158 | //! Vertex manipulator which desaturates the color values | ||
159 | /** Uses the lightness value of the color. */ | ||
160 | class SVertexColorDesaturateToLightnessManipulator : public IVertexManipulator | ||
161 | { | ||
162 | public: | ||
163 | void operator()(video::S3DVertex& vertex) const | ||
164 | { | ||
165 | vertex.Color=core::round32(vertex.Color.getLightness()); | ||
166 | } | ||
167 | }; | ||
168 | //! Vertex manipulator which desaturates the color values | ||
169 | /** Uses the average value of the color. */ | ||
170 | class SVertexColorDesaturateToAverageManipulator : public IVertexManipulator | ||
171 | { | ||
172 | public: | ||
173 | void operator()(video::S3DVertex& vertex) const | ||
174 | { | ||
175 | vertex.Color=vertex.Color.getAverage(); | ||
176 | } | ||
177 | }; | ||
178 | //! Vertex manipulator which desaturates the color values | ||
179 | /** Uses the luminance value of the color. */ | ||
180 | class SVertexColorDesaturateToLuminanceManipulator : public IVertexManipulator | ||
181 | { | ||
182 | public: | ||
183 | void operator()(video::S3DVertex& vertex) const | ||
184 | { | ||
185 | vertex.Color=core::round32(vertex.Color.getLuminance()); | ||
186 | } | ||
187 | }; | ||
188 | //! Vertex manipulator which interpolates the color values | ||
189 | /** Uses linear interpolation. */ | ||
190 | class SVertexColorInterpolateLinearManipulator : public IVertexManipulator | ||
191 | { | ||
192 | public: | ||
193 | SVertexColorInterpolateLinearManipulator(video::SColor color, f32 factor) : | ||
194 | Color(color), Factor(factor) {} | ||
195 | void operator()(video::S3DVertex& vertex) const | ||
196 | { | ||
197 | vertex.Color=vertex.Color.getInterpolated(Color, Factor); | ||
198 | } | ||
199 | private: | ||
200 | video::SColor Color; | ||
201 | f32 Factor; | ||
202 | }; | ||
203 | //! Vertex manipulator which interpolates the color values | ||
204 | /** Uses linear interpolation. */ | ||
205 | class SVertexColorInterpolateQuadraticManipulator : public IVertexManipulator | ||
206 | { | ||
207 | public: | ||
208 | SVertexColorInterpolateQuadraticManipulator(video::SColor color1, video::SColor color2, f32 factor) : | ||
209 | Color1(color1), Color2(color2), Factor(factor) {} | ||
210 | void operator()(video::S3DVertex& vertex) const | ||
211 | { | ||
212 | vertex.Color=vertex.Color.getInterpolated_quadratic(Color1, Color2, Factor); | ||
213 | } | ||
214 | private: | ||
215 | video::SColor Color1; | ||
216 | video::SColor Color2; | ||
217 | f32 Factor; | ||
218 | }; | ||
219 | |||
220 | //! Vertex manipulator which scales the position of the vertex | ||
221 | class SVertexPositionScaleManipulator : public IVertexManipulator | ||
222 | { | ||
223 | public: | ||
224 | SVertexPositionScaleManipulator(const core::vector3df& factor) : Factor(factor) {} | ||
225 | template <typename VType> | ||
226 | void operator()(VType& vertex) const | ||
227 | { | ||
228 | vertex.Pos *= Factor; | ||
229 | } | ||
230 | private: | ||
231 | core::vector3df Factor; | ||
232 | }; | ||
233 | |||
234 | //! Vertex manipulator which scales the position of the vertex along the normals | ||
235 | /** This can look more pleasing than the usual Scale operator, but | ||
236 | depends on the mesh geometry. | ||
237 | */ | ||
238 | class SVertexPositionScaleAlongNormalsManipulator : public IVertexManipulator | ||
239 | { | ||
240 | public: | ||
241 | SVertexPositionScaleAlongNormalsManipulator(const core::vector3df& factor) : Factor(factor) {} | ||
242 | template <typename VType> | ||
243 | void operator()(VType& vertex) const | ||
244 | { | ||
245 | vertex.Pos += vertex.Normal*Factor; | ||
246 | } | ||
247 | private: | ||
248 | core::vector3df Factor; | ||
249 | }; | ||
250 | |||
251 | //! Vertex manipulator which transforms the position of the vertex | ||
252 | class SVertexPositionTransformManipulator : public IVertexManipulator | ||
253 | { | ||
254 | public: | ||
255 | SVertexPositionTransformManipulator(const core::matrix4& m) : Transformation(m) {} | ||
256 | template <typename VType> | ||
257 | void operator()(VType& vertex) const | ||
258 | { | ||
259 | Transformation.transformVect(vertex.Pos); | ||
260 | } | ||
261 | private: | ||
262 | core::matrix4 Transformation; | ||
263 | }; | ||
264 | |||
265 | //! Vertex manipulator which scales the TCoords of the vertex | ||
266 | class SVertexTCoordsScaleManipulator : public IVertexManipulator | ||
267 | { | ||
268 | public: | ||
269 | SVertexTCoordsScaleManipulator(const core::vector2df& factor, u32 uvSet=1) : Factor(factor), UVSet(uvSet) {} | ||
270 | void operator()(video::S3DVertex2TCoords& vertex) const | ||
271 | { | ||
272 | if (1==UVSet) | ||
273 | vertex.TCoords *= Factor; | ||
274 | else if (2==UVSet) | ||
275 | vertex.TCoords2 *= Factor; | ||
276 | } | ||
277 | template <typename VType> | ||
278 | void operator()(VType& vertex) const | ||
279 | { | ||
280 | if (1==UVSet) | ||
281 | vertex.TCoords *= Factor; | ||
282 | } | ||
283 | private: | ||
284 | core::vector2df Factor; | ||
285 | u32 UVSet; | ||
286 | }; | ||
287 | |||
288 | } // end namespace scene | ||
289 | } // end namespace irr | ||
290 | |||
291 | |||
292 | #endif | ||