glc_material.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib 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
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 *****************************************************************************/
00022 
00024 
00025 #include "glc_material.h"
00026 #include "../geometry/glc_geometry.h"
00027 #include "../glc_factory.h"
00028 #include "../glc_openglexception.h"
00029 
00030 #include <QtDebug>
00031 
00032 // Class chunk id
00033 quint32 GLC_Material::m_ChunkId= 0xA703;
00034 
00036 // Constructor Destructor
00038 // Default constructor
00039 GLC_Material::GLC_Material()
00040 :GLC_Object("Material")
00041 , m_AmbientColor()
00042 , m_DiffuseColor()
00043 , m_SpecularColor()
00044 , m_EmissiveColor()
00045 , m_Shininess(50.0)             // By default shininess 50
00046 , m_WhereUsed()
00047 , m_OtherUsage()
00048 , m_pTexture(NULL)                      // no texture
00049 , m_Opacity(1.0)
00050 {
00051         //qDebug() << "GLC_Material::GLC_Material" << id();
00052         // Diffuse Color
00053         initDiffuseColor();
00054 
00055         // Others
00056         initOtherColor();
00057 }
00058 
00059 GLC_Material::GLC_Material(const QColor &diffuseColor)
00060 :GLC_Object("Material")
00061 , m_AmbientColor()
00062 , m_DiffuseColor(diffuseColor)
00063 , m_SpecularColor()
00064 , m_EmissiveColor()
00065 , m_Shininess(50.0)             // By default shininess 50
00066 , m_WhereUsed()
00067 , m_OtherUsage()
00068 , m_pTexture(NULL)                      // no texture
00069 , m_Opacity(1.0)
00070 {
00071         // Others
00072         initOtherColor();
00073 }
00074 
00075 
00076 GLC_Material::GLC_Material(const QString& name ,const GLfloat *pDiffuseColor)
00077 :GLC_Object(name)
00078 , m_AmbientColor()
00079 , m_DiffuseColor()
00080 , m_SpecularColor()
00081 , m_EmissiveColor()
00082 , m_Shininess(50.0)             // By default shininess 50
00083 , m_WhereUsed()
00084 , m_OtherUsage()
00085 , m_pTexture(NULL)                      // no texture
00086 , m_Opacity(1.0)
00087 {
00088         //qDebug() << "GLC_Material::GLC_Material" << id();
00089         // Init Diffuse Color
00090         if (pDiffuseColor != 0)
00091         {
00092                 m_DiffuseColor.setRgbF(static_cast<qreal>(pDiffuseColor[0]),
00093                                                                 static_cast<qreal>(pDiffuseColor[1]),
00094                                                                 static_cast<qreal>(pDiffuseColor[2]),
00095                                                                 static_cast<qreal>(pDiffuseColor[3]));
00096         }
00097         else
00098         {
00099                 initDiffuseColor();
00100         }
00101         // Others
00102         initOtherColor();
00103 }
00104 GLC_Material::GLC_Material(GLC_Texture* pTexture, const QString& name)
00105 :GLC_Object(name)
00106 , m_AmbientColor()
00107 , m_DiffuseColor()
00108 , m_SpecularColor()
00109 , m_EmissiveColor()
00110 , m_Shininess(50.0)             // By default shininess 50
00111 , m_WhereUsed()
00112 , m_OtherUsage()
00113 , m_pTexture(pTexture)                  // init texture
00114 , m_Opacity(1.0)
00115 {
00116         Q_ASSERT(NULL != m_pTexture);
00117         //qDebug() << "GLC_Material::GLC_Material" << id();
00118 
00119         // Diffuse Color
00120         initDiffuseColor();
00121 
00122         // Others
00123         initOtherColor();
00124 
00125         //if (m_pTexture->hasAlphaChannel()) m_Transparency= 0.99;
00126 }
00127 
00128 // Copy constructor
00129 GLC_Material::GLC_Material(const GLC_Material &InitMaterial)
00130 :GLC_Object(InitMaterial)
00131 , m_AmbientColor(InitMaterial.m_AmbientColor)
00132 , m_DiffuseColor(InitMaterial.m_DiffuseColor)
00133 , m_SpecularColor(InitMaterial.m_SpecularColor)
00134 , m_EmissiveColor(InitMaterial.m_EmissiveColor)
00135 , m_Shininess(InitMaterial.m_Shininess)
00136 , m_WhereUsed()
00137 , m_OtherUsage()
00138 , m_pTexture(NULL)
00139 , m_Opacity(InitMaterial.m_Opacity)
00140 {
00141         //qDebug() << "GLC_Material::GLC_Material copy constructor" << id();
00142         if (NULL != InitMaterial.m_pTexture)
00143         {
00144                 m_pTexture= new GLC_Texture(*(InitMaterial.m_pTexture));
00145                 Q_ASSERT(m_pTexture != NULL);
00146         }
00147 
00148 }
00149 
00150 // Destructor
00151 GLC_Material::~GLC_Material(void)
00152 {
00153         delete m_pTexture;
00154 }
00155 
00156 
00158 // Get Functions
00160 // Return the class Chunk ID
00161 quint32 GLC_Material::chunckID()
00162 {
00163         return m_ChunkId;
00164 }
00165 
00166 // Get Ambiant color
00167 QColor GLC_Material::ambientColor() const
00168 {
00169         return m_AmbientColor;
00170 }
00171 
00172 // Get diffuse color
00173 QColor GLC_Material::diffuseColor() const
00174 {
00175         return m_DiffuseColor;
00176 }
00177 
00178 // Get specular color
00179 QColor GLC_Material::specularColor() const
00180 {
00181         return m_SpecularColor;
00182 }
00183 
00184 // Get the emissive color
00185 QColor GLC_Material::emissiveColor() const
00186 {
00187         return m_EmissiveColor;
00188 }
00189 // Get the texture File Name
00190 QString GLC_Material::textureFileName() const
00191 {
00192         if (m_pTexture != NULL)
00193         {
00194                 return m_pTexture->fileName();
00195         }
00196         else
00197         {
00198                 return "";
00199         }
00200 }
00201 
00202 // Get Texture Id
00203 GLuint GLC_Material::textureID() const
00204 {
00205         if (m_pTexture != NULL)
00206         {
00207                 return m_pTexture->GL_ID();
00208         }
00209         else
00210         {
00211                 return 0;
00212         }
00213 
00214 }
00215 
00216 // return true if the texture is loaded
00217 bool GLC_Material::textureIsLoaded() const
00218 {
00219         if (m_pTexture != NULL)
00220         {
00221                 return m_pTexture->isLoaded();
00222         }
00223         else
00224         {
00225                 return false;
00226         }
00227 }
00228 
00229 // Return true if materials are equivalent
00230 bool GLC_Material::operator==(const GLC_Material& mat) const
00231 {
00232         bool result;
00233         if (this == &mat)
00234         {
00235                 result= true;
00236         }
00237         else
00238         {
00239                 result= m_AmbientColor == mat.m_AmbientColor;
00240                 result= result && (m_DiffuseColor == mat.m_DiffuseColor);
00241                 result= result && (m_SpecularColor == mat.m_SpecularColor);
00242                 result= result && (m_EmissiveColor == mat.m_EmissiveColor);
00243                 result= result && (m_Shininess == mat.m_Shininess);
00244                 if ((NULL != m_pTexture) && (NULL != mat.m_pTexture))
00245                 {
00246                         result= result && ((*m_pTexture) == (*mat.m_pTexture));
00247                 }
00248                 else
00249                 {
00250                         result= result && (m_pTexture == mat.m_pTexture);
00251                 }
00252                 result= result && (m_Opacity == mat.m_Opacity);
00253         }
00254         return result;
00255 }
00256 
00257 // Return the material hash code
00258 uint GLC_Material::hashCode() const
00259 {
00260         QString stringKey= QString::number(m_AmbientColor.rgba());
00261         stringKey+= QString::number(m_DiffuseColor.rgba());
00262         stringKey+= QString::number(m_SpecularColor.rgba());
00263         stringKey+= QString::number(m_EmissiveColor.rgba());
00264         stringKey+= QString::number(m_Shininess);
00265         stringKey+= QString::number(m_Opacity);
00266         if (NULL != m_pTexture)
00267         {
00268                 stringKey+= m_pTexture->fileName();
00269         }
00270 
00271         return qHash(stringKey);
00272 }
00273 
00275 // Set Functions
00277 // Set Material properties
00278  void GLC_Material::setMaterial(const GLC_Material* pMat)
00279  {
00280         if (NULL != pMat->m_pTexture)
00281         {
00282                 GLC_Texture* pTexture= new GLC_Texture(*(pMat->m_pTexture));
00283                 setTexture(pTexture);
00284         }
00285         else if (NULL != m_pTexture)
00286         {
00287                 qDebug() << "Delete texture";
00288                 delete m_pTexture;
00289                 m_pTexture= NULL;
00290         }
00291         // Ambient Color
00292         m_AmbientColor= pMat->m_AmbientColor;
00293         // Diffuse Color
00294         m_DiffuseColor= pMat->m_DiffuseColor;
00295         // Specular Color
00296         m_SpecularColor= pMat->m_SpecularColor;
00297         // Lighting emit
00298         m_EmissiveColor= pMat->m_EmissiveColor;
00299         // Shininess
00300         m_Shininess= pMat->m_Shininess;
00301         // Transparency
00302         m_Opacity= pMat->m_Opacity;
00303         // Update geometry which use this material
00304         WhereUsed::const_iterator iGeom= m_WhereUsed.constBegin();
00305         while (iGeom != m_WhereUsed.constEnd())
00306         {
00307                 iGeom.value()->updateTransparentMaterialNumber();
00308                 ++iGeom;
00309         }
00310 
00311  }
00312 
00313 // Set Ambiant Color
00314 void GLC_Material::setAmbientColor(const QColor& ambientColor)
00315 {
00316         m_AmbientColor= ambientColor;
00317         m_AmbientColor.setAlphaF(m_Opacity);
00318 }
00319 
00320 // Set Diffuse color
00321 void GLC_Material::setDiffuseColor(const QColor& diffuseColor)
00322 {
00323         m_DiffuseColor= diffuseColor;
00324         m_DiffuseColor.setAlphaF(m_Opacity);
00325 }
00326 
00327 // Set Specular color
00328 void GLC_Material::setSpecularColor(const QColor& specularColor)
00329 {
00330         m_SpecularColor= specularColor;
00331         m_SpecularColor.setAlphaF(m_Opacity);
00332 }
00333 
00334 // Set Emissive
00335 void GLC_Material::setEmissiveColor(const QColor& lightEmission)
00336 {
00337         m_EmissiveColor= lightEmission;
00338         m_EmissiveColor.setAlphaF(m_Opacity);
00339 }
00340 
00341 // Set Texture
00342 void GLC_Material::setTexture(GLC_Texture* pTexture)
00343 {
00344         Q_ASSERT(NULL != pTexture);
00345         //qDebug() << "GLC_Material::SetTexture";
00346         if (m_pTexture != NULL)
00347         {
00348                 delete m_pTexture;
00349                 m_pTexture= pTexture;
00350                 glLoadTexture();
00351         }
00352         else
00353         {
00354                 // It is not sure that there is OpenGL context
00355                 m_pTexture= pTexture;
00356         }
00357 
00358         //if (m_pTexture->hasAlphaChannel()) m_Transparency= 0.99;
00359 }
00360 
00361 // remove Material Texture
00362 void GLC_Material::removeTexture()
00363 {
00364         if (m_pTexture != NULL)
00365         {
00366                 delete m_pTexture;
00367                 m_pTexture= NULL;
00368         }
00369 }
00370 
00371 // Add Geometry to where used hash table
00372 bool GLC_Material::addGLC_Geom(GLC_Geometry* pGeom)
00373 {
00374         QMutexLocker mutexLocker(&m_Mutex);
00375         //qDebug() << "GLC_Material::addGLC_Geom" << pGeom->id();
00376         WhereUsed::iterator iGeom= m_WhereUsed.find(pGeom->id());
00377 
00378         if (iGeom == m_WhereUsed.end())
00379         {       // Ok, ID doesn't exist
00380                 // Add Geometry to where used hash table
00381                 m_WhereUsed.insert(pGeom->id(), pGeom);
00382                 return true;
00383         }
00384         else
00385         {       // KO, ID exist
00386                 qDebug("GLC_Material::addGLC_Geom : Geometry not added");
00387                 return false;
00388         }
00389 }
00390 
00391 // Remove a geometry from the collection
00392 bool GLC_Material::delGLC_Geom(GLC_uint Key)
00393 {
00394         QMutexLocker mutexLocker(&m_Mutex);
00395 
00396         if (m_WhereUsed.contains(Key))
00397         {       // Ok, ID exist
00398                 m_WhereUsed.remove(Key);        // Remove container
00399 
00400                 return true;
00401         }
00402         else
00403         {       // KO doesn't exist
00404                 qDebug("GLC_Material::delGLC_Geom : Geometry not remove");
00405                 return false;
00406         }
00407 
00408 }
00409 // Add the id to the other used Set
00410 bool GLC_Material::addUsage(GLC_uint id)
00411 {
00412         QMutexLocker mutexLocker(&m_Mutex);
00413         if (!m_OtherUsage.contains(id))
00414         {
00415                 m_OtherUsage << id;
00416                 return true;
00417         }
00418         else
00419         {
00420                 qDebug("GLC_Material::addUsage : id not added");
00421                 return false;
00422         }
00423 }
00424 
00425 // Remove the id to the other used Set
00426 bool GLC_Material::delUsage(GLC_uint id)
00427 {
00428         QMutexLocker mutexLocker(&m_Mutex);
00429         if (m_OtherUsage.contains(id))
00430         {
00431                 m_OtherUsage.remove(id);
00432                 return true;
00433         }
00434         else
00435         {
00436                 qDebug() << "GLC_Material::delUsage : id not removed " << m_Uid;
00437                 return false;
00438         }
00439 }
00440 
00441 
00442 // Set the material opacity
00443 void GLC_Material::setOpacity(const qreal alpha)
00444 {
00445         m_Opacity= alpha;
00446         m_AmbientColor.setAlphaF(m_Opacity);
00447         m_DiffuseColor.setAlphaF(m_Opacity);
00448         m_SpecularColor.setAlphaF(m_Opacity);
00449         m_EmissiveColor.setAlphaF(m_Opacity);
00450         // Update geometry which use this material
00451         WhereUsed::const_iterator iGeom= m_WhereUsed.constBegin();
00452         while (iGeom != m_WhereUsed.constEnd())
00453         {
00454                 iGeom.value()->updateTransparentMaterialNumber();
00455                 ++iGeom;
00456         }
00457 }
00458 
00460 // OpenGL Functions
00462 
00463 // Load the texture
00464 void GLC_Material::glLoadTexture(QGLContext* pContext)
00465 {
00466         if (m_pTexture != NULL)
00467         {
00468                 m_pTexture->glLoadTexture(pContext);
00469         }
00470         else
00471         {
00472                 qDebug() << "GLC_Material::glLoadTexture : Material without texture !";
00473         }
00474 }
00475 
00476 // Execute OpenGL Material
00477 void GLC_Material::glExecute()
00478 {
00479 
00480         GLfloat pAmbientColor[4]= {ambientColor().redF(),
00481                                                                 ambientColor().greenF(),
00482                                                                 ambientColor().blueF(),
00483                                                                 ambientColor().alphaF()};
00484 
00485         GLfloat pDiffuseColor[4]= {diffuseColor().redF(),
00486                                                                 diffuseColor().greenF(),
00487                                                                 diffuseColor().blueF(),
00488                                                                 diffuseColor().alphaF()};
00489 
00490         GLfloat pSpecularColor[4]= {specularColor().redF(),
00491                                                                 specularColor().greenF(),
00492                                                                 specularColor().blueF(),
00493                                                                 specularColor().alphaF()};
00494 
00495         GLfloat pLightEmission[4]= {emissiveColor().redF(),
00496                                                                 emissiveColor().greenF(),
00497                                                                 emissiveColor().blueF(),
00498                                                                 emissiveColor().alphaF()};
00499 
00500         const bool textureIsEnable= glIsEnabled(GL_TEXTURE_2D);
00501         if (m_pTexture != NULL)
00502         {
00503                 if (!textureIsEnable) glEnable(GL_TEXTURE_2D);
00504                 m_pTexture->glcBindTexture();
00505                 if (GLC_State::glslUsed())
00506                 {
00507                         if (GLC_Shader::hasActiveShader())
00508                         {
00509                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("tex", GLint(0));
00510                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("useTexture", true);
00511                         }
00512                 }
00513 
00514         }
00515         else
00516         {
00517 
00518                 if (GLC_State::glslUsed() && GLC_Shader::hasActiveShader())
00519                 {
00520                                 if (!textureIsEnable) glEnable(GL_TEXTURE_2D);
00521                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("tex", GLint(0));
00522                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("useTexture", false);
00523                 }
00524                 else
00525                 {
00526                         if (textureIsEnable) glDisable(GL_TEXTURE_2D);
00527                 }
00528 
00529         }
00530 
00531         glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pAmbientColor);
00532         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pDiffuseColor);
00533         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pSpecularColor);
00534         glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pLightEmission);
00535         glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, &m_Shininess);
00536 
00537         glColor4fv(pDiffuseColor);
00538 
00539 
00540         // OpenGL Error handler
00541         GLenum error= glGetError();
00542         if (error != GL_NO_ERROR)
00543         {
00544                 GLC_OpenGlException OpenGlException("GLC_Material::glExecute() ", error);
00545                 throw(OpenGlException);
00546         }
00547 
00548 }
00549 
00550 // Execute OpenGL Material
00551 void GLC_Material::glExecute(float overwriteTransparency)
00552 {
00553         GLfloat pAmbientColor[4]= {ambientColor().redF(),
00554                                                                 ambientColor().greenF(),
00555                                                                 ambientColor().blueF(),
00556                                                                 overwriteTransparency};
00557 
00558         GLfloat pDiffuseColor[4]= {diffuseColor().redF(),
00559                                                                 diffuseColor().greenF(),
00560                                                                 diffuseColor().blueF(),
00561                                                                 overwriteTransparency};
00562 
00563         GLfloat pSpecularColor[4]= {specularColor().redF(),
00564                                                                 specularColor().greenF(),
00565                                                                 specularColor().blueF(),
00566                                                                 overwriteTransparency};
00567 
00568         GLfloat pLightEmission[4]= {emissiveColor().redF(),
00569                                                                 emissiveColor().greenF(),
00570                                                                 emissiveColor().blueF(),
00571                                                                 overwriteTransparency};
00572 
00573         const bool textureIsEnable= glIsEnabled(GL_TEXTURE_2D);
00574 
00575         if (m_pTexture != NULL)
00576         {
00577                 if (!textureIsEnable) glEnable(GL_TEXTURE_2D);
00578                 m_pTexture->glcBindTexture();
00579                 if (GLC_State::glslUsed())
00580                 {
00581                         if (GLC_Shader::hasActiveShader())
00582                         {
00583                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("tex", GLint(0));
00584                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("useTexture", true);
00585                         }
00586                 }
00587         }
00588         else
00589         {
00590                 if (textureIsEnable) glDisable(GL_TEXTURE_2D);
00591                 if (GLC_State::glslUsed())
00592                 {
00593                         if (GLC_Shader::hasActiveShader())
00594                         {
00595                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("tex", GLint(0));
00596                                 GLC_Shader::currentShaderHandle()->programShaderHandle()->setUniformValue("useTexture", false);
00597                         }
00598                 }
00599         }
00600 
00601         glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pAmbientColor);
00602         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pDiffuseColor);
00603         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pSpecularColor);
00604         glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pLightEmission);
00605         glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, &m_Shininess);
00606 
00607         glColor4fv(pDiffuseColor);
00608 
00609         // OpenGL Error handler
00610         GLenum error= glGetError();
00611         if (error != GL_NO_ERROR)
00612         {
00613                 GLC_OpenGlException OpenGlException("GLC_Material::glExecute(float overwriteTransparency) ", error);
00614                 throw(OpenGlException);
00615         }
00616 }
00617 
00619 // Private servicies Functions
00621 
00622 // Init Ambiant Color
00623 void GLC_Material::initDiffuseColor(void)
00624 {
00625         m_DiffuseColor.setRgbF(1.0, 1.0, 1.0, 1.0);
00626 }
00627 
00628 // Init default color
00629 void GLC_Material::initOtherColor(void)
00630 {
00631         //Ambiant Color
00632         m_AmbientColor.setRgbF(0.8, 0.8, 0.8, 1.0);
00633 
00634         // Specular Color
00635         m_SpecularColor.setRgbF(0.5, 0.5, 0.5, 1.0);
00636 
00637         // Lighting emit
00638         m_EmissiveColor.setRgbF(0.0, 0.0, 0.0, 1.0);
00639 }
00640 
00641 // Non Member methods
00642 // Non-member stream operator
00643 QDataStream &operator<<(QDataStream &stream, const GLC_Material &material)
00644 {
00645         quint32 chunckId= GLC_Material::m_ChunkId;
00646         stream << chunckId;
00647 
00648         // Store GLC_Object class members
00649         stream << material.id() << material.name();
00650 
00651         // Store GLC_Material class members
00652         stream << material.ambientColor() << material.diffuseColor() << material.specularColor();
00653         stream << material.emissiveColor() << material.shininess() << material.opacity();
00654 
00655         // Test if the material has texture
00656         bool hasTexture= material.hasTexture();
00657         stream << hasTexture;
00658         if (hasTexture)
00659         {
00660                 GLC_Texture texture(*(material.textureHandle()));
00661                 stream << texture;
00662         }
00663 
00664         return stream;
00665 }
00666 QDataStream &operator>>(QDataStream &stream, GLC_Material &material)
00667 {
00668         quint32 chunckId;
00669         stream >> chunckId;
00670 
00671         Q_ASSERT(chunckId == GLC_Material::m_ChunkId);
00672 
00673         // Retrieve GLC_Object members
00674         GLC_uint id;
00675         QString name;
00676         stream >> id >> name;
00677         material.setId(id);
00678         material.setName(name);
00679 
00680         // Retrieve GLC_Material members
00681         QColor ambient, diffuse, specular, lightEmission;
00682         float shininess;
00683         double alpha;
00684         stream >> ambient >> diffuse >> specular >> lightEmission;
00685         stream >> shininess >> alpha;
00686         material.setAmbientColor(ambient);
00687         material.setDiffuseColor(diffuse);
00688         material.setSpecularColor(specular);
00689         material.setEmissiveColor(lightEmission);
00690         material.setShininess(shininess);
00691         material.setOpacity(alpha);
00692 
00693         // Test if material has texture
00694         bool hasTexture;
00695         stream >> hasTexture;
00696         if (hasTexture)
00697         {
00698                 GLC_Texture texture;
00699                 stream >> texture;
00700                 material.setTexture(new GLC_Texture(texture));
00701         }
00702         return stream;
00703 }

SourceForge.net Logo

©2005-2011 Laurent Ribon