]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/matlib.hxx
Modified Files:
[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 STL_STRING             // Standard C++ string library
37 #include <map>                  // STL associative "array"
38 #include <vector>               // STL "array"
39
40 #include <plib/ssg.h>           // plib include
41
42
43 class SGMaterial;
44
45 SG_USING_STD(string);
46 SG_USING_STD(map);
47 SG_USING_STD(vector);
48 SG_USING_STD(less);
49
50
51 // Material management class
52 class SGMaterialLib {
53
54 private:
55
56     // associative array of materials
57     typedef map < string, SGSharedPtr<SGMaterial>, less<string> > material_map;
58     typedef material_map::iterator material_map_iterator;
59     typedef material_map::const_iterator const_material_map_iterator;
60
61     material_map matlib;
62
63 public:
64
65     // Constructor
66     SGMaterialLib ( void );
67
68     // Load a library of material properties
69     bool load( const string &fg_root, const string& mpath, const char *season );
70
71     // Add the named texture with default properties
72     bool add_item( const string &tex_path );
73     bool add_item( const string &mat_name, const string &tex_path );
74     bool add_item( const string &mat_name, ssgSimpleState *state );
75
76     // find a material record by material name
77     SGMaterial *find( const string& material );
78
79     /**
80      * Load the next deferred texture, if there is any.
81      */
82     void load_next_deferred();
83
84     material_map_iterator begin() { return matlib.begin(); }
85     const_material_map_iterator begin() const { return matlib.begin(); }
86
87     material_map_iterator end() { return matlib.end(); }
88     const_material_map_iterator end() const { return matlib.end(); }
89
90     const SGMaterial* findMaterial(/*const*/ssgLeaf* leaf) const;
91     bool find( ssgSimpleState*, string & material ) const;
92
93     // Destructor
94     ~SGMaterialLib ( void );
95 };
96
97
98 #endif // _MATLIB_HXX