]> git.mxchange.org Git - flightgear.git/blob - src/Objects/newmat.hxx
c73fd502dc9f415828d70aeb7a095a9794d4c22d
[flightgear.git] / src / Objects / newmat.hxx
1 // newmat.hxx -- class to handle material properties
2 //
3 // Written by Curtis Olson, started May 1998.
4 //
5 // Copyright (C) 1998 - 2000  Curtis L. Olson  - curt@flightgear.org
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _NEWMAT_HXX
25 #define _NEWMAT_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32 #ifdef HAVE_CONFIG_H
33 #  include <config.h>
34 #endif
35
36 #ifdef HAVE_WINDOWS_H
37 #  include <windows.h>
38 #endif
39
40 #include <plib/sg.h>
41 #include <plib/ssg.h>
42
43 #include <simgear/compiler.h>
44
45 #include <GL/glut.h>
46
47 #include STL_STRING      // Standard C++ string library
48
49 FG_USING_STD(string);
50
51
52 // MSVC++ 6.0 kuldge - Need forward declaration of friends.
53 class FGNewMat;
54 istream& operator >> ( istream& in, FGNewMat& m );
55
56 // Material property class
57 class FGNewMat {
58
59 private:
60
61     // names
62     string material_name;
63     string texture_name;
64
65     // pointers to ssg states
66     ssgStateSelector *state;
67     ssgSimpleState *textured;
68     ssgSimpleState *nontextured;
69
70     // alpha texture?
71     int alpha;
72
73     // texture size
74     double xsize, ysize;
75
76     // wrap texture?
77     int wrapu, wrapv;
78
79     // material properties
80     sgVec4 ambient, diffuse, specular, emission;
81
82 public:
83
84     // Constructor
85     FGNewMat ( void );
86     FGNewMat ( const string& name );
87     FGNewMat ( const string &mat_name, const string &tex_name );
88
89     // Destructor
90     ~FGNewMat ( void );
91
92     friend istream& operator >> ( istream& in, FGNewMat& m );
93
94     // void load_texture( const string& root );
95     void build_ssg_state( const string& path, 
96                           GLenum shade_model, bool texture_default );
97     void set_ssg_state( ssgSimpleState *s );
98
99     inline string get_material_name() const { return material_name; }
100     inline void set_material_name( const string& n ) { material_name = n; }
101
102     inline string get_texture_name() const { return texture_name; }
103     inline void set_texture_name( const string& n ) { texture_name = n; }
104
105     inline double get_xsize() const { return xsize; }
106     inline double get_ysize() const { return ysize; }
107     inline void set_xsize( double x ) { xsize = x; }
108     inline void set_ysize( double y ) { ysize = y; }
109
110     inline float *get_ambient() { return ambient; }
111     inline float *get_diffuse() { return diffuse; }
112     inline float *get_specular() { return specular; }
113     inline float *get_emission() { return emission; }
114     inline void set_ambient( sgVec4 a ) { sgCopyVec4( ambient, a ); }
115     inline void set_diffuse( sgVec4 d ) { sgCopyVec4( diffuse, d ); }
116     inline void set_specular( sgVec4 s ) { sgCopyVec4( specular, s ); }
117     inline void set_emission( sgVec4 e ) { sgCopyVec4( emission, e ); }
118
119     inline ssgStateSelector *get_state() const { return state; }
120
121     void dump_info();
122 };
123
124
125 #endif // _NEWMAT_HXX 
126
127