1 // matlib.hxx -- class to handle material properties
3 // Written by Curtis Olson, started May 1998.
5 // Copyright (C) 1998 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
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.
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.
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.
29 # error This library requires C++
32 #include <simgear/compiler.h>
34 #include <simgear/structure/SGSharedPtr.hxx>
36 #include STL_STRING // Standard C++ string library
37 #include <map> // STL associative "array"
38 #include <vector> // STL "array"
41 #include <osg/StateSet>
50 // Material management class
55 // associative array of materials
56 typedef map < string, SGSharedPtr<SGMaterial>, less<string> > material_map;
57 typedef material_map::iterator material_map_iterator;
58 typedef material_map::const_iterator const_material_map_iterator;
65 SGMaterialLib ( void );
67 // Load a library of material properties
68 bool load( const string &fg_root, const string& mpath, const char *season );
70 // Add the named texture with default properties
71 bool add_item( const string &tex_path );
72 bool add_item( const string &mat_name, const string &tex_path );
73 bool add_item( const string &mat_name, osg::StateSet *state );
75 // find a material record by material name
76 SGMaterial *find( const string& material );
79 * Load the next deferred texture, if there is any.
81 void load_next_deferred();
83 material_map_iterator begin() { return matlib.begin(); }
84 const_material_map_iterator begin() const { return matlib.begin(); }
86 material_map_iterator end() { return matlib.end(); }
87 const_material_map_iterator end() const { return matlib.end(); }
89 const SGMaterial* findMaterial(const osg::StateSet* stateSet) const;
92 ~SGMaterialLib ( void );