]> git.mxchange.org Git - simgear.git/blob - simgear/scene/tgdb/SGReaderWriterBTG.cxx
Don't render ocean tiles in the light pass
[simgear.git] / simgear / scene / tgdb / SGReaderWriterBTG.cxx
1 // Copyright (C) 2007 Tim Moore timoore@redhat.com
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
18 #ifdef HAVE_CONFIG_H
19 #  include <simgear_config.h>
20 #endif
21
22 #include <osgDB/FileNameUtils>
23 #include <osgDB/Registry>
24
25 #include <simgear/scene/model/ModelRegistry.hxx>
26 #include <simgear/scene/util/SGReaderWriterOptions.hxx>
27
28 #include "SGReaderWriterBTG.hxx"
29 #include "obj.hxx"
30
31 using namespace simgear;
32
33 SGReaderWriterBTG::SGReaderWriterBTG()
34 {
35     supportsExtension("btg", "SimGear btg database format");
36     // supportsExtension("btg.gz", "SimGear btg database format");
37 }
38
39 SGReaderWriterBTG::~SGReaderWriterBTG()
40 {
41 }
42
43 const char* SGReaderWriterBTG::className() const
44 {
45     return "BTG Database reader";
46 }
47
48 bool
49 SGReaderWriterBTG::acceptsExtension(const std::string& extension) const
50 {
51     // trick the osg extensions match algorithm to accept btg.gz files.
52     if (osgDB::convertToLowerCase(extension) == "gz")
53         return true;
54     return osgDB::ReaderWriter::acceptsExtension(extension);
55 }
56
57 osgDB::ReaderWriter::ReadResult
58 SGReaderWriterBTG::readNode(const std::string& fileName,
59                             const osgDB::Options* options) const
60 {
61     const SGReaderWriterOptions* sgOptions;
62     sgOptions = dynamic_cast<const SGReaderWriterOptions*>(options);
63     osg::Node* result = SGLoadBTG(fileName, sgOptions);
64     if (!result)
65         return ReadResult::FILE_NOT_HANDLED;
66
67     return result;
68 }
69
70
71 typedef ModelRegistryCallback<DefaultProcessPolicy, NoCachePolicy,
72                               NoOptimizePolicy,
73                               NoSubstitutePolicy, BuildGroupBVHPolicy>
74 BTGCallback;
75
76 namespace
77 {
78 ModelRegistryCallbackProxy<BTGCallback> g_btgCallbackProxy("btg");
79 }