Further work on the new osgUtil::Simplifier.

This commit is contained in:
Robert Osfield
2004-04-12 21:29:31 +00:00
parent ceec7ae86d
commit c80de01fd7
3 changed files with 204 additions and 56 deletions

View File

@@ -24,11 +24,23 @@ namespace osgUtil {
/** A simplifier for reducing the number of traingles in osg::Geometry.
*/
class OSGUTIL_EXPORT Simplifier
class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor
{
public:
Simplifier();
Simplifier(float sampleRatio=0.5f);
virtual void apply(osg::Geode& geode)
{
for(unsigned int i=0;i<geode.getNumDrawables();++i)
{
osg::Geometry* geometry = geode.getDrawable(i)->asGeometry();
if (geometry)
{
simplify(*geometry,_sampleRatio);
}
}
}
/** simply the geometry to defined ratio of original size.*/
void simplify(osg::Geometry& geometry, float sampleRatio);
@@ -38,8 +50,11 @@ class OSGUTIL_EXPORT Simplifier
protected:
float _sampleRatio;
};
}
#endif