]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/matlib.hxx
simgear/scene/sky/sky.cxx: Include sg_inlines.h with simgear/ prefix as all other...
[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 #ifndef __cplusplus
29 # error This library requires C++
30 #endif
31
32 #include <simgear/compiler.h>
33
34 #include <simgear/structure/SGSharedPtr.hxx>
35
36 #include <string>               // Standard C++ string library
37 #include <map>                  // STL associative "array"
38 #include <vector>               // STL "array"
39
40 #include <osg/Geode>
41
42 class SGMaterial;
43 class SGPropertyNode;
44
45 using std::string;
46 using std::map;
47 using std::vector;
48 using std::less;
49
50 namespace simgear
51 {
52 class Effect;
53 }
54
55 // Material management class
56 class SGMaterialLib {
57
58 private:
59
60     // associative array of materials
61     typedef map < string, SGSharedPtr<SGMaterial> > material_map;
62     typedef material_map::iterator material_map_iterator;
63     typedef material_map::const_iterator const_material_map_iterator;
64
65     material_map matlib;
66
67 public:
68
69     // Constructor
70     SGMaterialLib ( void );
71
72     // Load a library of material properties
73     bool load( const string &fg_root, const string& mpath,
74             SGPropertyNode *prop_root );
75     // find a material record by material name
76     SGMaterial *find( const string& material );
77
78     material_map_iterator begin() { return matlib.begin(); }
79     const_material_map_iterator begin() const { return matlib.begin(); }
80
81     material_map_iterator end() { return matlib.end(); }
82     const_material_map_iterator end() const { return matlib.end(); }
83
84     static const SGMaterial* findMaterial(const osg::Geode* geode);
85
86     // Destructor
87     ~SGMaterialLib ( void );
88 };
89
90
91 #endif // _MATLIB_HXX