openscenegraph
InsertImpostorsVisitor
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13
14#ifndef OSGSIM_INSERTIMPOSTORSVISITOR
15#define OSGSIM_INSERTIMPOSTORSVISITOR
16
17#include <osg/NodeVisitor>
18#include <osgSim/Impostor>
19
20namespace osgSim {
21
22/** Insert impostor nodes into scene graph.
23 * For example of usage see examples/osgimpostor.
24 */
25class OSGSIM_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor
26{
27 public:
28
29 /** Default to traversing all children. */
30 InsertImpostorsVisitor();
31
32 META_NodeVisitor(osgSim, InsertImpostorsVisitor)
33
34 void setImpostorThresholdRatio(float ratio) { _impostorThresholdRatio = ratio; }
35 float getImpostorThresholdRatio() const { return _impostorThresholdRatio; }
36
37 void setMaximumNumberOfNestedImpostors(unsigned int num) { _maximumNumNestedImpostors = num; }
38 unsigned int getMaximumNumberOfNestedImpostors() const { return _maximumNumNestedImpostors; }
39
40 /** Empty visitor, make it ready for next traversal. */
41 void reset();
42
43 virtual void apply(osg::Node& node);
44
45 virtual void apply(osg::Group& node);
46
47 virtual void apply(osg::LOD& node);
48
49 /* Insert the required impostors into the scene graph. */
50 void insertImpostors();
51
52 protected:
53
54 typedef std::vector< osg::Group* > GroupList;
55 typedef std::vector< osg::LOD* > LODList;
56
57 GroupList _groupList;
58 LODList _lodList;
59
60 float _impostorThresholdRatio;
61 unsigned int _maximumNumNestedImpostors;
62 unsigned int _numNestedImpostors;
63
64};
65
66}
67
68#endif