Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Curioni <maxime.curioni@gmail.com>2008-08-02 11:39:49 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-08-02 11:39:49 +0400
commite385d69580de32df6dcfd009853ddd4eb8a3191e (patch)
treeef141019b1e00f03da689be0cea0b1a1bf6eb457 /source/blender/freestyle/intern/stroke
parent7565990db264dbb7771744cea0a1c87b3e11fc3f (diff)
soc-2008-mxcurioni: Made crucial corrections to stabilize the system. Most of the original styles are supported: stroke attributes are correctly taken into account, Python shaders are supported. Added SamplingShader.
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
-rwxr-xr-xsource/blender/freestyle/intern/stroke/BasicStrokeShaders.h99
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Operators.cpp15
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Stroke.cpp17
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Stroke.h2
-rwxr-xr-xsource/blender/freestyle/intern/stroke/StrokeShader.h4
5 files changed, 126 insertions, 11 deletions
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index f68971a3966..d54c38bb6cd 100755
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -126,6 +126,11 @@ namespace StrokeShaders {
}
/*! Destructor.*/
virtual ~IncreasingThicknessShader() {}
+
+ virtual string getName() const {
+ return "IncreasingThicknessShader";
+ }
+
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
@@ -165,6 +170,11 @@ namespace StrokeShaders {
}
/*! Destructor.*/
virtual ~ConstrainedIncreasingThicknessShader() {}
+
+ virtual string getName() const {
+ return "ConstrainedIncreasingThicknessShader";
+ }
+
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -192,6 +202,10 @@ namespace StrokeShaders {
}
virtual ~LengthDependingThicknessShader() {}
+ virtual string getName() const {
+ return "LengthDependingThicknessShader";
+ }
+
virtual void shade(Stroke& stroke) const;
};
@@ -228,6 +242,11 @@ namespace StrokeShaders {
_aThickness = 0;
}
}
+
+ virtual string getName() const {
+ return "ThicknessVariationPatternShader";
+ }
+
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
@@ -258,6 +277,11 @@ namespace StrokeShaders {
* The period of the noise signal
*/
ThicknessNoiseShader(float iAmplitude, float iPeriod);
+
+ virtual string getName() const {
+ return "ThicknessNoiseShader";
+ }
+
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -347,6 +371,11 @@ namespace StrokeShaders {
_colorMax[2] = iBM;
_colorMax[3] = iAlphaM;
}
+
+ virtual string getName() const {
+ return "IncreasingColorShader";
+ }
+
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -376,6 +405,11 @@ namespace StrokeShaders {
_aVariation = 0;
}
}
+
+ virtual string getName() const {
+ return "ColorVariationPatternShader";
+ }
+
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
@@ -400,6 +434,10 @@ namespace StrokeShaders {
: StrokeShader()
{_coefficient=coeff;}
+ virtual string getName() const {
+ return "MaterialColorShader";
+ }
+
virtual void shade(Stroke& stroke) const;
};
@@ -416,6 +454,11 @@ namespace StrokeShaders {
_orientation=iOrientation;
_orientation.normalize();
}
+
+ virtual string getName() const {
+ return "CalligraphicColorShader";
+ }
+
virtual void shade(Stroke& stroke) const;
};
@@ -438,6 +481,11 @@ namespace StrokeShaders {
* The period of the noise signal
*/
ColorNoiseShader(float iAmplitude, float iPeriod);
+
+ virtual string getName() const {
+ return "ColorNoiseShader";
+ }
+
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -477,6 +525,11 @@ namespace StrokeShaders {
{
_textureId = id;
}
+
+ virtual string getName() const {
+ return "TextureAssignerShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
@@ -526,6 +579,11 @@ namespace StrokeShaders {
_mediumType = mediumType;
_tips = iTips;
}
+
+ virtual string getName() const {
+ return "StrokeTextureShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
@@ -554,6 +612,11 @@ namespace StrokeShaders {
{
_amount = iAmount;
}
+
+ virtual string getName() const {
+ return "BackboneStretcherShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -577,6 +640,11 @@ namespace StrokeShaders {
{
_sampling = sampling;
}
+
+ virtual string getName() const {
+ return "SamplingShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -593,6 +661,10 @@ namespace StrokeShaders {
_amount = iAmount;
}
+ virtual string getName() const {
+ return "ExternalContourStretcherShader";
+ }
+
virtual void shade(Stroke& stroke) const;
};
@@ -604,6 +676,10 @@ namespace StrokeShaders {
: StrokeShader()
{}
+ virtual string getName() const {
+ return "BSplineShader";
+ }
+
virtual void shade(Stroke& stroke) const;
};
@@ -630,6 +706,10 @@ namespace StrokeShaders {
: StrokeShader()
{_error=error;}
+ virtual string getName() const {
+ return "BezierCurveShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -661,6 +741,11 @@ namespace StrokeShaders {
_amount = iAmount;
_curvatureThreshold = iThreshold;
}
+
+ virtual string getName() const {
+ return "InflateShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -690,6 +775,11 @@ namespace StrokeShaders {
*/
PolygonalizationShader(float iError) : StrokeShader()
{_error = iError;}
+
+ virtual string getName() const {
+ return "PolygonalizationShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -720,6 +810,11 @@ namespace StrokeShaders {
*/
GuidingLinesShader(float iOffset) : StrokeShader()
{_offset = iOffset;}
+
+ virtual string getName() const {
+ return "GuidingLinesShader";
+ }
+
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -739,6 +834,10 @@ namespace StrokeShaders {
/*! Destructor. */
virtual ~TipRemoverShader () {}
/*! The shading method */
+ virtual string getName() const {
+ return "TipRemoverShader";
+ }
+
virtual void shade(Stroke &stroke) const;
protected:
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index 39914cbef1a..6221f6c16f1 100755
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -814,10 +814,14 @@ Stroke* createStroke(Interface1D& inter) {
inline void applyShading(Stroke& stroke, vector<StrokeShader*>& shaders) {
- for (vector<StrokeShader*>::iterator it = shaders.begin();
- it != shaders.end();
- ++it)
- (*it)->shade(stroke);
+ for (vector<StrokeShader*>::iterator it = shaders.begin(); it != shaders.end(); ++it) {
+ StrokeShader *ss = *it;
+ string name( ss->py_ss ? PyString_AsString(PyObject_CallMethod(ss->py_ss, "getName", "")) : ss->getName() );
+
+ cout << "Shading: " << name << endl;
+ (*it)->shade(stroke);
+
+ }
}
@@ -832,7 +836,8 @@ void Operators::create(UnaryPredicate1D& pred, vector<StrokeShader*> shaders) {
++it) {
if (!pred(**it))
continue;
- Stroke* stroke = createStroke(**it);
+
+ Stroke* stroke = createStroke(**it);
if (stroke) {
applyShading(*stroke, shaders);
canvas->RenderStroke(stroke);
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index a1277611a90..dbb49bab45d 100755
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -45,6 +45,9 @@ StrokeAttribute::StrokeAttribute()
_userAttributesVec2f = 0;
_userAttributesVec3f = 0;
_visible = true;
+
+ py_sa = 0;
+
}
StrokeAttribute::StrokeAttribute(const StrokeAttribute& iBrother)
{
@@ -66,6 +69,10 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute& iBrother)
_userAttributesVec3f = new Vec3fMap(*iBrother._userAttributesVec3f);
else
_userAttributesVec3f = 0;
+
+ py_sa = 0;
+
+
}
StrokeAttribute::StrokeAttribute( float iRColor, float iGColor, float iBColor,
float iAlpha,
@@ -85,6 +92,9 @@ StrokeAttribute::StrokeAttribute( float iRColor, float iGColor, float iBColor,
_userAttributesReal = 0;
_userAttributesVec2f = 0;
_userAttributesVec3f = 0;
+
+py_sa = 0;
+
}
StrokeAttribute::StrokeAttribute(const StrokeAttribute& a1, const StrokeAttribute& a2, float t)
@@ -136,7 +146,9 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute& a1, const StrokeAttribut
_userAttributesVec3f = 0;
}
+ py_sa = 0;
}
+
StrokeAttribute::~StrokeAttribute()
{
if(_userAttributesReal){
@@ -404,11 +416,8 @@ Stroke::Stroke(const Stroke& iBrother)
_mediumType = iBrother._mediumType;
_textureId = iBrother._textureId;
_tips = iBrother._tips;
+ _rep = new StrokeRep(*(iBrother._rep));
- if( iBrother._rep )
- _rep = new StrokeRep(*(iBrother._rep));
- else
- _rep = new StrokeRep(this);
}
Stroke::~Stroke()
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 3df57341e5f..3b3a6a5ab2d 100755
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -52,6 +52,8 @@ class LIB_STROKE_EXPORT StrokeAttribute
{
public:
+ PyObject *py_sa;
+
/*! default constructor */
StrokeAttribute();
/*! Copy constructor */
diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h
index f92895564d8..cb7ceeca09f 100755
--- a/source/blender/freestyle/intern/stroke/StrokeShader.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.h
@@ -82,7 +82,7 @@ public:
* shader's name.
*/
virtual string getName() const {
- return "StrokeShader";
+ return "StrokeShader";
}
/*! The shading method. This method must
* be overloaded by inherited classes.
@@ -119,7 +119,7 @@ public:
string name( py_ss ? PyString_AsString(PyObject_CallMethod(py_ss, "getName", "")) : getName() );
if( py_ss && PyObject_HasAttrString(py_ss, "shade") ) {
- return Director_BPy_StrokeShader_shade(py_ss, ioStroke);
+ Director_BPy_StrokeShader_shade(py_ss, ioStroke);
} else {
cerr << "Warning: " << name << " method shade() not implemented" << endl;
}