diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-10-08 19:34:55 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-10-08 20:31:07 +0400 |
commit | 14df7de9163ef6bc0a12303abed3a50697038a8c (patch) | |
tree | 6aa968c53147098341bb6dea23964d710ee62406 /source/blender/freestyle/intern/stroke | |
parent | 9c97624fc966000008e940eaffe279afb2e28b07 (diff) |
D801: Freestyle: remove old and unused stroke shaders
This patch removes several stroke shaders written in C++ that are unused
and don't serve a real purpose any more. The removed shaders are:
- BPy_ColorVariationPatternShader
- BPy_StrokeTextureShader
- BPy_TextureAssignerShader
- BPy_ThicknessVariationPatternShader
- BPy_fstreamShader
- BPy_streamShader
and a few more that weren't even exposed to the Python API.
Some minor edits were made by the reviewer.
Differential Revision: https://developer.blender.org/D801
Reviewed by: kjym3
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
3 files changed, 0 insertions, 763 deletions
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp index 274e36a4c9b..e37631e5bd6 100644 --- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp @@ -81,20 +81,6 @@ int CalligraphicShader::shade(Stroke &ioStroke) const return 0; } -#if 0 -void TipRemoverShader::shade(Stroke &ioStroke) const -{ - StrokeInternal::StrokeVertexIterator v, vend; - for (v = ioStroke.strokeVerticesBegin(), vend = ioStroke.strokeVerticesEnd(); v != vend; ++v) { - if (((*v)->curvilinearAbscissa() < _tipLength) || - (((*v)->strokeLength() - (*v)->curvilinearAbscissa()) < _tipLength)) { - (*v)->attribute().setThickness(0.0, 0.0); - (*v)->attribute().setColor(1, 1, 1); - } - } -} -#endif - ///////////////////////////////////////// // // SPATIAL NOISE SHADER @@ -347,63 +333,4 @@ void Smoother::copyVertices() _stroke->UpdateLength(); } -#if 0 // FIXME - -///////////////////////////////////////// -// -// OMISSION SHADER -// -///////////////////////////////////////// - -OmissionShader::OmissionShader(real sizeWindow, real thrVari, real thrFlat, real lFlat) -{ - _sizeWindow = sizeWindow; - _thresholdVariation = thrVari; - _thresholdFlat = thrFlat; - _lengthFlat = lFlat; -} - -int OmissionShader::shade(Stroke &ioStroke) const -{ - Omitter omi(ioStroke); - omi.omit(_sizeWindow, _thresholdVariation, _thresholdFlat, _lengthFlat); - - return 0; -} - - -// OMITTER -/////////////////////////// - -Omitter::Omitter(Stroke &ioStroke) : Smoother(ioStroke) -{ - StrokeInternal::StrokeVertexIterator v, vend; - int i = 0; - for (v = ioStroke.strokeVerticesBegin(), vend = ioStroke.strokeVerticesEnd(); v != vend; ++v, ++i) { - _u[i] = (v)->curvilinearAbscissa(); - } -} - -void Omitter::omit(real sizeWindow, real thrVari, real thrFlat, real lFlat) -{ - _sizeWindow=sizeWindow; - _thresholdVariation=thrVari; - _thresholdFlat=thrFlat; - _lengthFlat=lFlat; - - for (int i = 1; i < _nbVertices-1; ++i) { - if (_u[i] < _lengthFlat) - continue; - // is the previous segment flat? - int j = i - 1; - while ((j >= 0) && (_u[i] - _u[j] < _lengthFlat)) { - if ((_normal[j] * _normal[i]) < _thresholdFlat) - ; // FIXME - --j; - } - } -} - -#endif - } /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index 69ca45d3ec7..8d0720d83d9 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -43,9 +43,6 @@ #include "BKE_global.h" -//soc #include <qimage.h> -//soc #include <QString> - extern "C" { # include "IMB_imbuf.h" # include "IMB_imbuf_types.h" @@ -55,18 +52,6 @@ namespace Freestyle { // Internal function -#if 0 // soc -void convert(const QImage& iImage, float **oArray, unsigned &oSize) -{ - oSize = iImage.width(); - *oArray = new float[oSize]; - for (unsigned int i = 0; i < oSize; ++i) { - QRgb rgb = iImage.pixel(i,0); - (*oArray)[i] = ((float)qBlue(rgb)) / 255.0f; - } -} -#endif - static void convert(ImBuf *imBuf, float **oArray, unsigned &oSize) { oSize = imBuf->x; @@ -191,76 +176,6 @@ int LengthDependingThicknessShader::shade(Stroke& stroke) const return 0; } - -ThicknessVariationPatternShader::ThicknessVariationPatternShader(const string pattern_name, float iMinThickness, - float iMaxThickness, bool stretch) -: StrokeShader() -{ - _stretch = stretch; - _minThickness = iMinThickness; - _maxThickness = iMaxThickness; - ImBuf *image = NULL; - vector<string> pathnames; - StringUtils::getPathName(TextureManager::Options::getPatternsPath(), pattern_name, pathnames); - for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); ++j) { - ifstream ifs(j->c_str()); - if (ifs.is_open()) { - /* OCIO_TODO: support different input color space */ - image = IMB_loadiffname(j->c_str(), 0, NULL); - break; - } - } - if (image == NULL) - cerr << "Error: cannot find pattern \"" << pattern_name << "\" - check the path in the Options" << endl; - else - convert(image, &_aThickness, _size); - IMB_freeImBuf(image); -} - - -int ThicknessVariationPatternShader::shade(Stroke& stroke) const -{ - StrokeInternal::StrokeVertexIterator v, vend; - float *array = NULL; - /* int size; */ /* UNUSED */ - array = _aThickness; - /* size = _size; */ /* UNUSED */ - int vert_size = stroke.strokeVerticesSize(); - int sig = 0; - unsigned index; - const float *originalThickness; - for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) { - originalThickness = v->attribute().getThickness(); - if (_stretch) { - float tmp = v->u() * (_size - 1); - index = (unsigned)floor(tmp); - if ((tmp - index) > (index + 1 - tmp)) - ++index; - } - else { - index = (unsigned)floor(v->curvilinearAbscissa()); - } - index %= _size; - float thicknessR = array[index] * originalThickness[0]; - float thicknessL = array[index] * originalThickness[1]; - if (thicknessR + thicknessL < _minThickness) { - thicknessL = _minThickness / 2.0f; - thicknessR = _minThickness / 2.0f; - } - if (thicknessR + thicknessL > _maxThickness) { - thicknessL = _maxThickness / 2.0f; - thicknessR = _maxThickness / 2.0f; - } - if ((sig == 0) || (sig == vert_size - 1)) - v->attribute().setThickness(1, 1); - else - v->attribute().setThickness(thicknessR, thicknessL); - ++sig; - } - return 0; -} - - static const unsigned NB_VALUE_NOISE = 512; ThicknessNoiseShader::ThicknessNoiseShader() : StrokeShader() @@ -328,51 +243,6 @@ int IncreasingColorShader::shade(Stroke& stroke) const return 0; } -ColorVariationPatternShader::ColorVariationPatternShader(const string pattern_name, bool stretch) : StrokeShader() -{ - _stretch = stretch; - ImBuf *image = NULL; - vector<string> pathnames; - StringUtils::getPathName(TextureManager::Options::getPatternsPath(), pattern_name, pathnames); - for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); ++j) { - ifstream ifs(j->c_str()); - if (ifs.is_open()) { - /* OCIO_TODO: support different input color space */ - image = IMB_loadiffname(j->c_str(), 0, NULL); //soc - break; - } - } - if (image == NULL) - cerr << "Error: cannot find pattern \"" << pattern_name << "\" - check the path in the Options" << endl; - else - convert(image, &_aVariation, _size); - IMB_freeImBuf(image); -} - -int ColorVariationPatternShader::shade(Stroke& stroke) const -{ - StrokeInternal::StrokeVertexIterator v, vend; - unsigned index; - for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) { - const float *originalColor = v->attribute().getColor(); - if (_stretch) { - float tmp = v->u() * (_size - 1); - index = (unsigned)floor(tmp); - if ((tmp - index) > (index + 1 - tmp)) - ++index; - } - else { - index = (unsigned)floor(v->curvilinearAbscissa()); - } - index %= _size; - float r = _aVariation[index] * originalColor[0]; - float g = _aVariation[index] * originalColor[1]; - float b = _aVariation[index] * originalColor[2]; - v->attribute().setColor(r, g, b); - } - return 0; -} - int MaterialColorShader::shade(Stroke& stroke) const { Interface0DIterator v, vend; @@ -389,29 +259,6 @@ int MaterialColorShader::shade(Stroke& stroke) const return 0; } - -int CalligraphicColorShader::shade(Stroke& stroke) const -{ - Interface0DIterator v; - Functions0D::VertexOrientation2DF0D fun; - StrokeVertex *sv; - for (v = stroke.verticesBegin(); !v.isEnd(); ++v) { - if (fun(v) < 0) - return -1; - Vec2f vertexOri(fun.result); - Vec2d ori2d(-vertexOri[1], vertexOri[0]); - ori2d.normalizeSafe(); - real scal = ori2d * _orientation; - sv = dynamic_cast<StrokeVertex*>(&(*v)); - if ((scal < 0)) - sv->attribute().setColor(0, 0, 0); - else - sv->attribute().setColor(1, 1, 1); - } - return 0; -} - - ColorNoiseShader::ColorNoiseShader() : StrokeShader() { _amplitude = 1.0f; @@ -439,11 +286,9 @@ int ColorNoiseShader::shade(Stroke& stroke) const float b = bruit * _amplitude + originalColor[2]; v->attribute().setColor(r, g, b); } - return 0; } - // // Texture Shaders // @@ -466,19 +311,6 @@ int StrokeTextureStepShader::shade(Stroke& stroke) const return 0; } -// Legacy shaders from freestyle standalone texture system -int TextureAssignerShader::shade(Stroke& stroke) const -{ - cout << "TextureAssignerShader is not supported in blender, please use the BlenderTextureShader" << endl; - return 0; -} - -int StrokeTextureShader::shade(Stroke& stroke) const -{ - cout << "StrokeTextureShader is not supported in blender, please use the BlenderTextureShader" << endl; - return 0; -} - // // Geometry Shaders // @@ -541,119 +373,6 @@ int ExternalContourStretcherShader::shade(Stroke& stroke) const return 0; } -int BSplineShader::shade(Stroke& stroke) const -{ - if (stroke.strokeVerticesSize() < 4) - return 0; - - // Find the new vertices - vector<Vec2d> newVertices; - double t = 0.0; - float _sampling = 5.0f; - - StrokeInternal::StrokeVertexIterator p0, p1, p2, p3, end; - p0 = stroke.strokeVerticesBegin(); - p1 = p0; - p2 = p1; - p3 = p2; - end = stroke.strokeVerticesEnd(); - double a[4], b[4]; - int n = 0; - while (p1 != end) { -#if 0 - if (p1 == end) - p1 = p0; -#endif - if (p2 == end) - p2 = p1; - if (p3 == end) - p3 = p2; - // compute new matrix - a[0] = (-(p0)->x() + 3 * (p1)->x() - 3 * (p2)->x() + (p3)->x()) / 6.0; - a[1] = (3 * (p0)->x() - 6 * (p1)->x() + 3 * (p2)->x()) / 6.0; - a[2] = (-3 * (p0)->x() + 3 * (p2)->x()) / 6.0; - a[3] = ((p0)->x() + 4 * (p1)->x() + (p2)->x()) / 6.0; - - b[0] = (-(p0)->y() + 3 * (p1)->y() - 3 * (p2)->y() + (p3)->y()) / 6.0; - b[1] = (3 * (p0)->y() - 6 * (p1)->y() + 3 * (p2)->y()) / 6.0; - b[2] = (-3 * (p0)->y() + 3 * (p2)->y()) / 6.0; - b[3] = ((p0)->y() + 4 * (p1)->y() + (p2)->y()) / 6.0; - - // draw the spline depending on resolution: - Vec2d p1p2((p2)->x() - (p1)->x(), (p2)->y() - (p1)->y()); - double norm = p1p2.norm(); - //t = _sampling / norm; - t = 0; - while (t < 1) { - newVertices.push_back(Vec2d((a[3] + t * (a[2] + t * (a[1] + t * a[0]))), - (b[3] + t * (b[2] + t * (b[1] + t * b[0]))))); - t = t + _sampling / norm; - } - if (n > 2) { - ++p0; - ++p1; - ++p2; - ++p3; - } - else { - if (n == 0) - ++p3; - if (n == 1) { - ++p2; - ++p3; - } - if (n == 2) { - ++p1; - ++p2; - ++p3; - } - ++n; - } - } - //last point: - newVertices.push_back(Vec2d((p0)->x(), (p0)->y())); - - int originalSize = newVertices.size(); - _sampling = stroke.ComputeSampling(originalSize); - - // Resample and set x,y coordinates - stroke.Resample(_sampling); - int newsize = stroke.strokeVerticesSize(); - - int nExtraVertex = 0; - if (newsize < originalSize) { - cerr << "Warning: unsufficient resampling" << endl; - } - else { - nExtraVertex = newsize - originalSize; - } - - // assigns the new coordinates: - vector<Vec2d>::iterator p = newVertices.begin(), pend = newVertices.end(); - vector<Vec2d>::iterator last = p; - n = 0; - StrokeInternal::StrokeVertexIterator it, itend; - for (it = stroke.strokeVerticesBegin(), itend = stroke.strokeVerticesEnd(); - (it != itend) && (p != pend); - ++it, ++p, ++n) - { - it->setX(p->x()); - it->setY(p->y()); - last = p; - } - - // nExtraVertex should stay unassigned - for (int i = 0; i < nExtraVertex; ++i, ++it, ++n) { - it->setX(last->x()); - it->setY(last->y()); - if (it.isEnd()) { - // XXX Shouldn't we break in this case??? - cerr << "Warning: Problem encountered while creating B-spline" << endl; - } - } - stroke.UpdateLength(); - return 0; -} //!! Bezier curve stroke shader int BezierCurveShader::shade(Stroke& stroke) const @@ -673,15 +392,6 @@ int BezierCurveShader::shade(Stroke& stroke) const previous = v; } -#if 0 - Vec2d tmp; - bool equal = false; - if (data.front() == data.back()) { - tmp = data.back(); - data.pop_back(); - equal = true; - } -#endif // here we build the bezier curve BezierCurve bcurve(data, _error); @@ -702,25 +412,6 @@ int BezierCurveShader::shade(Stroke& stroke) const } } -#if 0 - if (equal) { - if (data.back() == data.front()) { - vector<Vec2d>::iterator d = data.begin(), dend; - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "ending point = starting point" << endl; - cout << "---------------DATA----------" << endl; - for (dend = data.end(); d != dend; ++d) { - cout << d->x() << "-" << d->y() << endl; - } - cout << "--------------BEZIER RESULT----------" << endl; - for (d = CurveVertices.begin(), dend = CurveVertices.end(); d != dend; ++d) { - cout << d->x() << "-" << d->y() << endl; - } - } - } - } -#endif - // Resample the Stroke depending on the number of vertices of the bezier curve: int originalSize = CurveVertices.size(); #if 0 @@ -734,11 +425,6 @@ int BezierCurveShader::shade(Stroke& stroke) const cerr << "Warning: unsufficient resampling" << endl; } else { -#if 0 - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "Oversampling" << endl; - } -#endif nExtraVertex = newsize - originalSize; if (nExtraVertex != 0) { if (G.debug & G_DEBUG_FREESTYLE) { @@ -752,22 +438,12 @@ int BezierCurveShader::shade(Stroke& stroke) const vector<Vec2d>::iterator last = p; int n; StrokeInternal::StrokeVertexIterator it, itend; -#if 0 - for (; p != pend; ++n, ++p); -#endif for (n = 0, it = stroke.strokeVerticesBegin(), itend = stroke.strokeVerticesEnd(), pend = CurveVertices.end(); (it != itend) && (p != pend); ++it, ++p, ++n) { it->setX(p->x()); it->setY(p->y()); -#if 0 - double x = p->x(); - double y = p->y(); - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "x = " << x << "-" << "y = " << y << endl; - } -#endif last = p; } stroke.UpdateLength(); @@ -816,46 +492,6 @@ int BezierCurveShader::shade(Stroke& stroke) const return 0; } -int InflateShader::shade(Stroke& stroke) const -{ - // we're computing the curvature variance of the stroke. (Combo 5) - // If it's too high, forget about it - Functions1D::Curvature2DAngleF1D fun; - if (fun(stroke) < 0) - return -1; - if (fun.result > _curvatureThreshold) - return 0; - - Functions0D::VertexOrientation2DF0D ori_fun; - Functions0D::Curvature2DAngleF0D curv_fun; - Functions1D::Normal2DF1D norm_fun; - Interface0DIterator it; - StrokeVertex *sv; - for (it = stroke.verticesBegin(); !it.isEnd(); ++it) { - if (ori_fun(it) < 0) - return -1; - Vec2f ntmp(ori_fun.result); - Vec2f n(ntmp.y(), -ntmp.x()); - if (norm_fun(stroke) < 0) - return -1; - Vec2f strokeN(norm_fun.result); - if (n * strokeN < 0) { - n[0] = -n[0]; - n[1] = -n[1]; - } - sv = dynamic_cast<StrokeVertex*>(&(*it)); - float u = sv->u(); - float t = 4.0f * (0.25f - (u - 0.5) * (u - 0.5)); - if (curv_fun(it) < 0) - return -1; - float curvature_coeff = (M_PI - curv_fun.result) / M_PI; - Vec2d newPoint(sv->x() + curvature_coeff * t * _amount * n.x(), - sv->y() + curvature_coeff * t * _amount * n.y()); - sv->setPoint(newPoint[0], newPoint[1]); - } - stroke.UpdateLength(); - return 0; -} class CurvePiece { @@ -1040,40 +676,16 @@ int TipRemoverShader::shade(Stroke& stroke) const // assign old attributes to new stroke vertices: vector<StrokeAttribute>::iterator a = oldAttributes.begin(), aend = oldAttributes.end(); -#if 0 - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "-----------------------------------------------" << endl; - } -#endif for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); (v != vend) && (a != aend); ++v, ++a) { v->setAttribute(*a); -#if 0 - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "thickness = " << (*a).getThickness()[0] << "-" << (*a).getThickness()[1] << endl; - } -#endif } // we're done! return 0; } -int streamShader::shade(Stroke& stroke) const -{ - if (G.debug & G_DEBUG_FREESTYLE) { - cout << stroke << endl; - } - return 0; -} - -int fstreamShader::shade(Stroke& stroke) const -{ - _stream << stroke << endl; - return 0; -} - } // end of namespace StrokeShaders } /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h index 6ac22c5b2d1..e3842f45eb0 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h @@ -218,51 +218,6 @@ public: virtual int shade(Stroke& stroke) const; }; -/*! [ Thickness Shader ]. -* Applys a pattern (texture) to vary thickness. -* The new thicknesses are the result of the multiplication -* of the pattern and the original thickness -*/ -class ThicknessVariationPatternShader : public StrokeShader -{ -public: - /*! Builds the shader. - * \param pattern_name - * The texture file name. - * \param iMinThickness - * The minimum thickness we don't want to exceed. - * \param iMaxThickness - * The maximum thickness we don't want to exceed. - * \param stretch - * Tells whether the pattern texture must be stretched or repeted to fit the stroke. - */ - ThicknessVariationPatternShader(const string pattern_name, float iMinThickness = 1.0f, float iMaxThickness = 5.0f, - bool stretch = true); - - /*! Destructor.*/ - virtual ~ThicknessVariationPatternShader() - { - if (0 != _aThickness) { - delete[] _aThickness; - _aThickness = 0; - } - } - - virtual string getName() const - { - return "ThicknessVariationPatternShader"; - } - - /*! The shading method. */ - virtual int shade(Stroke& stroke) const; - -private: - float *_aThickness; // array of thickness values, in % of the max (i.e comprised between 0 and 1) - unsigned _size; - float _minThickness; - float _maxThickness; - bool _stretch; -}; /*! [ Thickness Shader ]. * Adds some noise to the stroke thickness. @@ -389,44 +344,6 @@ public: virtual int shade(Stroke& stroke) const; }; -/*! [ Color Shader ]. - * Applys a pattern to vary original color. - * The new color is the result of the multiplication of the pattern and the original color - */ -class ColorVariationPatternShader : public StrokeShader -{ -public: - /*! Builds the shader from the pattern texture file name. - * \param pattern_name - * The file name of the texture file to use as pattern - * \param stretch - * Tells whether the texture must be strecthed or repeted to fit the stroke. - */ - ColorVariationPatternShader(const string pattern_name, bool stretch = true); - - /*! Destructor */ - virtual ~ColorVariationPatternShader() - { - if (0 != _aVariation) { - delete[] _aVariation; - _aVariation = 0; - } - } - - virtual string getName() const - { - return "ColorVariationPatternShader"; - } - - /*! The shading method. */ - virtual int shade(Stroke& stroke) const; - -private: - float *_aVariation; // array of coef values, in % of the max (i.e comprised between 0 and 1) - unsigned _size; - bool _stretch; -}; - /* [ Color Shader ]. * Assigns a color to the stroke depending on the material of the shape to which ot belongs to. (Disney shader) */ @@ -449,28 +366,6 @@ public: virtual int shade(Stroke& stroke) const; }; -class CalligraphicColorShader : public StrokeShader -{ -private: - /* UNUSED */ - // int _textureId; - Vec2d _orientation; - -public: - CalligraphicColorShader(const Vec2d &iOrientation) : StrokeShader() - { - _orientation = iOrientation; - _orientation.normalize(); - } - - virtual string getName() const - { - return "CalligraphicColorShader"; - } - - virtual int shade(Stroke& stroke) const; -}; - /*! [ Color Shader ]. * Shader to add noise to the stroke colors. */ @@ -501,105 +396,6 @@ public: }; // -// Texture Shaders -// -/////////////////////////////////////////////////////////////////////////////// -/*! [ Texture Shader ]. -* Assigns a texture to the stroke in order to simulate -* its marks system. This shader takes as input an integer value -* telling which texture and blending mode to use among a set of -* predefined textures. -* Here are the different presets: -* 0) -> /brushes/charcoalAlpha.bmp, HUMID_MEDIUM -* 1) -> /brushes/washbrushAlpha.bmp, HUMID_MEDIUM -* 2) -> /brushes/oil.bmp, HUMID_MEDIUM -* 3) -> /brushes/oilnoblend.bmp, HUMID_MEDIUM -* 4) -> /brushes/charcoalAlpha.bmp, DRY_MEDIUM -* 5) -> /brushes/washbrushAlpha.bmp, DRY_MEDIUM -* 6) -> /brushes/opaqueDryBrushAlpha.bmp, OPAQUE_MEDIUM -* 7) -> /brushes/opaqueBrushAlpha.bmp, Stroke::OPAQUE_MEDIUM -* Any other value will lead to the following preset: -* default) -> /brushes/smoothAlpha.bmp, OPAQUE_MEDIUM. -*/ -class TextureAssignerShader : public StrokeShader // FIXME -{ -private: - int _textureId; - -public: - /*! Builds the shader. - * \param id - * The number of the preset to use. - */ - TextureAssignerShader(int id) : StrokeShader() - { - _textureId = id; - } - - virtual string getName() const - { - return "TextureAssignerShader"; - } - - /*! The shading method */ - virtual int shade(Stroke& stroke) const; -}; - -/*! [ Texture Shader ]. -* Assigns a texture and a blending mode to the stroke -* in order to simulate its marks system. -*/ -class StrokeTextureShader : public StrokeShader -{ -private: - string _texturePath; - Stroke::MediumType _mediumType; - bool _tips; // 0 or 1 - -public: - /*! Builds the shader from the texture file name and the blending mode to use. - * \param textureFile - * The the texture file name. - * \attention The textures must be placed in the $FREESTYLE_DIR/data/textures/brushes directory. - * \param mediumType - * The medium type and therefore, the blending mode that must be used for the rendering of this stroke. - * \param iTips - * Tells whether the texture includes tips or not. - * If it is the case, the texture image must respect the following format: - * \verbatim - * __________ - * | | - * | A | - * |__________| - * | | | - * | B | C | - * |_____|____| - * - * \endverbatim - * - A : The stroke's corpus texture - * - B : The stroke's left extremity texture - * - C : The stroke's right extremity texture - */ - StrokeTextureShader(const string textureFile, Stroke::MediumType mediumType = Stroke::OPAQUE_MEDIUM, - bool iTips = false) - : StrokeShader() - { - _texturePath = textureFile; - _mediumType = mediumType; - _tips = iTips; - } - - virtual string getName() const - { - return "StrokeTextureShader"; - } - - /*! The shading method */ - virtual int shade(Stroke& stroke) const; -}; - - -// // Geometry Shaders // /////////////////////////////////////////////////////////////////////////////// @@ -678,20 +474,6 @@ public: virtual int shade(Stroke& stroke) const; }; -// B-Spline stroke shader -class BSplineShader: public StrokeShader -{ -public: - BSplineShader() : StrokeShader() {} - - virtual string getName() const - { - return "BSplineShader"; - } - - virtual int shade(Stroke& stroke) const; -}; - // Bezier curve stroke shader /*! [ Geometry Shader ]. @@ -724,37 +506,6 @@ public: virtual int shade(Stroke& stroke) const; }; -/* Shader to inflate the curves. It keeps the extreme points positions and moves the other ones along the 2D normal. - * The displacement value is proportional to the 2d curvature at the considered point (the higher the curvature, - * the smaller the displacement) and to a value specified by the user. - */ -class InflateShader : public StrokeShader -{ -private: - float _amount; - float _curvatureThreshold; - -public: - /*! Builds an inflate shader - * \param iAmount - * A multiplicative coefficient that acts on the amount and direction of displacement - * \param iThreshold - * The curves having a 2d curvature > iThreshold at one of their points is not inflated - */ - InflateShader(float iAmount, float iThreshold) : StrokeShader() - { - _amount = iAmount; - _curvatureThreshold = iThreshold; - } - - virtual string getName() const - { - return "InflateShader"; - } - - /*! The shading method */ - virtual int shade(Stroke& stroke) const; -}; /*! [ Geometry Shader ]. * Shader to modify the Stroke geometry so that it looks more "polygonal". @@ -846,59 +597,6 @@ protected: real _tipLength; }; -/*! [ output Shader ]. - * streams the Stroke - */ -class streamShader : public StrokeShader -{ -public: - /*! Destructor. */ - virtual ~streamShader() {} - - /*! Returns the string "streamShader".*/ - virtual string getName() const - { - return "streamShader"; - } - - /*! The shading method. */ - virtual int shade(Stroke& stroke) const; -}; - -/*! [ output Shader ]. - * streams the Stroke in a file - */ -class fstreamShader : public StrokeShader -{ -protected: - mutable ofstream _stream; - -public: - /*! Builds the shader from the output file name */ - fstreamShader(const char *iFileName) : StrokeShader() - { - _stream.open(iFileName); - if (!_stream.is_open()) { - cerr << "couldn't open file " << iFileName << endl; - } - } - - /*! Destructor. */ - virtual ~fstreamShader() - { - _stream.close(); - } - - /*! Returns the string "fstreamShader".*/ - virtual string getName() const - { - return "fstreamShader"; - } - - /*! The shading method. */ - virtual int shade(Stroke& stroke) const; -}; - /*! [ Texture Shader ]. * Shader to assign texture to the Stroke material. */ |