]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/SGPagedLOD.cxx
Merge branch 'next' of git://gitorious.org/fg/simgear into next
[simgear.git] / simgear / scene / model / SGPagedLOD.cxx
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 #ifdef HAVE_CONFIG_H
18 #  include <simgear_config.h>
19 #endif
20
21 #include <osgDB/ReadFile>
22 #include <osgDB/Input>
23 #include <osgDB/ParameterOutput>
24 #include <osgDB/DatabasePager>
25
26 #include <simgear/debug/logstream.hxx>
27 #include <simgear/structure/OSGVersion.hxx>
28
29 #include "modellib.hxx"
30 #include "SGReaderWriterXMLOptions.hxx"
31 #include "SGPagedLOD.hxx"
32
33 #include <simgear/math/SGMath.hxx>
34
35 using namespace osg;
36 using namespace simgear;
37
38 SGPagedLOD::SGPagedLOD()
39         : PagedLOD()
40 {
41 }
42
43 SGPagedLOD::~SGPagedLOD()
44 {
45     //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::~SGPagedLOD(" << getFileName(0) << ")");
46 }
47
48 SGPagedLOD::SGPagedLOD(const SGPagedLOD& plod,const CopyOp& copyop)
49         : osg::PagedLOD(plod, copyop),
50         _readerWriterOptions(plod._readerWriterOptions)
51 {
52 }
53
54 bool SGPagedLOD::addChild(osg::Node *child)
55 {
56     if (!PagedLOD::addChild(child))
57         return false;
58
59     setRadius(getBound().radius());
60     setCenter(getBound().center());
61     return true;
62 }
63
64 void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, osg::FrameStamp* framestamp)
65 {
66     //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
67     //getFileName(getNumChildren()) << ")");
68     unsigned childNum = getNumChildren();
69     setTimeStamp(childNum, 0);
70     double priority=1.0;
71     dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp,
72                          getDatabaseRequest(childNum),
73                          _readerWriterOptions.get());
74 }
75
76 bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw)
77 {
78     return true;
79 }
80
81 namespace
82 {
83 osgDB::RegisterDotOsgWrapperProxy sgPagedLODProxy
84 (
85     new SGPagedLOD,
86     "simgear::SGPagedLOD",
87     "Object Node LOD PagedLOD SGPagedLOD Group",
88     0,
89     &SGPagedLOD_writeLocalData
90     );
91 }