00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00113
00115 static AsMaterial materials[]=
00116 {
00117 {
00118 "Brass",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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