Loading...
Searching...
No Matches
SVertexManipulator.h
Go to the documentation of this file.
// Copyright (C) 2009-2012 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __S_VERTEX_MANIPULATOR_H_INCLUDED__
#define __S_VERTEX_MANIPULATOR_H_INCLUDED__
#include "S3DVertex.h"
#include "SColor.h"
namespace irr
{
namespace scene
{
class IMesh;
class IMeshBuffer;
struct SMesh;
struct IVertexManipulator
{
};
class SVertexColorSetManipulator : public IVertexManipulator
{
public:
SVertexColorSetManipulator(video::SColor color) : Color(color) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color=Color;
}
private:
video::SColor Color;
};
class SVertexColorSetAlphaManipulator : public IVertexManipulator
{
public:
SVertexColorSetAlphaManipulator(u32 alpha) : Alpha(alpha) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color.setAlpha(Alpha);
}
private:
u32 Alpha;
};
class SVertexColorInvertManipulator : public IVertexManipulator
{
public:
void operator()(video::S3DVertex& vertex) const
{
vertex.Color.setRed(255-vertex.Color.getRed());
vertex.Color.setGreen(255-vertex.Color.getGreen());
vertex.Color.setBlue(255-vertex.Color.getBlue());
}
};
class SVertexColorThresholdManipulator : public IVertexManipulator
{
public:
SVertexColorThresholdManipulator(u8 threshold, video::SColor low,
video::SColor high) : Threshold(threshold), Low(low), High(high) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color = ((u8)vertex.Color.getAverage()>Threshold)?High:Low;
}
private:
u8 Threshold;
video::SColor Low;
video::SColor High;
};
class SVertexColorBrightnessManipulator : public IVertexManipulator
{
public:
SVertexColorBrightnessManipulator(s32 amount) : Amount(amount) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color.setRed(core::clamp(vertex.Color.getRed()+Amount, 0u, 255u));
vertex.Color.setGreen(core::clamp(vertex.Color.getGreen()+Amount, 0u, 255u));
vertex.Color.setBlue(core::clamp(vertex.Color.getBlue()+Amount, 0u, 255u));
}
private:
s32 Amount;
};
class SVertexColorContrastManipulator : public IVertexManipulator
{
public:
SVertexColorContrastManipulator(f32 factor) : Factor(factor) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color.setRed(core::clamp(core::round32((vertex.Color.getRed()-128)*Factor)+128, 0, 255));
vertex.Color.setGreen(core::clamp(core::round32((vertex.Color.getGreen()-128)*Factor)+128, 0, 255));
vertex.Color.setBlue(core::clamp(core::round32((vertex.Color.getBlue()-128)*Factor)+128, 0, 255));
}
private:
f32 Factor;
};
class SVertexColorContrastBrightnessManipulator : public IVertexManipulator
{
public:
SVertexColorContrastBrightnessManipulator(f32 factor, s32 amount) : Factor(factor), Amount(amount+128) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color.setRed(core::clamp(core::round32((vertex.Color.getRed()-128)*Factor)+Amount, 0, 255));
vertex.Color.setGreen(core::clamp(core::round32((vertex.Color.getGreen()-128)*Factor)+Amount, 0, 255));
vertex.Color.setBlue(core::clamp(core::round32((vertex.Color.getBlue()-128)*Factor)+Amount, 0, 255));
}
private:
f32 Factor;
s32 Amount;
};
class SVertexColorGammaManipulator : public IVertexManipulator
{
public:
SVertexColorGammaManipulator(f32 gamma) : Gamma(1.f)
{
if (gamma != 0.f)
Gamma = 1.f/gamma;
}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color.setRed(core::clamp(core::round32(powf((f32)(vertex.Color.getRed()),Gamma)), 0, 255));
vertex.Color.setGreen(core::clamp(core::round32(powf((f32)(vertex.Color.getGreen()),Gamma)), 0, 255));
vertex.Color.setBlue(core::clamp(core::round32(powf((f32)(vertex.Color.getBlue()),Gamma)), 0, 255));
}
private:
f32 Gamma;
};
class SVertexColorScaleManipulator : public IVertexManipulator
{
public:
SVertexColorScaleManipulator(f32 factor) : Factor(factor) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color.setRed(core::clamp(core::round32(vertex.Color.getRed()*Factor), 0, 255));
vertex.Color.setGreen(core::clamp(core::round32(vertex.Color.getGreen()*Factor), 0, 255));
vertex.Color.setBlue(core::clamp(core::round32(vertex.Color.getBlue()*Factor), 0, 255));
}
private:
f32 Factor;
};
class SVertexColorDesaturateToLightnessManipulator : public IVertexManipulator
{
public:
void operator()(video::S3DVertex& vertex) const
{
vertex.Color=core::round32(vertex.Color.getLightness());
}
};
class SVertexColorDesaturateToAverageManipulator : public IVertexManipulator
{
public:
void operator()(video::S3DVertex& vertex) const
{
vertex.Color=vertex.Color.getAverage();
}
};
class SVertexColorDesaturateToLuminanceManipulator : public IVertexManipulator
{
public:
void operator()(video::S3DVertex& vertex) const
{
vertex.Color=core::round32(vertex.Color.getLuminance());
}
};
class SVertexColorInterpolateLinearManipulator : public IVertexManipulator
{
public:
SVertexColorInterpolateLinearManipulator(video::SColor color, f32 factor) :
Color(color), Factor(factor) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color=vertex.Color.getInterpolated(Color, Factor);
}
private:
video::SColor Color;
f32 Factor;
};
class SVertexColorInterpolateQuadraticManipulator : public IVertexManipulator
{
public:
SVertexColorInterpolateQuadraticManipulator(video::SColor color1, video::SColor color2, f32 factor) :
Color1(color1), Color2(color2), Factor(factor) {}
void operator()(video::S3DVertex& vertex) const
{
vertex.Color=vertex.Color.getInterpolated_quadratic(Color1, Color2, Factor);
}
private:
video::SColor Color1;
video::SColor Color2;
f32 Factor;
};
class SVertexPositionScaleManipulator : public IVertexManipulator
{
public:
SVertexPositionScaleManipulator(const core::vector3df& factor) : Factor(factor) {}
template <typename VType>
void operator()(VType& vertex) const
{
vertex.Pos *= Factor;
}
private:
core::vector3df Factor;
};
class SVertexPositionScaleAlongNormalsManipulator : public IVertexManipulator
{
public:
SVertexPositionScaleAlongNormalsManipulator(const core::vector3df& factor) : Factor(factor) {}
template <typename VType>
void operator()(VType& vertex) const
{
vertex.Pos += vertex.Normal*Factor;
}
private:
core::vector3df Factor;
};
class SVertexPositionTransformManipulator : public IVertexManipulator
{
public:
SVertexPositionTransformManipulator(const core::matrix4& m) : Transformation(m) {}
template <typename VType>
void operator()(VType& vertex) const
{
Transformation.transformVect(vertex.Pos);
}
private:
core::matrix4 Transformation;
};
class SVertexTCoordsScaleManipulator : public IVertexManipulator
{
public:
SVertexTCoordsScaleManipulator(const core::vector2df& factor, u32 uvSet=1) : Factor(factor), UVSet(uvSet) {}
void operator()(video::S3DVertex2TCoords& vertex) const
{
if (1==UVSet)
vertex.TCoords *= Factor;
else if (2==UVSet)
vertex.TCoords2 *= Factor;
}
template <typename VType>
void operator()(VType& vertex) const
{
if (1==UVSet)
vertex.TCoords *= Factor;
}
private:
core::vector2df Factor;
u32 UVSet;
};
} // end namespace scene
} // end namespace irr
#endif
S3DVertex.h
SColor.h
irr::scene::IMeshBuffer
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:40
irr::scene::IMesh
Class which holds the geometry of an object.
Definition IMesh.h:24
irr::scene::SVertexColorBrightnessManipulator::SVertexColorBrightnessManipulator
SVertexColorBrightnessManipulator(s32 amount)
Definition SVertexManipulator.h:82
irr::scene::SVertexColorBrightnessManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:83
irr::scene::SVertexColorContrastBrightnessManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:114
irr::scene::SVertexColorContrastBrightnessManipulator::SVertexColorContrastBrightnessManipulator
SVertexColorContrastBrightnessManipulator(f32 factor, s32 amount)
Definition SVertexManipulator.h:113
irr::scene::SVertexColorContrastManipulator::SVertexColorContrastManipulator
SVertexColorContrastManipulator(f32 factor)
Definition SVertexManipulator.h:97
irr::scene::SVertexColorContrastManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:98
irr::scene::SVertexColorDesaturateToAverageManipulator
Vertex manipulator which desaturates the color values.
Definition SVertexManipulator.h:171
irr::scene::SVertexColorDesaturateToAverageManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:173
irr::scene::SVertexColorDesaturateToLightnessManipulator
Vertex manipulator which desaturates the color values.
Definition SVertexManipulator.h:161
irr::scene::SVertexColorDesaturateToLightnessManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:163
irr::scene::SVertexColorDesaturateToLuminanceManipulator
Vertex manipulator which desaturates the color values.
Definition SVertexManipulator.h:181
irr::scene::SVertexColorDesaturateToLuminanceManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:183
irr::scene::SVertexColorGammaManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:134
irr::scene::SVertexColorGammaManipulator::SVertexColorGammaManipulator
SVertexColorGammaManipulator(f32 gamma)
Definition SVertexManipulator.h:129
irr::scene::SVertexColorInterpolateLinearManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:195
irr::scene::SVertexColorInterpolateLinearManipulator::SVertexColorInterpolateLinearManipulator
SVertexColorInterpolateLinearManipulator(video::SColor color, f32 factor)
Definition SVertexManipulator.h:193
irr::scene::SVertexColorInterpolateQuadraticManipulator::SVertexColorInterpolateQuadraticManipulator
SVertexColorInterpolateQuadraticManipulator(video::SColor color1, video::SColor color2, f32 factor)
Definition SVertexManipulator.h:208
irr::scene::SVertexColorInterpolateQuadraticManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:210
irr::scene::SVertexColorInvertManipulator
Vertex manipulator which invertes the RGB values.
Definition SVertexManipulator.h:52
irr::scene::SVertexColorInvertManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:54
irr::scene::SVertexColorScaleManipulator::SVertexColorScaleManipulator
SVertexColorScaleManipulator(f32 factor)
Definition SVertexManipulator.h:148
irr::scene::SVertexColorScaleManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:149
irr::scene::SVertexColorSetAlphaManipulator::SVertexColorSetAlphaManipulator
SVertexColorSetAlphaManipulator(u32 alpha)
Definition SVertexManipulator.h:42
irr::scene::SVertexColorSetAlphaManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:43
irr::scene::SVertexColorSetManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:31
irr::scene::SVertexColorSetManipulator::SVertexColorSetManipulator
SVertexColorSetManipulator(video::SColor color)
Definition SVertexManipulator.h:30
irr::scene::SVertexColorThresholdManipulator::operator()
void operator()(video::S3DVertex &vertex) const
Definition SVertexManipulator.h:68
irr::scene::SVertexColorThresholdManipulator::SVertexColorThresholdManipulator
SVertexColorThresholdManipulator(u8 threshold, video::SColor low, video::SColor high)
Definition SVertexManipulator.h:66
irr::scene::SVertexPositionScaleAlongNormalsManipulator::SVertexPositionScaleAlongNormalsManipulator
SVertexPositionScaleAlongNormalsManipulator(const core::vector3df &factor)
Definition SVertexManipulator.h:241
irr::scene::SVertexPositionScaleAlongNormalsManipulator::operator()
void operator()(VType &vertex) const
Definition SVertexManipulator.h:243
irr::scene::SVertexPositionScaleManipulator::SVertexPositionScaleManipulator
SVertexPositionScaleManipulator(const core::vector3df &factor)
Definition SVertexManipulator.h:224
irr::scene::SVertexPositionScaleManipulator::operator()
void operator()(VType &vertex) const
Definition SVertexManipulator.h:226
irr::scene::SVertexPositionTransformManipulator::operator()
void operator()(VType &vertex) const
Definition SVertexManipulator.h:257
irr::scene::SVertexPositionTransformManipulator::SVertexPositionTransformManipulator
SVertexPositionTransformManipulator(const core::matrix4 &m)
Definition SVertexManipulator.h:255
irr::scene::SVertexTCoordsScaleManipulator::operator()
void operator()(video::S3DVertex2TCoords &vertex) const
Definition SVertexManipulator.h:270
irr::scene::SVertexTCoordsScaleManipulator::operator()
void operator()(VType &vertex) const
Definition SVertexManipulator.h:278
irr::scene::SVertexTCoordsScaleManipulator::SVertexTCoordsScaleManipulator
SVertexTCoordsScaleManipulator(const core::vector2df &factor, u32 uvSet=1)
Definition SVertexManipulator.h:269
irr::video::SColor
Class representing a 32 bit ARGB color.
Definition SColor.h:202
irr::video::SColor::setBlue
void setBlue(u32 b)
Sets the blue component of the Color.
Definition SColor.h:274
irr::video::SColor::getGreen
u32 getGreen() const
Returns the green component of the color.
Definition SColor.h:231
irr::video::SColor::getInterpolated
SColor getInterpolated(const SColor &other, f32 d) const
Interpolates the color with a f32 value to another color.
Definition SColor.h:340
irr::video::SColor::getAverage
u32 getAverage() const
Get average intensity of the color in the range [0,255].
Definition SColor.h:251
irr::video::SColor::getRed
u32 getRed() const
Returns the red component of the color.
Definition SColor.h:226
irr::video::SColor::getLuminance
f32 getLuminance() const
Get luminance of the color in the range [0,255].
Definition SColor.h:245
irr::video::SColor::setAlpha
void setAlpha(u32 a)
Sets the alpha component of the Color.
Definition SColor.h:259
irr::video::SColor::setRed
void setRed(u32 r)
Sets the red component of the Color.
Definition SColor.h:264
irr::video::SColor::getLightness
f32 getLightness() const
Get lightness of the color in the range [0,255].
Definition SColor.h:239
irr::video::SColor::getInterpolated_quadratic
SColor getInterpolated_quadratic(const SColor &c1, const SColor &c2, f32 d) const
Returns interpolated color. ( quadratic ).
Definition SColor.h:354
irr::video::SColor::setGreen
void setGreen(u32 g)
Sets the green component of the Color.
Definition SColor.h:269
irr::video::SColor::getBlue
u32 getBlue() const
Returns the blue component of the color.
Definition SColor.h:236
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
irr::core::vector2df
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
irr::core::clamp
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.h:166
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2235
irr::core::round32
REALINLINE s32 round32(f32 x)
Definition irrMath.h:680
irr::scene
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CDynamicMeshBuffer.h:16
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::f32
float f32
32 bit floating point variable.
Definition irrTypes.h:104
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
irr::u8
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
irr::s32
signed int s32
32 bit signed variable.
Definition irrTypes.h:66
irr::scene::IVertexManipulator
Interface for vertex manipulators.
Definition SVertexManipulator.h:24
irr::scene::SMesh
Simple implementation of the IMesh interface.
Definition SMesh.h:19
irr::video::S3DVertex2TCoords
Vertex with two texture coordinates.
Definition S3DVertex.h:110
irr::video::S3DVertex2TCoords::TCoords2
core::vector2d< f32 > TCoords2
Second set of texture coordinates.
Definition S3DVertex.h:145
irr::video::S3DVertex
standard vertex used by the Irrlicht engine.
Definition S3DVertex.h:43
irr::video::S3DVertex::TCoords
core::vector2d< f32 > TCoords
Texture coordinates.
Definition S3DVertex.h:66
irr::video::S3DVertex::Color
SColor Color
Color.
Definition S3DVertex.h:63
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0