1 // Copyright (C) 2008 Till Busch buti@bux.at
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.
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.
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.
18 # include <simgear_config.h>
21 #include <osgDB/ReadFile>
22 #include <osgDB/Input>
23 #include <osgDB/ParameterOutput>
24 #include <osgDB/DatabasePager>
26 #include <simgear/debug/logstream.hxx>
27 #include <simgear/structure/OSGVersion.hxx>
29 #include "modellib.hxx"
30 #include "SGReaderWriterXMLOptions.hxx"
31 #include "SGPagedLOD.hxx"
33 #include <simgear/math/SGMath.hxx>
36 using namespace simgear;
38 SGPagedLOD::SGPagedLOD()
43 SGPagedLOD::~SGPagedLOD()
45 //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::~SGPagedLOD(" << getFileName(0) << ")");
48 SGPagedLOD::SGPagedLOD(const SGPagedLOD& plod,const CopyOp& copyop)
49 : osg::PagedLOD(plod, copyop)
50 #if !SG_PAGEDLOD_HAS_OPTIONS
51 , _readerWriterOptions(plod._readerWriterOptions)
56 bool SGPagedLOD::addChild(osg::Node *child)
58 if (!PagedLOD::addChild(child))
61 setRadius(getBound().radius());
62 setCenter(getBound().center());
66 // Work around interface change in osgDB::DatabasePager::requestNodeFile
69 NodePathProxy(NodePath& nodePath)
73 operator Group* () { return static_cast<Group*>(_nodePath.back()); }
74 operator NodePath& () { return _nodePath; }
78 void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, FrameStamp* framestamp,
81 //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
82 //getFileName(getNumChildren()) << ")");
83 unsigned childNum = getNumChildren();
84 setTimeStamp(childNum, 0);
86 dbp->requestNodeFile(getFileName(childNum), NodePathProxy(path),
88 getDatabaseRequest(childNum),
89 getReaderWriterOptions());
92 bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw)
99 osgDB::RegisterDotOsgWrapperProxy sgPagedLODProxy
102 "simgear::SGPagedLOD",
103 "Object Node LOD PagedLOD SGPagedLOD Group",
105 &SGPagedLOD_writeLocalData