Code: Select all
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;
};
Code: Select all
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 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;
};
Thanks.
A hopeful beginner,
BluePanda