Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vpmaterial.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 // ChangeLog
00006 // Dec 15, 2004 - Bruno de Oliveira Schneider 
00007 // - Added PLASTIC_RED(), PLASTIC_GREEN(), PLASTIC_BLUE(), LIGHT_PLASTIC_GRAY()
00008 //   and DARK_PLASTIC_GRAY().
00009 // - Added SetDiffuseColor, SetSpecularColor, SetShininess, GetDiffuseColor, 
00010 //   SetAmbientColor and SetEmissiveColor.
00011 // Sep 24, 2004 - Bruno de Oliveira Schneider 
00012 // - File created.
00013 
00014 #include "vpmaterial.h"
00015 
00016 #ifdef VP_OGL
00017 #include <GL/gl.h>
00018 #endif
00019 
00020 //#include <iostream>
00021 //using namespace std;
00022 
00023 VPMaterial::VPMaterial()
00024 {
00025 }
00026 
00027 VPMaterial::VPMaterial(const VPMaterial& m)
00028 {
00029     color = m.color;
00030     emissive = m.emissive;
00031     ambient = m.ambient;
00032     specular = m.specular;
00033     shininess = m.shininess;
00034 }
00035 
00036 VPMaterial::VPMaterial(const VPColor& c)
00037 {
00038     color = c;
00039     c.GetScaled(0.0001f, &emissive);
00040     c.GetScaled(0.3f, &ambient);
00041     c.GetScaled(0.1f, &specular);
00042     shininess = 0.01f;
00043 }
00044 
00045 VPMaterial::VPMaterial(const VPTexture& t)
00046 {
00047 }
00048 
00049 VPMaterial::VPMaterial(const VPColor& c, float spc, float amb, float ems, float shi)
00050 {
00051     color = c;
00052     c.GetScaled(ems, &emissive);
00053     c.GetScaled(amb, &ambient);
00054     c.GetScaled(spc, &specular);
00055     shininess = shi;
00056 }
00057 
00058 VPMaterial& VPMaterial::operator=(const VPMaterial& m)
00059 {
00060     color = m.color;
00061     emissive = m.emissive;
00062     ambient = m.ambient;
00063     specular = m.specular;
00064     shininess = m.shininess;
00065     return *this;
00066 }
00067 
00068 const VPMaterial& VPMaterial::LIGHT_PLASTIC_GRAY()
00069 {
00070     static const VPMaterial lpGray(VPColor(204,204,220));
00071     return lpGray;
00072 }
00073 
00074 const VPMaterial& VPMaterial::DARK_PLASTIC_GRAY()
00075 {
00076     static const VPMaterial dpGray(VPColor(127,127,127));
00077     return dpGray;
00078 }
00079 
00080 const VPMaterial& VPMaterial::PLASTIC_RED()
00081 {
00082     static const VPMaterial pRed(VPColor::RED());
00083     return pRed;
00084 }
00085 
00086 const VPMaterial& VPMaterial::PLASTIC_GREEN()
00087 {
00088     static const VPMaterial pGreen(VPColor::GREEN());
00089     return pGreen;
00090 }
00091 
00092 const VPMaterial& VPMaterial::PLASTIC_BLUE()
00093 {
00094     static const VPMaterial pBlue(VPColor::BLUE());
00095     return pBlue;
00096 }
00097 
00098 bool VPMaterial::DrawOGL() const
00099 {
00100 #ifdef VP_OGL
00101     float fVec[4];
00102     color.Get(fVec);
00103     glColor4fv(fVec);
00104     glMaterialfv(GL_FRONT, GL_DIFFUSE, fVec);
00105     ambient.Get(fVec);
00106     glMaterialfv(GL_FRONT, GL_AMBIENT, fVec);
00107     specular.Get(fVec);
00108     glMaterialfv(GL_FRONT, GL_SPECULAR, fVec);
00109     emissive.Get(fVec);
00110     glMaterialfv(GL_FRONT, GL_EMISSION, fVec);
00111     glMaterialf(GL_FRONT, GL_SHININESS, shininess);
00112     return true;
00113 #else
00114     return false;
00115 #endif
00116 }

Generated on Tue Sep 6 10:00:04 2005 for VPAT by  doxygen 1.4.4