00001 00002 /* 00003 TEDDY - General graphics application library 00004 Copyright (C) 1999-2002 Timo Suoranta 00005 tksuoran@cc.helsinki.fi 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 $Id: Material.h,v 1.5 2002/01/17 18:57:37 tksuoran Exp $ 00022 */ 00023 00024 00025 #ifndef TEDDY__MATERIALS__MATERIAL__H 00026 #define TEDDY__MATERIALS__MATERIAL__H 00027 00028 00029 #include "Teddy/Graphics/Color.h" 00030 #include "Teddy/Materials/Render.h" 00031 #include "Teddy/MixIn/Named.h" 00032 #include "Teddy/MixIn/Options.h" 00033 #include "SDL_types.h" 00034 00035 00036 // Forward declarations 00037 namespace Teddy { 00038 namespace Graphics { class Texture; }; 00039 }; 00040 using namespace Teddy::Graphics; 00041 using namespace Teddy::MixIn; 00042 00043 00044 namespace Teddy { 00045 namespace Materials { 00046 00047 00057 class Material : public Named, public Options { 00058 public: 00059 Material( const Material &material ); 00060 Material( const Material &material, Uint8 lighting ); 00061 Material( const std::string &name ); 00062 Material( const std::string &name, Uint8 mode, Uint8 lighting, unsigned long options ); 00063 Material( const std::string &name, Color color ); 00064 Material( Color color ); 00065 Material( const std::string &name, const unsigned long options ); 00066 virtual ~Material(); 00067 00068 void applyAmbient ( Uint8 lighting ); 00069 void applyDiffuse ( Uint8 lighting ); 00070 void applySpecular ( Uint8 lighting ); 00071 void applyEmission ( Uint8 lighting ); 00072 void applyShinyness ( Uint8 lighting ); 00073 void applyBorder ( Uint8 lighting ); 00074 00075 virtual void setMode ( Uint8 mode ); 00076 virtual Uint8 getMode () const; 00077 virtual void setLighting ( Uint8 lighting ); 00078 virtual Uint8 getLighting () const; 00079 00080 virtual void setEmission ( const Color &e ); 00081 virtual Color getEmission () const; 00082 virtual void setAmbient ( const Color &a ); 00083 virtual Color getAmbient () const; 00084 virtual void setDiffuse ( const Color &d ); 00085 virtual Color getDiffuse () const; 00086 virtual void setSpecular ( const Color &s ); 00087 virtual Color getSpecular () const; 00088 virtual void setShininess ( float s ); 00089 virtual float getShininess () const; 00090 virtual void setBorder ( const Color &s ); 00091 virtual Color getBorder () const; 00092 virtual void setPolygonOffset ( const int offset ); 00093 virtual int getPolygonOffset () const; 00094 virtual void setMaxSmoothingAngle( const float angle ); 00095 virtual float getMaxSmoothingAngle() const; 00096 virtual Texture *getTexture (); 00097 virtual void setTexture ( Texture *t, bool enable=false ); 00098 00099 protected: 00100 Texture *texture; 00101 Uint8 render_mode; 00102 Uint8 render_lighting; 00103 float shininess; 00104 Color ambient; 00105 Color diffuse; 00106 Color specular; 00107 Color emission; 00108 Color border; 00109 int polygon_offset; 00110 float max_smoothing_angle; 00111 00112 public: 00113 static Material BLACK; 00114 static Material GRAY_25; 00115 static Material GRAY_50; 00116 static Material GRAY_75; 00117 static Material WHITE; 00118 static Material RED; 00119 static Material YELLOW; 00120 static Material ORANGE; 00121 static Material GREEN; 00122 static Material CYAN; 00123 static Material BLUE; 00124 static Material MAGENTA; 00125 static Material DARK_ORANGE; 00126 static Material DARK_RED; 00127 static Material DARK_YELLOW; 00128 static Material DARK_GREEN; 00129 static Material DARK_CYAN; 00130 static Material DARK_BLUE; 00131 static Material DARK_MAGENTA; 00132 static Material LIGHT_ORANGE; 00133 static Material LIGHT_RED; 00134 static Material LIGHT_YELLOW; 00135 static Material LIGHT_GREEN; 00136 static Material LIGHT_CYAN; 00137 static Material LIGHT_BLUE; 00138 static Material LIGHT_MAGENTA; 00139 }; 00140 00141 00142 }; // namespace Materials 00143 }; // namespace Teddy 00144 00145 00146 #endif // TEDDY__MATERIALS__MATERIAL_H 00147