]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/CheckSceneryVisitor.hxx
model paging patch from Till Busch
[simgear.git] / simgear / scene / model / CheckSceneryVisitor.hxx
1 // Copyright (C) 2008 Till Busch buti@bux.at
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17 #ifndef CHECKSCENERYVISITOR_HXX
18 #define CHECKSCENERYVISITOR_HXX
19
20 #include <osg/NodeVisitor>
21 #include <osg/fast_back_stack>
22
23 namespace osgDB {
24 class DatabasePager;
25 }
26
27
28 namespace simgear
29 {
30
31 class SGPagedLOD;
32
33 // Checks the scene graph for SGPagedLODs that are within range
34 // (compared to postion) and injects them into the DatabasePager.
35 // After visiting, isLoaded() returns true if all models in range
36 // are available.
37
38 class CheckSceneryVisitor : public osg::NodeVisitor
39 {
40 public:
41     CheckSceneryVisitor(osgDB::DatabasePager* dbp, osg::Vec3 &position, double range);
42
43     virtual void apply(osg::Node& node);
44     virtual void apply(osg::PagedLOD& node);
45     virtual void apply(osg::Transform& node);
46
47     bool isLoaded() const {
48         return _loaded;
49     }
50     void setLoaded(bool l) {
51         _loaded=l;
52     }
53     const osg::Vec3 &getPosition() const {
54         return _position;
55     }
56
57 private:
58     osg::Vec3 _position;
59     double _range;
60     bool _loaded;
61     osgDB::DatabasePager* _dbp;
62
63     osg::fast_back_stack<osg::Matrix> _viewMatrices;
64 };
65
66 }
67
68 #endif