00001 /* -*- C++ -*- */ 00002 00003 /* COPYRIGHT 00004 * 00005 * This file is part of the Visual Effects Engine - VEE 00006 * 00007 * Read the "VEE-LICENSE" file for the license. 00008 * 00009 * Authors & Copyright: 00010 * 00011 * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 00012 * Janne Kontkanen 2001-2004 00013 * 00014 * Additional copyrights: Tekes 2003-2004 00015 * 00016 * firstname.lastname@hut.fi 00017 * 00018 */ 00019 00020 #ifndef GEE_MATERIAL_HPP 00021 #define GEE_MATERIAL_HPP 00022 00023 #include <vee_vector4.h> 00024 00025 #include <string> 00026 00027 class GEE_Io; 00028 00029 enum GEE_MaterialFlag { 00031 GEE_MAT_BLEND = 0x1, 00033 GEE_MAT_LIGHTING = 0x2, 00035 GEE_MAT_SMOOTH = 0x4, 00037 GEE_MAT_TWO_SIDED = 0x8, 00039 GEE_MAT_VERTEX_COLORS = 0x10 00040 }; 00041 00042 class GEE_Material 00043 { 00044 public: 00045 00046 GEE_Material(float shine = 0.5, 00047 const VEE_Vector4 & color = VEE_Vector4ONE, 00048 int flags = GEE_MAT_LIGHTING | GEE_MAT_SMOOTH | GEE_MAT_TWO_SIDED); 00049 ~GEE_Material(); 00050 00051 bool read(GEE_Io *); 00052 bool write(GEE_Io *); 00053 00054 float shine() const { return m_shine; } 00055 void setShine(float s) { m_shine = s; } 00056 00057 int flags() const { return m_flags; } 00058 void setFlags(int f) { m_flags = f; } 00059 00061 void setColor(const VEE_Vector4 & c) 00062 { m_ambient = m_diffuse = m_specular = c; } 00063 00064 const VEE_Vector4 & ambient() const { return m_ambient; } 00065 void setAmbient(const VEE_Vector4 & color) { m_ambient = color; } 00066 00067 const VEE_Vector4 & diffuse() const { return m_diffuse; } 00068 void setDiffuse(const VEE_Vector4 & color) { m_diffuse = color; } 00069 00070 const VEE_Vector4 & specular() const { return m_specular; } 00071 void setSpecular(const VEE_Vector4 & color) { m_specular = color; } 00072 00073 float burn() const { return m_burn; } 00074 void setBurn(float b) { m_burn = b; } 00075 00076 bool useVertexColors() const 00077 { return (m_flags & GEE_MAT_VERTEX_COLORS) != 0; } 00078 void setUseVertexColors(bool useColors) 00079 { 00080 if(useColors) m_flags |= GEE_MAT_VERTEX_COLORS; 00081 else m_flags &= ~(GEE_MAT_VERTEX_COLORS); 00082 } 00083 00084 void setTwoSided(bool twoSided) 00085 { 00086 if(twoSided) m_flags |= GEE_MAT_TWO_SIDED; 00087 else m_flags &= ~(GEE_MAT_TWO_SIDED); 00088 } 00089 00090 void enableBlend(bool blend) 00091 { 00092 if(blend) m_flags |= GEE_MAT_BLEND; 00093 else m_flags &= ~(GEE_MAT_BLEND); 00094 } 00095 00096 bool blend() const { return m_flags & GEE_MAT_BLEND; } 00097 00098 const std::string & texture() const { return m_texture; } 00099 void setTexture(const std::string &t) { m_texture = t; } 00100 00101 bool operator == (const GEE_Material & that); 00102 00103 protected: 00104 float m_shine; 00106 VEE_Vector4 m_ambient, m_diffuse, m_specular; 00107 00108 float m_burn; 00109 00110 int m_flags; 00111 00112 std::string m_texture; 00113 }; 00114 00115 00116 #endif 00117