Page principale | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Composants | Déclarations | Pages associées

material.h

Aller à la documentation de ce fichier.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program 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 General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
00017 *********************************************************************************** */
00018 
00023 #ifndef INCLUDE_3D_MATERIAL_H
00024 #define INCLUDE_3D_MATERIAL_H
00025 
00026 #include "3d.h"
00027 #include "color.h"
00028 #include "variable.h"
00029 
00039 class Material
00040 {
00041 public: 
00042         int typeFace;
00043         Color ambient;
00044         Color diffuse;
00045         Color specular;
00046         Color emission;
00047         Enabling<GLint> shiness; // 0 par default
00048 
00049 public:
00050         Material()
00051         {
00052                 Zero();
00053         }
00054 
00055         void Zero()
00056         {
00057                 typeFace = GL_FRONT_AND_BACK;
00058                 ambient.Zero();
00059                 diffuse.Zero();
00060                 specular.Zero();
00061                 emission.Zero();
00062                 shiness.elem=0;
00063         }
00064 
00065         void operator=(Material &source)
00066         {
00067                 typeFace = source.typeFace;
00068 
00069                 ambient = source.ambient;
00070                 diffuse = source.diffuse;
00071                 specular = source.specular;
00072                 emission = source.emission;
00073 
00074                 shiness = source.shiness;
00075         }
00076 
00077         void SetDS (float *source)
00078         {
00079                 SetDS(source[0],source[1],source[2],source[3]);
00080         }
00081 
00082         void SetDS (float r,float g,float b,float a=0) // set diffuse and specular
00083         {
00084                 ambient.SetNull();
00085                 diffuse.Set(r,g,b,a);
00086                 specular=diffuse;
00087                 emission.SetNull();
00088         }
00089 
00090         void SetNull ()
00091         {
00092                 ambient.SetNull();
00093                 diffuse.SetNull();
00094                 specular.SetNull();
00095                 emission.SetNull();
00096         }
00097 
00098         void SetFull(BOOL includeEmission=FALSE)
00099         {
00100                 ambient.SetFull();
00101                 diffuse.SetFull();
00102                 specular.SetFull();
00103                 if (includeEmission) emission.SetFull();
00104         }
00105         void Use()
00106         {
00107                 if (ambient.isEnable)   glMaterialfv(typeFace,GL_AMBIENT,ambient);
00108                 if (diffuse.isEnable)   glMaterialfv(typeFace,GL_DIFFUSE,diffuse);
00109                 if (specular.isEnable)  glMaterialfv(typeFace,GL_SPECULAR,specular);
00110                 if (emission.isEnable)  glMaterialfv(typeFace,GL_EMISSION,emission);
00111                 if (shiness.isEnable)   glMateriali (typeFace,GL_SHININESS,shiness.elem);
00112         }
00113 };
00114 
00115 #endif

Généré le Thu Apr 8 18:52:14 2004 pour 3D Controls par doxygen 1.3.6