1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGUTIL_SMOOTHINGVISITOR
15#define OSGUTIL_SMOOTHINGVISITOR 1
17#include <osg/NodeVisitor>
19#include <osg/Geometry>
21#include <osgUtil/Export>
25/** A smoothing visitor for calculating smoothed normals for
26 * osg::GeoSet's which contains surface primitives.
28class OSGUTIL_EXPORT SmoothingVisitor : public osg::NodeVisitor
32 /// default to traversing all children.
34 virtual ~SmoothingVisitor();
36 /// smooth geoset by creating per vertex normals.
37 static void smooth(osg::Geometry& geoset, double creaseAngle=osg::PI);
39 /// apply smoothing method to all geometries.
40 virtual void apply(osg::Geometry& geom);
42 /// set the maximum angle, in radians, at which angle between adjacent triangles that normals are smoothed
43 /// for edges that greater the shared vertices are duplicated
44 void setCreaseAngle(double angle) { _creaseAngle = angle; }
45 double getCreaseAngle() const { return _creaseAngle; }