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

material.h

Go to the documentation of this file.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-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 #include "mystring.h"
00030 #include "recorder.h"
00031 
00032 
00034 typedef struct 
00035 {
00036         MyString name;
00037         float ambient[4];
00038         float diffuse[4];
00039         float specular[4];
00040         float shininess;
00041 } AsMaterial;
00042 
00043 #define NB_MATERIAL 24
00044 
00045 typedef enum
00046 {
00047         mat_brass = 0,
00048         mat_bronze,
00049         mat_polished_bronze,
00050         mat_chrome,
00051         mat_copper,
00052         mat_polished_copper,
00053         mat_gold,
00054         mat_polished_gold,
00055         mat_pewter,
00056         mat_silver,
00057         mat_polished_silver,
00058         mat_emerald,
00059         mat_jade,
00060         mat_obsidian,
00061         mat_pearl,
00062         mat_ruby,
00063         mat_turquoise,
00064         mat_black_plastic,
00065         mat_black_rubber,
00066         mat_cyan_rubber,
00067         mat_green_rubber,
00068         mat_red_rubber,
00069         mat_white_rubber,
00070         mat_yellow_rubber
00071 } TypeMaterial;
00072 
00084 class Material
00085 {
00086 public: 
00087         int typeFace;
00088         Color ambient;
00089         Color diffuse;
00090         Color specular;
00091         Color emission;
00092         Enabling<GLint> shiness; 
00093         float opacity;
00094         Recorder recorder;              
00095 public:
00096         Material();
00097         void Zero();
00098         void operator=(Material &source);
00099         void SetDS (Color color);
00100         void SetDS (float *source);
00101         void SetDS (float r,float g,float b);
00102         void SetDS (float r,float g,float b,float a);
00103         void SetAlpha(float alpha);
00104         void SetNull ();
00105         void SetFull(BOOL includeEmission=FALSE);
00106         void Use();
00107         void As(TypeMaterial mat);
00108         void Record();
00109         void Play();
00110 };
00111 
00112 /* source http://www.cs.utk.edu/~kuck/materials_ogl.htm -et-
00113 http://devernay.free.fr/cours/opengl/materials.html */
00115 static AsMaterial materials[]= 
00116 { 
00117         {       
00118                 "Brass", // laiton
00119                 {0.329412f,             0.223529f,      0.027451f,      1.0f},
00120                 {0.780392f,             0.568627f,      0.113725f,      1.0f},
00121                 {0.992157f,             0.941176f,      0.807843f,      1.0f}, 
00122                 27.8974f
00123         },{
00124                 "Bronze", // bronze
00125                 {0.2125f,       0.1275f,        0.054f,         1.0f},
00126                 {0.714f,        0.4284f,        0.18144f,       1.0f},
00127                 {0.393548f, 0.271906f,  0.166721f,      1.0f},
00128                 25.6f
00129         },{
00130                 "Polished Bronze", // bronze polie
00131                 {0.25f,         0.148f,         0.06475f,       1.0f},
00132                 {0.4f,          0.2368f,        0.1036f,        1.0f},
00133                 {0.774597f, 0.458561f,  0.200621f,      1.0f},
00134                 76.8f
00135         },{
00136                 "Chrome", // chrome
00137                 {0.25f,         0.25f,          0.25f,          1.0f},
00138                 {0.4f,          0.4f,           0.4f,           1.0f},
00139                 {0.774597f, 0.774597f,  0.774597f,      1.0f},
00140                 76.8f
00141         },{
00142                 "Copper", // cuivre 
00143                 {0.19125f,      0.0735f,        0.0225f,        1.0f},
00144                 {0.7038f,       0.27048f,       0.0828f,        1.0f},
00145                 {0.256777f, 0.137622f,  0.086014f,      1.0f},
00146                 12.8f
00147         },{
00148                 "Polished Copper", // cuivre polie
00149                 {0.2295f,       0.08825f,       0.0275f,        1.0f},
00150                 {0.5508f,       0.2118f,        0.066f,         1.0f},
00151                 {0.580594f, 0.223257f,  0.0695701f, 1.0f},
00152                 51.2f
00153         },{
00154                 "Gold", // or
00155                 {0.24725f,      0.1995f,        0.0745f,        1.0f},
00156                 {0.75164f,      0.60648f,       0.22648f,       1.0f},
00157                 {0.628281f,     0.555802f,      0.366065f,      1.0f},
00158                 51.2f
00159         },{
00160                 "Polished Gold", // or polie
00161                 {0.24725f,      0.2245f,        0.0645f,        1.0f},
00162                 {0.34615f,      0.3143f,        0.0903f,        1.0f},
00163                 {0.797357f,     0.723991f,      0.208006f,      1.0f},
00164                 83.2f
00165         },{
00166                 "Pewter", // etain
00167                 {0.105882f,     0.058824f,      0.113725f,      1.0f},
00168                 {0.427451f, 0.470588f,  0.541176f,      1.0f}, 
00169                 {0.333333f, 0.333333f,  0.521569f,      1.0f},
00170                 9.84615f
00171         },{
00172                 "Silver", // argent
00173                 {0.19225f,      0.19225f,       0.19225f,       1.0f},
00174                 {0.50754f,      0.50754f,       0.50754f ,      1.0f},
00175                 {0.508273f,     0.508273f,      0.508273f,      1.0f},
00176                 51.2f
00177         },{
00178                 "Polished Silver", // argent polie
00179                 {0.23125f,      0.23125f,       0.23125f,       1.0f},
00180                 {0.2775f,       0.2775f,        0.2775f,        1.0f},
00181                 {0.773911f, 0.773911f,  0.773911f,      1.0f},
00182                 89.6f
00183         },{
00184                 "Emerald", // emeraude
00185                 {0.0215f,       0.1745f,        0.0215f,        0.55f},
00186                 {0.07568f,      0.61424f,       0.07568f,       0.55f},
00187                 {0.633f,        0.727811f,      0.633f,         0.55f},
00188                 76.8f
00189         },{
00190                 "Jade", // jade
00191                 {0.135f,        0.2225f,        0.1575f,        0.95f},
00192                 {0.54f,         0.89f,          0.63f,          0.95f},
00193                 {0.316228f, 0.316228f,  0.316228f,      0.95f},
00194                 12.8f
00195         },{
00196                 "Obsidian", // obsidien
00197                 {0.05375f,      0.05f,          0.06625f,       0.82f},
00198                 {0.18275f,      0.17f,          0.22525f,       0.82f},
00199                 {0.332741f, 0.328634f,  0.346435f,      0.82f},
00200                 38.4f
00201         },{
00202                 "Pearl", // perle
00203                 {0.25f,         0.20725f,       0.20725f,       0.922f},
00204                 {1.0f,          0.829f,         0.829f,         0.922f},
00205                 {0.296648f, 0.296648f,  0.296648f,      0.922f},
00206                 11.264f
00207         },{
00208                 "Ruby", // ruby
00209                 {0.1745f,       0.01175f,       0.01175f,       0.55f},
00210                 {0.61424f,      0.04136f,       0.04136f,       0.55f},
00211                 {0.727811f, 0.626959f,  0.626959f,      0.55f},
00212                 76.8f
00213         },{
00214                 "Turquoise", // turquoise
00215                 {0.1f,          0.18725f,       0.1745f,        0.8f},
00216                 {0.396f,        0.74151f,       0.69102f,       0.8f},
00217                 {0.297254f, 0.30829f,   0.306678f,      0.8f},
00218                 12.8f
00219         },{
00220                 "Black Plastic", // plasique noir
00221                 {0.0f,          0.0f,           0.0f,           1.0f},
00222                 {0.01f,         0.01f,          0.01f,          1.0f},
00223                 {0.50f,         0.50f,          0.50f,          1.0f},
00224                 32.0f
00225         },{
00226                 "Black Rubber", // caoutchouc noir
00227                 {0.02f,         0.02f,          0.02f,          1.0f},
00228                 {0.01f,         0.01f,          0.01f,          1.0f},
00229                 {0.4f,          0.4f,           0.4f,           1.0f},
00230                 10.0f
00231         },{     
00232                 "cyan plastic", // plasitique cyan
00233                 {0.0f,                  0.1f,                   0.06f,                  1.0f},
00234                 {0.0f,                  0.50980392f,    0.50980392f,    1.0f},
00235                 {0.50196078f,   0.50196078f,    0.50196078f,    1.0f},
00236                 32.0f
00237         },{
00238                 "green plastic", // plastique vert
00239                 {0.0f,          0.0f,           0.0f,           1.0f},
00240                 {0.1f,          0.35f,          0.1f,           1.0f}, 
00241                 {0.45f,         0.55f,          0.45f,          1.0f},
00242                 32.0f
00243         },{
00244                 "red plastic",  // plastique rouge
00245                 {0.0f,          0.0f,           0.0f,           1.0f},
00246                 {0.5f,          0.0f,           0.0f,           1.0f},
00247                 {0.7f,          0.6f,           0.6f,           1.0f},
00248                 32.0f
00249         },{
00250                 "white plastic", // plastique blanc
00251                 {0.0f,          0.0f,           0.0f,           1.0f},
00252                 {0.55f,         0.55f,          0.55f,          1.0f},
00253                 {0.70f,         0.70f,          0.70f,          1.0f},
00254                 32.0f
00255         },{
00256                 "yellow plastic", // plastique jaune
00257                 {0.0f,          0.0f,           0.0f,           1.0f},
00258                 {0.5f,          0.5f,           0.0f,           1.0f},
00259                 {0.60f,         0.60f,          0.50f,          1.0f},
00260                 32.0f
00261         }, {
00262                 "cyan rubber", // caoutchouc cyan
00263                 {0.0f,          0.05f,          0.05f,          1.0f},
00264                 {0.4f,          0.5f,           0.5f,           1.0f},
00265                 {0.04f,         0.7f,           0.7f,           1.0f},
00266                 10.0f
00267         }, {
00268                 "green rubber", // caoutchouc vert
00269                 {0.0f,          0.05f,          0.0f,           1.0f},
00270                 {0.4f,          0.5f,           0.4f,           1.0f},
00271                 {0.04f,         0.7f,           0.04f,          1.0f},
00272                 10.0f
00273         }, {
00274                 "red rubber", // caoutchouc rouge
00275                 {0.05f,         0.0f,           0.0f,           1.0f},
00276                 {0.5f,          0.4f,           0.4f,           1.0f},
00277                 {0.7f,          0.04f,          0.04f,          1.0f},
00278                 10.0f
00279         }, {
00280                 "white rubber", // caoutchouc blanc
00281                 {0.05f,         0.05f,          0.05f,          1.0f},
00282                 {0.5f,          0.5f,           0.5f,           1.0f},
00283                 {0.7f,          0.7f,           0.7f,           1.0f},
00284                 10.0f
00285         }, {
00286                 "yellow rubber", // caoutchouc jaune
00287                 {0.05f,         0.05f,          0.0f,           1.0f},
00288                 {0.5f,          0.5f,           0.4f,           1.0f},
00289                 {0.7f,          0.7f,           0.04f,          1.0f},
00290                 10.0f
00291         }
00292 };
00293 
00294 #endif

Generated on Fri Aug 20 19:19:47 2004 for 3d Controls by doxygen 1.3.6