Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglMaterial.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglMaterial.hpp
00021  *  Created: 30 September 1997
00022  *  Summary: container for OpenGL material parameters and drawing code
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    // See sglStatelet::apply() for details.
00285    void apply(sglCurrState *curr_state) const;
00286 
00287    // See sglStatelet::getSorted() for details.
00288    virtual bool getSorted() const { return true; }
00289 
00290    // See sglObject::printInfo() for details.
00291    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00292 
00293 private:
00294    // copy constructor forbidden
00295    sglMaterial(sglMaterial &);
00296    // assignment operator forbidden
00297    sglMaterial &operator=(const sglMaterial &);
00298 
00299 private:
00300    // material color properties
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    // exponent material property
00311    float m_front_shininess;
00312    float m_back_shininess;
00313 
00314    // color material mode
00315    ColorModeEnum m_color_material_mode;
00316    SideEnum m_color_material_side;
00317 };
00318 
00319 #endif

Generated at Mon Jul 1 18:00:05 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001