]> git.mxchange.org Git - simgear.git/blob - simgear/scene/util/SGReaderWriterOptions.hxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / util / SGReaderWriterOptions.hxx
1 // Copyright (C) 2007 Tim Moore timoore@redhat.com
2 // Copyright (C) 2008 Till Busch buti@bux.at
3 // Copyright (C) 2011 Mathias Froehlich
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 //
19
20 #ifndef SGREADERWRITEROPTIONS_HXX
21 #define SGREADERWRITEROPTIONS_HXX 1
22
23 #include <osgDB/Options>
24 #include <simgear/scene/model/modellib.hxx>
25 #include <simgear/props/props.hxx>
26
27 class SGPropertyNode;
28 class SGMaterialLib;
29
30 namespace simgear
31 {
32
33 class SGReaderWriterOptions : public osgDB::Options {
34 public:
35     SGReaderWriterOptions() :
36         _materialLib(0),
37         _load_panel(0),
38         _model_data(0),
39         _instantiateEffects(false)
40     { }
41     SGReaderWriterOptions(const std::string& str) :
42         osgDB::Options(str),
43         _materialLib(0),
44         _load_panel(0),
45         _model_data(0),
46         _instantiateEffects(false)
47     { }
48     SGReaderWriterOptions(const osgDB::Options& options,
49                           const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
50         osgDB::Options(options, copyop),
51         _materialLib(0),
52         _load_panel(0),
53         _model_data(0),
54         _instantiateEffects(false)
55     { }
56     SGReaderWriterOptions(const SGReaderWriterOptions& options,
57                           const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
58         osgDB::Options(options, copyop),
59         _propertyNode(options._propertyNode),
60         _materialLib(options._materialLib),
61         _load_panel(options._load_panel),
62         _model_data(options._model_data),
63         _instantiateEffects(options._instantiateEffects)
64     { }
65
66     META_Object(simgear, SGReaderWriterOptions);
67
68     const SGSharedPtr<SGPropertyNode>& getPropertyNode() const
69     { return _propertyNode; }
70     void setPropertyNode(const SGSharedPtr<SGPropertyNode>& propertyNode)
71     { _propertyNode = propertyNode; }
72
73     SGMaterialLib* getMaterialLib() const
74     { return _materialLib; }
75     void setMaterialLib(SGMaterialLib* materialLib)
76     { _materialLib = materialLib; }
77
78     typedef osg::Node *(*panel_func)(SGPropertyNode *);
79
80     panel_func getLoadPanel() const
81     { return _load_panel; }
82     void setLoadPanel(panel_func pf)
83     { _load_panel=pf; }
84
85     SGModelData *getModelData() const
86     { return _model_data.get(); }
87     void setModelData(SGModelData *modelData)
88     { _model_data=modelData; }
89
90     bool getInstantiateEffects() const
91     { return _instantiateEffects; }
92     void setInstantiateEffects(bool instantiateEffects)
93     { _instantiateEffects = instantiateEffects; }
94
95     static SGReaderWriterOptions* copyOrCreate(const osgDB::Options* options);
96     static SGReaderWriterOptions* fromPath(const std::string& path);
97
98 protected:
99     virtual ~SGReaderWriterOptions();
100
101 private:
102     SGSharedPtr<SGPropertyNode> _propertyNode;
103     SGMaterialLib* _materialLib;
104     osg::Node *(*_load_panel)(SGPropertyNode *);
105     osg::ref_ptr<SGModelData> _model_data;
106     bool _instantiateEffects;
107 };
108
109 }
110
111 #endif