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