]> git.mxchange.org Git - flightgear.git/blob - src/Objects/newmat.hxx
c5eecac033c7c0170ece04d197dbe97574327fde
[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     // material properties
77     sgVec4 ambient, diffuse, specular, emission;
78
79 public:
80
81     // Constructor
82     FGNewMat ( void );
83     FGNewMat ( const string& name );
84     FGNewMat ( const string &mat_name, const string &tex_name );
85
86     // Destructor
87     ~FGNewMat ( void );
88
89     friend istream& operator >> ( istream& in, FGNewMat& m );
90
91     // void load_texture( const string& root );
92     void build_ssg_state( const string& path, 
93                           GLenum shade_model, bool texture_default );
94     void set_ssg_state( ssgSimpleState *s );
95
96     inline string get_material_name() const { return material_name; }
97     inline void set_material_name( const string& n ) { material_name = n; }
98
99     inline string get_texture_name() const { return texture_name; }
100     inline void set_texture_name( const string& n ) { texture_name = n; }
101
102     inline double get_xsize() const { return xsize; }
103     inline double get_ysize() const { return ysize; }
104     inline void set_xsize( double x ) { xsize = x; }
105     inline void set_ysize( double y ) { ysize = y; }
106
107     inline float *get_ambient() { return ambient; }
108     inline float *get_diffuse() { return diffuse; }
109     inline float *get_specular() { return specular; }
110     inline float *get_emission() { return emission; }
111     inline void set_ambient( sgVec4 a ) { sgCopyVec4( ambient, a ); }
112     inline void set_diffuse( sgVec4 d ) { sgCopyVec4( diffuse, d ); }
113     inline void set_specular( sgVec4 s ) { sgCopyVec4( specular, s ); }
114     inline void set_emission( sgVec4 e ) { sgCopyVec4( emission, e ); }
115
116     inline ssgStateSelector *get_state() const { return state; }
117
118     void dump_info();
119 };
120
121
122 #endif // _NEWMAT_HXX 
123
124