1 // Copyright (C) 2007 Tim Moore timoore@redhat.com
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 <osgDB/FileNameUtils>
19 #include <osgDB/Registry>
21 #include <simgear/scene/model/ModelRegistry.hxx>
23 #include "SGReaderWriterBTGOptions.hxx"
24 #include "SGReaderWriterBTG.hxx"
27 using namespace simgear;
29 // SGReaderWriterBTGOptions static value here to avoid an additional,
32 std::string SGReaderWriterBTGOptions::defaultOptions;
34 SGReaderWriterBTG::SGReaderWriterBTG()
36 supportsExtension("btg", "SimGear btg database format");
39 SGReaderWriterBTG::~SGReaderWriterBTG()
43 const char* SGReaderWriterBTG::className() const
45 return "BTG Database reader";
49 SGReaderWriterBTG::acceptsExtension(const std::string& extension) const
51 std::string lowercase_ext = osgDB::convertToLowerCase(extension);
52 if (lowercase_ext == "gz")
54 return osgDB::ReaderWriter::acceptsExtension(extension);
57 osgDB::ReaderWriter::ReadResult
58 SGReaderWriterBTG::readNode(const std::string& fileName,
59 const osgDB::ReaderWriter::Options* options) const
61 SGMaterialLib* matlib = 0;
62 bool calcLights = false;
63 bool useRandomObjects = false;
64 bool useRandomVegetation = false;
65 const SGReaderWriterBTGOptions* btgOptions
66 = dynamic_cast<const SGReaderWriterBTGOptions*>(options);
68 matlib = btgOptions->getMatlib();
69 calcLights = btgOptions->getCalcLights();
70 useRandomObjects = btgOptions->getUseRandomObjects();
71 useRandomVegetation = btgOptions->getUseRandomVegetation();
73 osg::Node* result = SGLoadBTG(fileName, matlib, calcLights,
79 return ReadResult::FILE_NOT_HANDLED;
83 typedef ModelRegistryCallback<DefaultProcessPolicy, NoCachePolicy,
84 NoOptimizePolicy, NoCopyPolicy,
85 NoSubstitutePolicy, BuildGroupBVHPolicy>
90 ModelRegistryCallbackProxy<BTGCallback> g_btgCallbackProxy("btg");