1 // newmat.hxx -- class to handle material properties
3 // Written by Curtis Olson, started May 1998.
5 // Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
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., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # error This library requires C++
43 #include <simgear/compiler.h>
47 #include STL_STRING // Standard C++ string library
52 // MSVC++ 6.0 kuldge - Need forward declaration of friends.
54 istream& operator >> ( istream& in, FGNewMat& m );
56 // Material property class
65 // pointers to ssg states
66 ssgStateSelector *state;
67 ssgSimpleState *textured;
68 ssgSimpleState *nontextured;
82 // coverage of night lighting. This number is specifically the
83 // amount of area coverage we give a single light. The size of a
84 // triangle is divided by this number and that is the number of
85 // lights assigned to that triangle. Lower numbers mean more
86 // dense light ocverage.
87 double light_coverage;
89 // material properties
90 sgVec4 ambient, diffuse, specular, emission;
96 FGNewMat ( const string& name );
97 FGNewMat ( const string &mat_name, const string &tex_name );
102 friend istream& operator >> ( istream& in, FGNewMat& m );
104 // void load_texture( const string& root );
105 void build_ssg_state( const string& path,
106 GLenum shade_model, bool texture_default );
107 void set_ssg_state( ssgSimpleState *s );
109 inline string get_material_name() const { return material_name; }
110 inline void set_material_name( const string& n ) { material_name = n; }
112 inline string get_texture_name() const { return texture_name; }
113 inline void set_texture_name( const string& n ) { texture_name = n; }
115 inline double get_xsize() const { return xsize; }
116 inline double get_ysize() const { return ysize; }
117 inline void set_xsize( double x ) { xsize = x; }
118 inline void set_ysize( double y ) { ysize = y; }
120 inline float *get_ambient() { return ambient; }
121 inline float *get_diffuse() { return diffuse; }
122 inline float *get_specular() { return specular; }
123 inline float *get_emission() { return emission; }
124 inline void set_ambient( sgVec4 a ) { sgCopyVec4( ambient, a ); }
125 inline void set_diffuse( sgVec4 d ) { sgCopyVec4( diffuse, d ); }
126 inline void set_specular( sgVec4 s ) { sgCopyVec4( specular, s ); }
127 inline void set_emission( sgVec4 e ) { sgCopyVec4( emission, e ); }
129 inline double get_light_coverage () const { return light_coverage; }
130 inline void set_light_coverage (double coverage) {
131 light_coverage = coverage;
134 inline ssgStateSelector *get_state() const { return state; }
140 #endif // _NEWMAT_HXX