![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsOpenGLMaterial.cpp 00003 00004 OpenGL Material Properties 00005 00006 SUKITTI PUNAK (10/23/2004) 00007 UPDATE (07/16/2007) 00008 ******************************************************************************/ 00009 #include "TAPsOpenGLMaterial.hpp" 00010 // Using Inclusion Model (i.e. definitions are included in declarations) 00011 // (this name.cpp is included in name.hpp) 00012 // Each friend is defined directly inside its declaration. 00013 00014 BEGIN_NAMESPACE_TAPs__OpenGL 00015 //============================================================================= 00016 //----------------------------------------------------------------------------- 00017 // Constructors 00018 Material::Material () 00019 { 00020 // Initialize Default Material Value 00021 SetMaterial( Enum::METAL_SILVER ); 00022 SetColorRGBA( 0.5, 0.5, 0.5, 1 ); 00023 } 00024 //----------------------------------------------------------------------------- 00025 Material::Material ( 00026 GLfloat *ambient, GLfloat *diffuse, GLfloat *specular, 00027 GLfloat shininess, GLfloat *emission ) 00028 { 00029 SetAmbient( ambient ); 00030 SetDiffuse( diffuse ); 00031 SetSpecular( specular ); 00032 SetShininess( shininess ); 00033 SetEmission( emission ); 00034 } 00035 //----------------------------------------------------------------------------- 00036 Material::Material ( 00037 GLfloat rAmbient, GLfloat gAmbient, GLfloat bAmbient, GLfloat aAmbient, 00038 GLfloat rDiffuse, GLfloat gDiffuse, GLfloat bDiffuse, GLfloat aDiffuse, 00039 GLfloat rSpecular, GLfloat gSpecular, GLfloat bSpecular, GLfloat aSpecular, 00040 GLfloat shininess, 00041 GLfloat rEmission, GLfloat gEmission, GLfloat bEmission, GLfloat aEmission ) 00042 { 00043 SetAmbient( rAmbient, gAmbient, bAmbient, aAmbient ); 00044 SetDiffuse( rDiffuse, gDiffuse, bDiffuse, aDiffuse ); 00045 SetSpecular( rSpecular, gSpecular, bSpecular, aSpecular ); 00046 SetShininess( shininess ); 00047 SetEmission( rEmission, gEmission, bEmission, aEmission ); 00048 } 00049 //----------------------------------------------------------------------------- 00051 Material::Material ( const Material & mat ) 00052 { 00053 SetAmbient( mat.mat_ambient ); 00054 SetDiffuse( mat.mat_diffuse ); 00055 SetSpecular( mat.mat_specular ); 00056 SetShininess( mat.mat_shininess ); 00057 SetEmission( mat.mat_emission ); 00058 SetColorRGBA( mat.color_RGBA ); 00059 } 00060 //----------------------------------------------------------------------------- 00061 00062 //============================================================================= 00063 // Assignment Operator 00064 //----------------------------------------------------------------------------- 00065 Material & Material::operator= ( Material const &mat ) 00066 { 00067 for ( int i = 0; i < 4; ++i ) { 00068 this->mat_ambient[i] = mat.mat_ambient[i]; 00069 this->mat_diffuse[i] = mat.mat_diffuse[i]; 00070 this->mat_specular[i] = mat.mat_specular[i]; 00071 this->mat_emission[i] = mat.mat_emission[i]; 00072 this->color_RGBA[i] = mat.color_RGBA[i]; 00073 } 00074 this->mat_shininess[0] = mat.mat_shininess[0]; 00075 return *this; 00076 } 00077 //----------------------------------------------------------------------------- 00078 00079 //============================================================================= 00080 // Material List 00081 //============================================================================= 00082 void Material::SetMaterial( Enum::MaterialType mt ) 00083 { 00084 switch (mt) 00085 { 00086 case Enum::BLUE_NAVY: 00087 // Initialize Default Material Value 00088 SetAmbient( 0.05, 0.05, 0.05, 0.0 ); 00089 SetDiffuse( 0.2, 0.5, 1.0, 1.0 ); 00090 SetSpecular( 0.7, 0.7, 0.7, 1.0 ); 00091 SetShininess( 96.0f ); 00092 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00093 break; 00094 00095 case Enum::BLUE: 00096 SetAmbient( 0.0, 0.0, 0.8, 0.0 ); 00097 SetDiffuse( 0.1, 0.1, 0.8, 1.0 ); 00098 SetSpecular( 0.7, 0.7, 0.7, 1.0 ); 00099 SetShininess( 16.0 ); 00100 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00101 break; 00102 case Enum::BLUE_01: 00103 SetAmbient( 0.0, 0.1, 1.0, 1.0 ); 00104 SetDiffuse( 0.1, 0.4, 1.0, 1.0 ); 00105 SetSpecular( 0.7, 0.7, 1.0, 1.0 ); 00106 SetShininess( 1.0 ); 00107 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00108 break; 00109 case Enum::BLUE_02: 00110 SetAmbient( 0.0, 0.1, 0.9, 1.0 ); 00111 SetDiffuse( 0.1, 0.4, 0.9, 1.0 ); 00112 SetSpecular( 0.7, 0.7, 0.9, 1.0 ); 00113 SetShininess( 1.0 ); 00114 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00115 break; 00116 case Enum::BLUE_03: 00117 SetAmbient( 0.0, 0.1, 0.8, 1.0 ); 00118 SetDiffuse( 0.1, 0.4, 0.8, 1.0 ); 00119 SetSpecular( 0.7, 0.7, 0.8, 1.0 ); 00120 SetShininess( 1.0 ); 00121 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00122 break; 00123 case Enum::BLUE_04: 00124 SetAmbient( 0.0, 0.1, 0.7, 1.0 ); 00125 SetDiffuse( 0.1, 0.4, 0.7, 1.0 ); 00126 SetSpecular( 0.7, 0.7, 0.7, 1.0 ); 00127 SetShininess( 1.0 ); 00128 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00129 break; 00130 case Enum::BLUE_05: 00131 SetAmbient( 0.0, 0.1, 0.6, 1.0 ); 00132 SetDiffuse( 0.1, 0.4, 0.6, 1.0 ); 00133 SetSpecular( 0.7, 0.7, 0.6, 1.0 ); 00134 SetShininess( 1.0 ); 00135 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00136 break; 00137 00138 case Enum::GREEN: 00139 SetAmbient( 0.0, 0.8, 0.0, 1.0 ); 00140 SetDiffuse( 0.0, 0.8, 0.0, 1.0 ); 00141 SetSpecular( 0.8, 0.8, 0.8, 1.0 ); 00142 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00143 SetShininess( 16.0 ); 00144 break; 00145 case Enum::GREEN_01: 00146 SetAmbient( 0.2, 1.0, 0.5, 1.0 ); 00147 SetDiffuse( 0.2, 1.0, 0.5, 1.0 ); 00148 SetSpecular( 0.5, 1.0, 0.5, 1.0 ); 00149 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00150 SetShininess( 1.0 ); 00151 break; 00152 case Enum::GREEN_02: 00153 SetAmbient( 0.2, 0.9, 0.5, 1.0 ); 00154 SetDiffuse( 0.2, 0.9, 0.5, 1.0 ); 00155 SetSpecular( 0.5, 0.9, 0.5, 1.0 ); 00156 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00157 SetShininess( 1.0 ); 00158 break; 00159 case Enum::GREEN_03: 00160 SetAmbient( 0.2, 0.8, 0.5, 1.0 ); 00161 SetDiffuse( 0.2, 0.8, 0.5, 1.0 ); 00162 SetSpecular( 0.5, 0.8, 0.5, 1.0 ); 00163 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00164 SetShininess( 1.0 ); 00165 break; 00166 case Enum::GREEN_04: 00167 SetAmbient( 0.2, 0.7, 0.5, 1.0 ); 00168 SetDiffuse( 0.2, 0.7, 0.5, 1.0 ); 00169 SetSpecular( 0.5, 0.7, 0.5, 1.0 ); 00170 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00171 SetShininess( 1.0 ); 00172 break; 00173 case Enum::GREEN_05: 00174 SetAmbient( 0.2, 0.6, 0.5, 1.0 ); 00175 SetDiffuse( 0.2, 0.6, 0.5, 1.0 ); 00176 SetSpecular( 0.5, 0.6, 0.5, 1.0 ); 00177 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00178 SetShininess( 1.0 ); 00179 break; 00180 00181 case Enum::RED: 00182 case Enum::RED_01: 00183 case Enum::RED_02: 00184 case Enum::RED_03: 00185 case Enum::RED_04: 00186 case Enum::RED_05: 00187 SetAmbient( 0.8, 0.0, 0.0, 1.0 ); 00188 SetDiffuse( 0.8, 0.0, 0.0, 1.0 ); 00189 SetSpecular( 0.7, 0.7, 0.7, 1.0 ); 00190 SetShininess( 16.0 ); 00191 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00192 break; 00193 00194 case Enum::YELLOW: 00195 case Enum::YELLOW_01: 00196 case Enum::YELLOW_02: 00197 case Enum::YELLOW_03: 00198 case Enum::YELLOW_04: 00199 case Enum::YELLOW_05: 00200 SetAmbient( 0.6, 0.6, 0.0, 1.0 ); 00201 SetDiffuse( 0.6, 0.6, 0.0, 1.0 ); 00202 SetSpecular( 0.7, 0.7, 0.7, 1.0 ); 00203 SetShininess( 16.0 ); 00204 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00205 break; 00206 00207 case Enum::MAGENTA: 00208 case Enum::MAGENTA_01: 00209 case Enum::MAGENTA_02: 00210 case Enum::MAGENTA_03: 00211 case Enum::MAGENTA_04: 00212 case Enum::MAGENTA_05: 00213 SetAmbient( 0.6, 0.0, 0.6, 1.0 ); 00214 SetDiffuse( 0.6, 0.0, 0.6, 1.0 ); 00215 SetSpecular( 0.7, 0.7, 0.7, 1.0 ); 00216 SetShininess( 16.0 ); 00217 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00218 break; 00219 00220 case Enum::CYAN: 00221 case Enum::CYAN_01: 00222 case Enum::CYAN_02: 00223 case Enum::CYAN_03: 00224 case Enum::CYAN_04: 00225 case Enum::CYAN_05: 00226 SetAmbient( 0.0, 0.6, 0.6, 1.0 ); 00227 SetDiffuse( 0.0, 0.6, 0.6, 1.0 ); 00228 SetSpecular( 0.7, 0.7, 0.7, 1.0 ); 00229 SetShininess( 16.0 ); 00230 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00231 break; 00232 00233 case Enum::BRIGHT_YELLOW: 00234 SetAmbient( 0.5, 0.5, 0.0, 1.0 ); 00235 SetDiffuse( 0.5, 0.5, 0.0, 1.0 ); 00236 SetSpecular( 0.5, 0.5, 0.0, 1.0 ); 00237 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00238 SetShininess( 1.0 ); 00239 break; 00240 00241 case Enum::DARK_RED: 00242 case Enum::DARK_RED_01: 00243 // Initialize Default Material Value 00244 SetAmbient( 0.3, 0.1, 0.1, 0.0 ); 00245 SetDiffuse( 0.3, 0.1, 0.1, 1.0 ); 00246 SetSpecular( 0.3, 0.3, 0.3, 1.0 ); 00247 SetShininess( 16.0f ); 00248 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00249 break; 00250 case Enum::DARK_GREEN: 00251 case Enum::DARK_GREEN_01: 00252 // Initialize Default Material Value 00253 SetAmbient( 0.1, 0.3, 0.1, 0.0 ); 00254 SetDiffuse( 0.1, 0.3, 0.1, 1.0 ); 00255 SetSpecular( 0.3, 0.3, 0.3, 1.0 ); 00256 SetShininess( 16.0f ); 00257 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00258 break; 00259 case Enum::DARK_BLUE: 00260 case Enum::DARK_BLUE_01: 00261 // Initialize Default Material Value 00262 SetAmbient( 0.1, 0.1, 0.3, 0.0 ); 00263 SetDiffuse( 0.1, 0.1, 0.3, 1.0 ); 00264 SetSpecular( 0.3, 0.3, 0.3, 1.0 ); 00265 SetShininess( 16.0f ); 00266 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00267 break; 00268 00269 case Enum::METAL_GOLD: 00270 SetAmbient( 0.35, 0.25, 0.05, 0.0 ); 00271 SetDiffuse( 0.45, 0.35, 0.1, 1.0 ); 00272 SetSpecular( 1.0, 1.0, 0.9, 1.0 ); 00273 SetShininess( 128.0f ); 00274 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00275 break; 00276 case Enum::METAL_SILVER: 00277 SetAmbient( 0.25, 0.25, 0.25, 0.0 ); 00278 SetDiffuse( 0.35, 0.35, 0.35, 1.0 ); 00279 SetSpecular( 1.0, 1.0, 1.0, 1.0 ); 00280 SetShininess( 128.0f ); 00281 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00282 break; 00283 case Enum::METAL_BRONZE: 00284 SetAmbient( 0.3, 0.2, 0.1, 0.0 ); 00285 SetDiffuse( 0.45, 0.3, 0.1, 1.0 ); 00286 SetSpecular( 1.0, 1.0, 1.0, 1.0 ); 00287 SetShininess( 128.0f ); 00288 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00289 break; 00290 00291 // For Suturing 00292 case Enum::BLOOD_VESSEL: 00293 SetAmbient( 0.6, 0.1, 0.1, 1.0 ); 00294 SetDiffuse( 0.75, 0.1, 0.1, 1.0 ); 00295 SetSpecular( 1.0, 1.0, 1.0, 1.0 ); 00296 SetShininess( 256.0f ); 00297 SetEmission( 0.0, 0.0, 0.0, 1.0 ); 00298 break; 00299 case Enum::HEAD_NEEDLE: 00300 SetAmbient( 0.5, 0.5, 0.5, 1.0 ); 00301 SetDiffuse( 0.75, 0.75, 0.75, 1.0 ); 00302 SetSpecular( 1.0, 1.0, 1.0, 1.0 ); 00303 SetShininess( 512.0f ); 00304 SetEmission( 0.02, 0.01, 0.01, 1.0 ); 00305 break; 00306 case Enum::NEEDLE_SHARP_POINT: 00307 SetAmbient( 0.5, 0.75, 0.5, 0.25 ); 00308 SetDiffuse( 0.5, 0.95, 0.5, 0.25 ); 00309 SetSpecular( 1.0, 1.0, 1.0, 0.25 ); 00310 SetShininess( 512.0f ); 00311 SetEmission( 0.02, 0.1, 0.01, 0.25 ); 00312 break; 00313 00314 case Enum::BLACK: 00315 case Enum::BLACK_01: 00316 case Enum::BLACK_02: 00317 case Enum::BLACK_03: 00318 case Enum::BLACK_04: 00319 case Enum::BLACK_05: 00320 SetAmbient( 0.0, 0.0, 0.0, 1.0 ); 00321 SetDiffuse( 0.0, 0.0, 0.0, 1.0 ); 00322 SetSpecular( 0.0, 0.0, 0.0, 1.0 ); 00323 SetShininess( 16.0 ); 00324 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00325 break; 00326 00327 case Enum::WHITE: 00328 case Enum::WHITE_01: 00329 case Enum::WHITE_02: 00330 case Enum::WHITE_03: 00331 case Enum::WHITE_04: 00332 case Enum::WHITE_05: 00333 SetAmbient( 0.75, 0.75, 0.75, 0.95 ); 00334 SetDiffuse( 0.75, 0.75, 0.75, 0.95 ); 00335 SetSpecular( 0.75, 0.75, 0.75, 0.95 ); 00336 SetShininess( 16.0f ); 00337 SetEmission( 0.0, 0.0, 0.0, 0.0 ); 00338 break; 00339 00340 case Enum::CURRENT_MAT: 00341 default: 00342 SetAmbient( 0.5, 0.5, 0.5, 0.5 ); 00343 SetDiffuse( 0.5, 0.5, 0.5, 0.5 ); 00344 SetSpecular( 0.5, 0.5, 0.5, 0.5 ); 00345 SetShininess( 8.0f ); 00346 SetEmission( 0.05, 0.05, 0.05, 0.05 ); 00347 break; 00348 } 00349 } 00350 //============================================================================= 00351 END_NAMESPACE_TAPs__OpenGL 00352 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00353 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8