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
// OpenFlight� loader for OpenSceneGraph
16
// Copyright (C) 2005-2006 Brede Johansen
19
#ifndef OSGSIM_OPENFLIGHTOPTIMIZER
20
#define OSGSIM_OPENFLIGHTOPTIMIZER
22
#include <osg/NodeVisitor>
24
#include <osg/Geometry>
26
#include <osgSim/Export>
32
class OSGSIM_EXPORT Optimizer
37
virtual ~Optimizer() {}
39
enum OptimizationOptions
41
TESSELLATE_POLYGON = 0x001,
44
DEFAULT_OPTIMIZATIONS = TESSELLATE_POLYGON | MERGE_GEODES,
45
ALL_OPTIMIZATIONS = TESSELLATE_POLYGON | MERGE_GEODES
49
/** Traverse the node and its subgraph with a series of optimization
50
* visitors, specified by the OptimizationOptions.*/
51
void optimize(osg::Node* node);
53
/** Traverse the node and its subgraph with a series of optimization
54
* visitors, specified by the OptimizationOptions.*/
55
virtual void optimize(osg::Node* node, unsigned int options);
62
class OSGSIM_EXPORT TessellateVisitor : public osg::NodeVisitor
66
/// default to traversing all children.
68
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
70
virtual void apply(osg::Geode& geode);
74
bool hasPolygons(osg::Geometry& geometry);
78
class OSGSIM_EXPORT MakeLitVisitor : public osg::NodeVisitor
82
/// default to traversing all children.
84
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
86
virtual void apply(osg::Geode& geode);
92
class OSGSIM_EXPORT MergeGeodesVisitor : public osg::NodeVisitor
96
/// default to traversing all children.
97
MergeGeodesVisitor() :
98
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
100
virtual void apply(osg::Group& group);
102
void mergeGeodes(osg::Group& group);
106
bool mergeGeode(osg::Geode& lhs, osg::Geode& rhs);