diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-07-29 09:45:16 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-07-29 09:45:16 +0400 |
commit | db6388e0f2b1e03ff280615fb96b93c565c9b22a (patch) | |
tree | 3a538b4464fb6b9d6bef5df129027970f37f08c8 /source/blender/freestyle/style_modules_blender/curvature2d.py | |
parent | e4677c409dcad94e96b2ae765422f91e0b0dd9fd (diff) |
soc-2008-mxcurioni: finished porting the Freestyle API. All of the original classes, except EdgeModifier and TimestampModifier (which aren't even ported via SWIG), are available under the Blender.Freestyle module. Testing of the porting will now begin to make sure the SWIG-less system works as the original.
Quite a few modifications were made to finish the API:
- Freestyle's SConscript was modified to catch all files within the intern/python directory, allowing integration of future shaders implemented in C++.
- the Operators class was ported, with a special care of making its methods static (using the METH_STATIC flag in the tp_methods method definitions)
- all of the type-checking functions [ BPy_[class name]_Check(obj) ] were changed to allow subclasses to be seen as that type too: instead on looking at the ob_type value, the PyObject_IsInstance function is used.
- all of the iterators can now retrieve the object pointed to by the operator, using the getObject() method. A directedViewEdge pair is returned as a list of the two elements in the pair.
- all of the style modules were copied to a style_modules_blender/ folder and were modified to use Freestyle as a Blender's submodule. IntegrationType and MediumType was also integrated (for example, changing MEAN to IntegrationType.MEAN).
Testing now begins. If everything works correctly, I'll move on to lib3ds removal right away.
Diffstat (limited to 'source/blender/freestyle/style_modules_blender/curvature2d.py')
-rwxr-xr-x | source/blender/freestyle/style_modules_blender/curvature2d.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/source/blender/freestyle/style_modules_blender/curvature2d.py b/source/blender/freestyle/style_modules_blender/curvature2d.py new file mode 100755 index 00000000000..377ac97f5a1 --- /dev/null +++ b/source/blender/freestyle/style_modules_blender/curvature2d.py @@ -0,0 +1,60 @@ +# +# Filename : curvature2d.py +# Author : Stephane Grabli +# Date : 04/08/2005 +# Purpose : The stroke points are colored in gray levels and depending +# on the 2d curvature value +# +############################################################################# +# +# Copyright (C) : Please refer to the COPYRIGHT file distributed +# with this source distribution. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################# + +from Blender.Freestyle import * +from logical_operators import * +from PredicatesB1D import * +from shaders import * + +class py2DCurvatureColorShader(StrokeShader): + def getName(self): + return "py2DCurvatureColorShader" + + def shade(self, stroke): + it = stroke.strokeVerticesBegin() + it_end = stroke.strokeVerticesEnd() + func = Curvature2DAngleF0D() + while it.isEnd() == 0: + it0D = it.castToInterface0DIterator() + sv = it.getObject() + att = sv.attribute() + c = func(it0D) + if (c<0): + print "negative 2D curvature" + color = 10.0 * c/3.1415 + att.setColor(color,color,color); + it.increment() + +Operators.select(QuantitativeInvisibilityUP1D(0)) +Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) +shaders_list = [ + StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0), + ConstantThicknessShader(5), + py2DCurvatureColorShader() + ] +Operators.create(TrueUP1D(), shaders_list) |