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.
17 #include <osgDB/ReadFile>
19 #include <simgear/debug/logstream.hxx>
20 #include <simgear/structure/OSGVersion.hxx>
22 #include "modellib.hxx"
23 #include "SGReaderWriterXMLOptions.hxx"
24 #include "SGPagedLOD.hxx"
27 using namespace simgear;
29 SGPagedLOD::SGPagedLOD()
34 SGPagedLOD::~SGPagedLOD()
36 //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::~SGPagedLOD(" << getFileName(0) << ")");
39 SGPagedLOD::SGPagedLOD(const SGPagedLOD& plod,const CopyOp& copyop)
40 : osg::PagedLOD(plod, copyop),
41 _readerWriterOptions(plod._readerWriterOptions)
45 bool SGPagedLOD::addChild(osg::Node *child)
47 //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::addChild(" << getFileName(getNumChildren()) << ")");
48 if (!PagedLOD::addChild(child))
51 setRadius(getBound().radius());
52 setCenter(getBound().center());
53 // if the model was an .xml-file it will have UserData set
54 osg::ref_ptr<SGModelData> d = dynamic_cast<SGModelData*>(child->getUserData());
56 d->modelLoaded(getFileName(getNumChildren()-1), d->getProperties(), this);
57 else // this calls modelLoaded for non-xml models
59 SGReaderWriterXMLOptions *o=dynamic_cast<SGReaderWriterXMLOptions*>(_readerWriterOptions.get());
62 d = o->getModelData();
64 d->modelLoaded(getFileName(getNumChildren()-1), 0, this);
70 void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp)
72 //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
73 //getFileName(getNumChildren()) << ")");
74 unsigned childNum = getNumChildren();
75 setTimeStamp(childNum, 0);
77 dbp->requestNodeFile(getFileName(childNum),this,priority,0,
78 #if SG_OSG_VERSION >= 25001
79 getDatabaseRequest(childNum),
81 _readerWriterOptions.get());