00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __SGL_MATERIAL_HPP
00026 #define __SGL_MATERIAL_HPP
00027
00028 #include <sgl.h>
00029 #include <sglVector.hpp>
00030 #include <sglStatelet.hpp>
00031
00032
00033
00082 class SGL_DLL_API sglMaterial : public sglStatelet
00083 {
00084 public:
00086 enum SideEnum
00087 {
00089 eFRONT = GL_FRONT,
00090
00092 eBACK = GL_BACK,
00093
00095 eFRONT_AND_BACK = GL_FRONT_AND_BACK
00096 };
00097
00099 enum ColorModeEnum
00100 {
00102 eOFF = 0,
00103
00105 eAMBIENT = GL_AMBIENT,
00106
00108 eDIFFUSE = GL_DIFFUSE,
00109
00111 eSPECULAR = GL_SPECULAR,
00112
00114 eAMBIENT_AND_DIFFUSE = GL_AMBIENT_AND_DIFFUSE,
00115
00117 eEMISSION = GL_EMISSION
00118 };
00119
00120 public:
00124 sglMaterial();
00125
00127 virtual ~sglMaterial();
00128
00136 void setAmbient(float r, float g, float b,
00137 SideEnum side = eFRONT_AND_BACK);
00138
00144 void getFrontAmbient(float &r, float &g, float &b) const;
00145
00151 void getBackAmbient(float &r, float &g, float &b) const;
00152
00160 void setDiffuse(float r, float g, float b,
00161 SideEnum side = eFRONT_AND_BACK);
00162
00168 void getFrontDiffuse(float &r, float &g, float &b) const;
00169
00175 void getBackDiffuse(float &r, float &g, float &b) const;
00176
00184 void setSpecular(float r, float g, float b,
00185 SideEnum side = eFRONT_AND_BACK);
00186
00192 void getFrontSpecular(float &r, float &g, float &b) const;
00193
00199 void getBackSpecular(float &r, float &g, float &b) const;
00200
00208 void setEmission(float r, float g, float b,
00209 SideEnum side = eFRONT_AND_BACK);
00210
00216 void getFrontEmission(float &r, float &g, float &b) const;
00217
00223 void getBackEmission(float &r, float &g, float &b) const;
00224
00231 void setAlpha(float alpha, SideEnum side = eFRONT_AND_BACK);
00232
00236 float getFrontAlpha() const { return m_front_diffuse[3]; }
00237
00241 float getBackAlpha() const { return m_back_diffuse[3]; }
00242
00250 void setShininess(float shininess, SideEnum side = eFRONT_AND_BACK);
00251
00255 float getFrontShininess() const { return m_front_shininess; }
00256
00260 float getBackShininess() const { return m_back_shininess; }
00261
00273 void setColorMaterial(SideEnum side, ColorModeEnum mode);
00274
00281 void getColorMaterial(SideEnum &side, ColorModeEnum &mode) const
00282 { mode = m_color_material_mode; side = m_color_material_side; }
00283
00284
00285 void apply(sglCurrState *curr_state) const;
00286
00287
00288 virtual bool getSorted() const { return true; }
00289
00290
00291 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00292
00293 private:
00294
00295 sglMaterial(sglMaterial &);
00296
00297 sglMaterial &operator=(const sglMaterial &);
00298
00299 private:
00300
00301 sglVec4f m_front_ambient;
00302 sglVec4f m_front_diffuse;
00303 sglVec4f m_front_specular;
00304 sglVec4f m_front_emission;
00305 sglVec4f m_back_ambient;
00306 sglVec4f m_back_diffuse;
00307 sglVec4f m_back_specular;
00308 sglVec4f m_back_emission;
00309
00310
00311 float m_front_shininess;
00312 float m_back_shininess;
00313
00314
00315 ColorModeEnum m_color_material_mode;
00316 SideEnum m_color_material_side;
00317 };
00318
00319 #endif