This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/release/scripts/freestyle/style_modules/sketchy_topology_broken.py
Tamito Kajiyama 9f79d8ae67 * freestyle_init.py: Removed all classes for wrapping extension types.
This allows users to test the types of those objects that are returned
by API functions, by means of usual Python idioms such as "type(I) is T"
and "isinstance(I, T)".

* Removed all occurrences of ViewVertex::castToTVertex() in the following
modules and rewrote the code segments using it by means of the "type(I)
is T" idiom mentioned above:

  ChainingIterators.py
  PredicatesU1D.py

* Replaced all occurrences of vector.Vec2, vector.Vec3, Vec2f and Vec3f
by Blender.Mathutils.Vector in the following modules:

  anisotropic_diffusion.py
  Functions0D.py
  shaders.py
  sketchy_topology_broken.py

* shaders.py: Fixed NameError's concerning math.pow().

* shaders.py: Added a Python equivalent of getFEdge function, defined
in source\blender\freestyle\intern\view_map\Functions0D.cpp as follows:

  FEdge* Functions0D::getFEdge(Interface0D& it1, Interface0D& it2) {
    return it1.getFEdge(it2);
  }

* shaders.py: Replaced fe.qi() by fe.viewedge().qi().

* contour.py: Fixed the import statement for freestyle_init.py.
2009-07-27 20:13:47 +00:00

90 lines
3.0 KiB
Python
Executable File

#
# Filename : sketchy_topology_broken.py
# Author : Stephane Grabli
# Date : 04/08/2005
# Purpose : The topology of the strokes is, first, built
# independantly from the 3D topology of objects,
# and, second, so as to chain several times the same ViewEdge.
#
#############################################################################
#
# 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 freestyle_init import *
from logical_operators import *
from ChainingIterators import *
from shaders import *
## Backbone stretcher that leaves cusps intact to avoid cracks
class pyBackboneStretcherNoCuspShader(StrokeShader):
def __init__(self, l):
StrokeShader.__init__(self)
self._l = l
def getName(self):
return "pyBackboneStretcherNoCuspShader"
def shade(self, stroke):
it0 = stroke.strokeVerticesBegin()
it1 = StrokeVertexIterator(it0)
it1.increment()
itn = stroke.strokeVerticesEnd()
itn.decrement()
itn_1 = StrokeVertexIterator(itn)
itn_1.decrement()
v0 = it0.getObject()
v1 = it1.getObject()
if((v0.getNature() & Nature.CUSP == 0) and (v1.getNature() & Nature.CUSP == 0)):
p0 = v0.getPoint()
p1 = v1.getPoint()
d1 = p0-p1
d1.normalize()
newFirst = p0+d1*float(self._l)
v0.setPoint(newFirst)
else:
print "got a v0 cusp"
vn_1 = itn_1.getObject()
vn = itn.getObject()
if((vn.getNature() & Nature.CUSP == 0) and (vn_1.getNature() & Nature.CUSP == 0)):
pn = vn.getPoint()
pn_1 = vn_1.getPoint()
dn = pn-pn_1
dn.normalize()
newLast = pn+dn*float(self._l)
vn.setPoint(newLast)
else:
print "got a vn cusp"
Operators.select(QuantitativeInvisibilityUP1D(0))
## Chain 3 times each ViewEdge indpendantly from the
## initial objects topology
Operators.bidirectionalChain(pySketchyChainingIterator(3))
shaders_list = [
SamplingShader(4),
SpatialNoiseShader(6, 120, 2, 1, 1),
IncreasingThicknessShader(4, 10),
SmoothingShader(100, 0.1, 0, 0.2, 0, 0, 0, 1),
pyBackboneStretcherNoCuspShader(20),
#ConstantColorShader(0.0,0.0,0.0)
IncreasingColorShader(0.2,0.2,0.2,1,0.5,0.5,0.5,1),
#IncreasingColorShader(1,0,0,1,0,1,0,1),
TextureAssignerShader(4)
]
Operators.create(TrueUP1D(), shaders_list)