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 _readerWriterOptions(plod._readerWriterOptions)
54 bool SGPagedLOD::addChild(osg::Node *child)
56 if (!PagedLOD::addChild(child))
59 setRadius(getBound().radius());
60 setCenter(getBound().center());
64 void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, osg::FrameStamp* framestamp)
66 //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
67 //getFileName(getNumChildren()) << ")");
68 unsigned childNum = getNumChildren();
69 setTimeStamp(childNum, 0);
71 #if SG_OSG_MIN_VERSION_REQUIRED(2,9,11)
72 // osgDB::DatabasePager::requestNodeFile changed with OSG 2.9.11
75 #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
76 #warning !! Your version of OpenSceneGraph is currently unsupported.
77 #warning !! Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10.
78 #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
80 // Alas! Why is MSVC different (again)? :)
81 #pragma WARNING( Your version of OpenSceneGraph is currently unsupported. )
82 #pragma WARNING( Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10. )
85 //TODO We need to adapt to OSG 2.9.11 (and future releases). This doesn't work yet...
86 dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp,
87 getDatabaseRequest(childNum),
88 _readerWriterOptions.get());
90 // OSG revisions up to 2.9.10
91 dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp,
92 getDatabaseRequest(childNum),
93 _readerWriterOptions.get());
97 bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw)
104 osgDB::RegisterDotOsgWrapperProxy sgPagedLODProxy
107 "simgear::SGPagedLOD",
108 "Object Node LOD PagedLOD SGPagedLOD Group",
110 &SGPagedLOD_writeLocalData