diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-11 03:53:46 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-11 03:53:46 +0400 |
commit | 5f02b167d191969474c8f3575abdd6dbaeffeb57 (patch) | |
tree | c6af52cbefd00519d2879486c768ba02cf4e4769 /source/blender/freestyle/intern | |
parent | 826a09300a6ac270157b8735c2dd29f753b85235 (diff) |
New options for specifying unit line thickness.
The Post Processing tab in the Render buttons has new Line Thickness options for
defining unit line thickness in two different modes as follows:
1. Absolute mode: The unit line thickness is given by a user-specified number
in units of pixels. The default value is 1.
2. Relative mode: The unit line thickness is scaled by the proportion of the
present vertical image resolution to 480 pixels. For instance, the unit line
thickness is 1 with the image height set to 480, 1.5 with 720, and 2 with 960.
Diffstat (limited to 'source/blender/freestyle/intern')
8 files changed, 50 insertions, 1 deletions
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp index 2895549a79c..ec83d2d9ff8 100755 --- a/source/blender/freestyle/intern/application/AppCanvas.cpp +++ b/source/blender/freestyle/intern/application/AppCanvas.cpp @@ -26,6 +26,7 @@ #include "../stroke/StrokeRenderer.h" #include "AppCanvas.h" #include "AppConfig.h" +#include "../stroke/StyleModule.h" #include "../system/StringUtils.h" @@ -73,6 +74,11 @@ BBox<Vec2i> AppCanvas::border() const return _pViewer->border(); } +float AppCanvas::thickness() const +{ + return _pViewer->thickness(); +} + BBox<Vec3r> AppCanvas::scene3DBBox() const { return _pViewer->scene3DBBox(); @@ -100,7 +106,12 @@ void AppCanvas::init() void AppCanvas::postDraw() { - Canvas::postDraw(); + for (unsigned i = 0; i < _StyleModules.size(); i++) { + if(!_StyleModules[i]->getDisplayed() || !_Layers[i]) + continue; + _Layers[i]->ScaleThickness(thickness()); + } + Canvas::postDraw(); } void AppCanvas::Erase() diff --git a/source/blender/freestyle/intern/application/AppCanvas.h b/source/blender/freestyle/intern/application/AppCanvas.h index 42b3c7fdb50..59ed2af3bdd 100755 --- a/source/blender/freestyle/intern/application/AppCanvas.h +++ b/source/blender/freestyle/intern/application/AppCanvas.h @@ -41,6 +41,7 @@ public: virtual int width() const ; virtual int height() const ; virtual BBox<Vec2i> border() const ; + virtual float thickness() const ; AppView *_pViewer; inline const AppView * viewer() const {return _pViewer;} diff --git a/source/blender/freestyle/intern/application/AppView.h b/source/blender/freestyle/intern/application/AppView.h index d23172c9f8d..d9b53019a93 100644 --- a/source/blender/freestyle/intern/application/AppView.h +++ b/source/blender/freestyle/intern/application/AppView.h @@ -30,15 +30,18 @@ public: inline unsigned int width() { return _width; } inline unsigned int height() { return _height; } inline BBox<Vec2i> border() { return _border; } + inline float thickness() { return _thickness; } inline void setWidth( unsigned int width ) { _width = width; } inline void setHeight( unsigned int height ) { _height = height; } inline void setBorder( int xmin, int ymin, int xmax, int ymax ) { _border = BBox<Vec2i>(Vec2i(xmin, ymin), Vec2i(xmax, ymax)); } + inline void setThickness( float thickness ) { _thickness = thickness; } protected: unsigned int _width, _height; BBox<Vec2i> _border; + float _thickness; public: diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 31dc8629f92..fbcea9ca164 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -107,6 +107,16 @@ extern "C" { int xmax = re->disprect.xmax; int ymax = re->disprect.ymax; + float thickness = 1.f; + switch (re->r.line_thickness_mode) { + case R_LINE_THICKNESS_ABSOLUTE: + thickness = re->r.unit_line_thickness * (re->r.size / 100.f); + break; + case R_LINE_THICKNESS_RELATIVE: + thickness = height / 480.f; + break; + } + freestyle_viewport[0] = freestyle_viewport[1] = 0; freestyle_viewport[2] = width; freestyle_viewport[3] = height; @@ -114,12 +124,14 @@ extern "C" { view->setWidth( width ); view->setHeight( height ); view->setBorder( xmin, ymin, xmax, ymax ); + view->setThickness( thickness ); cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl; cout << "Width : " << width << endl; cout << "Height : " << height << endl; if (re->r.mode & R_BORDER) cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl; + cout << "Unit line thickness : " << thickness << " pixel(s)" << endl; } static void init_camera(Render* re){ diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index 0c852d0e209..3675a6c0ce2 100755 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -746,6 +746,17 @@ Interface0DIterator Stroke::pointsEnd(float t) { return verticesEnd(); } +void Stroke::ScaleThickness(float iFactor) +{ + for(vertex_container::iterator it=_Vertices.begin(), itend=_Vertices.end(); + it!=itend; + ++it) + { + StrokeAttribute& attr = (*it)->attribute(); + attr.setThickness(iFactor * attr.getThicknessR(), iFactor * attr.getThicknessL()); + } +} + void Stroke::Render(const StrokeRenderer *iRenderer) { if(!_rep) diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index 1b1084b54c2..5b20bcac896 100755 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -470,6 +470,7 @@ public: void UpdateLength(); /* Render method */ + void ScaleThickness(float iFactor); void Render(const StrokeRenderer *iRenderer ); void RenderBasic(const StrokeRenderer *iRenderer ); diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp index d5fc27d3d73..93d695be406 100755 --- a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp @@ -28,6 +28,15 @@ StrokeLayer::~StrokeLayer() clear(); } +void StrokeLayer::ScaleThickness(float iFactor) +{ + for(StrokeLayer::stroke_container::iterator s=_strokes.begin(), send=_strokes.end(); + s!=send; + ++s){ + (*s)->ScaleThickness(iFactor); + } +} + void StrokeLayer::Render(const StrokeRenderer *iRenderer ) { for(StrokeLayer::stroke_container::iterator s=_strokes.begin(), send=_strokes.end(); diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.h b/source/blender/freestyle/intern/stroke/StrokeLayer.h index dbe9ea5a75c..eb8e7891bdd 100755 --- a/source/blender/freestyle/intern/stroke/StrokeLayer.h +++ b/source/blender/freestyle/intern/stroke/StrokeLayer.h @@ -54,6 +54,7 @@ public: virtual ~StrokeLayer() ; /*! Render method */ + void ScaleThickness(float iFactor); void Render(const StrokeRenderer *iRenderer ); void RenderBasic(const StrokeRenderer *iRenderer ); |