]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/matlib.hxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / material / matlib.hxx
1 // matlib.hxx -- class to handle material properties
2 //
3 // Written by Curtis Olson, started May 1998.
4 //
5 // Copyright (C) 1998 - 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _MATLIB_HXX
25 #define _MATLIB_HXX
26
27
28 #include <simgear/compiler.h>
29
30 #include <simgear/structure/SGSharedPtr.hxx>
31
32 #include <string>               // Standard C++ string library
33 #include <map>                  // STL associative "array"
34 #include <vector>               // STL "array"
35
36 class SGMaterial;
37 class SGPropertyNode;
38
39 namespace simgear { class Effect; }
40 namespace osg { class Geode; }
41
42 // Material management class
43 class SGMaterialLib {
44
45 private:
46
47     // associative array of materials
48     typedef std::vector< SGSharedPtr<SGMaterial> > material_list;    
49     typedef material_list::iterator material_list_iterator;
50     typedef std::map < std::string,  material_list> material_map;
51     typedef material_map::iterator material_map_iterator;
52     typedef material_map::const_iterator const_material_map_iterator;
53
54     material_map matlib;
55
56 public:
57
58     // Constructor
59     SGMaterialLib ( void );
60
61     // Load a library of material properties
62     bool load( const std::string &fg_root, const std::string& mpath,
63             SGPropertyNode *prop_root );
64     // find a material record by material name
65     SGMaterial *find( const std::string& material );
66
67     material_map_iterator begin() { return matlib.begin(); }
68     const_material_map_iterator begin() const { return matlib.begin(); }
69
70     material_map_iterator end() { return matlib.end(); }
71     const_material_map_iterator end() const { return matlib.end(); }
72
73     static const SGMaterial *findMaterial(const osg::Geode* geode);
74
75     // Destructor
76     ~SGMaterialLib ( void );
77 };
78
79
80 #endif // _MATLIB_HXX