00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 # include <cstring>
00028 #endif
00029
00030 #include <Base/Exception.h>
00031 #include "Material.h"
00032
00033 using namespace App;
00034
00035
00036
00037
00038
00039 Material::Material(void)
00040 {
00041 setType(STEEL);
00042 setType(USER_DEFINED);
00043 }
00044
00045 Material::Material(const char* MatName)
00046 {
00047 set(MatName);
00048 }
00049
00050 Material::Material(const MaterialType MatType)
00051 {
00052 setType(MatType);
00053 }
00054
00055 Material::~Material()
00056 {
00057 }
00058
00059 void Material::set(const char* MatName)
00060 {
00061 if (strcmp("Brass",MatName) == 0 ) {
00062 setType(BRASS);
00063 }
00064 else if (strcmp("Bronze",MatName) == 0 ) {
00065 setType(BRONZE);
00066 }
00067 else if (strcmp("Copper",MatName) == 0 ) {
00068 setType(COPPER);
00069 }
00070 else if (strcmp("Gold",MatName) == 0 ) {
00071
00072
00073
00074
00075
00086 setType(GOLD);
00087 }
00088 else if (strcmp("Pewter",MatName) == 0 ) {
00089 setType(PEWTER);
00090 }
00091 else if (strcmp("Plaster",MatName) == 0 ) {
00092 setType(PLASTER);
00093 }
00094 else if (strcmp("Plastic",MatName) == 0 ) {
00095 setType(PLASTIC);
00096 }
00097 else if (strcmp("Silver",MatName) == 0 ) {
00098 setType(SILVER);
00099 }
00100 else if (strcmp("Steel",MatName) == 0 ) {
00101 setType(STEEL);
00102 }
00103 else if (strcmp("Stone",MatName) == 0 ) {
00104
00105
00106
00107
00108
00109 setType(STONE);
00110 }
00111 else if (strcmp("Shiny plastic",MatName) == 0 ) {
00112 setType(SHINY_PLASTIC);
00113 }
00114 else if (strcmp("Satin",MatName) == 0 ) {
00115 setType(SATIN);
00116 }
00117 else if (strcmp("Metalized",MatName) == 0 ) {
00118 setType(METALIZED);
00119 }
00120 else if (strcmp("Neon GNC",MatName) == 0 ) {
00121 setType(NEON_GNC);
00122 }
00123 else if (strcmp("Chrome",MatName) == 0 ) {
00124 setType(CHROME);
00125 }
00126 else if (strcmp("Aluminium",MatName) == 0 ) {
00127 setType(ALUMINIUM);
00128 }
00129 else if (strcmp("Obsidian",MatName) == 0 ) {
00130 setType(OBSIDIAN);
00131 }
00132 else if (strcmp("Neon PHC",MatName) == 0 ) {
00133 setType(NEON_PHC);
00134 }
00135 else if (strcmp("Jade",MatName) == 0 ) {
00136 setType(JADE);
00137 }
00138 else if (strcmp("Ruby",MatName) == 0 ) {
00139 setType(RUBY);
00140 }
00141 else if (strcmp("Emerald",MatName) == 0 ) {
00142 setType(EMERALD);
00143 }
00144 else if (strcmp("Default",MatName) == 0 ) {
00145 setType(DEFAULT);
00146 }
00147 else {
00148 setType(USER_DEFINED);
00149 }
00150 }
00151
00152 void Material::setType(const MaterialType MatType)
00153 {
00154 _matType = MatType;
00155 switch (MatType)
00156 {
00157 case BRASS:
00158 ambientColor .set(0.3294f,0.2235f,0.0275f);
00159 diffuseColor .set(0.7804f,0.5686f,0.1137f);
00160 specularColor.set(0.9922f,0.9412f,0.8078f);
00161 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00162 shininess = 0.2179f;
00163 transparency = 0.0000f;
00164 break;
00165 case BRONZE:
00166 ambientColor .set(0.2125f,0.1275f,0.0540f);
00167 diffuseColor .set(0.7140f,0.4284f,0.1814f);
00168 specularColor.set(0.3935f,0.2719f,0.1667f);
00169 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00170 shininess = 0.2000f;
00171 transparency = 0.0000f;
00172 break;
00173 case COPPER:
00174 ambientColor .set(0.3300f,0.2600f,0.2300f);
00175 diffuseColor .set(0.5000f,0.1100f,0.0000f);
00176 specularColor.set(0.9500f,0.7300f,0.0000f);
00177 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00178 shininess = 0.9300f;
00179 transparency = 0.0000f;
00180 break;
00181 case GOLD:
00182 ambientColor .set(0.3000f,0.2306f,0.0953f);
00183 diffuseColor .set(0.4000f,0.2760f,0.0000f);
00184 specularColor.set(0.9000f,0.8820f,0.7020f);
00185 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00186 shininess = 0.0625f;
00187 transparency = 0.0000f;
00188 break;
00189 case PEWTER:
00190 ambientColor .set(0.1059f,0.0588f,0.1137f);
00191 diffuseColor .set(0.4275f,0.4706f,0.5412f);
00192 specularColor.set(0.3333f,0.3333f,0.5216f);
00193 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00194 shininess = 0.0769f;
00195 transparency = 0.0000f;
00196 break;
00197 case PLASTER:
00198 ambientColor .set(0.0500f,0.0500f,0.0500f);
00199 diffuseColor .set(0.1167f,0.1167f,0.1167f);
00200 specularColor.set(0.0305f,0.0305f,0.0305f);
00201 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00202 shininess = 0.0078f;
00203 transparency = 0.0000f;
00204 break;
00205 case PLASTIC:
00206 ambientColor .set(0.1000f,0.1000f,0.1000f);
00207 diffuseColor .set(0.0000f,0.0000f,0.0000f);
00208 specularColor.set(0.0600f,0.0600f,0.0600f);
00209 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00210 shininess = 0.0078f;
00211 transparency = 0.0000f;
00212 break;
00213 case SILVER:
00214 ambientColor .set(0.1922f,0.1922f,0.1922f);
00215 diffuseColor .set(0.5075f,0.5075f,0.5075f);
00216 specularColor.set(0.5083f,0.5083f,0.5083f);
00217 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00218 shininess = 0.2000f;
00219 transparency = 0.0000f;
00220 break;
00221 case STEEL:
00222 ambientColor .set(0.0020f,0.0020f,0.0020f);
00223 diffuseColor .set(0.0000f,0.0000f,0.0000f);
00224 specularColor.set(0.9800f,0.9800f,0.9800f);
00225 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00226 shininess = 0.0600f;
00227 transparency = 0.0000f;
00228 break;
00229 case STONE:
00230 ambientColor .set(0.1900f,0.1520f,0.1178f);
00231 diffuseColor .set(0.7500f,0.6000f,0.4650f);
00232 specularColor.set(0.0784f,0.0800f,0.0480f);
00233 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00234 shininess = 0.1700f;
00235 transparency = 0.0000f;
00236 break;
00237 case SHINY_PLASTIC:
00238 ambientColor .set(0.0880f,0.0880f,0.0880f);
00239 diffuseColor .set(0.0000f,0.0000f,0.0000f);
00240 specularColor.set(1.0000f,1.0000f,1.0000f);
00241 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00242 shininess = 1.0000f;
00243 transparency = 0.0000f;
00244 break;
00245 case SATIN:
00246 ambientColor .set(0.0660f,0.0660f,0.0660f);
00247 diffuseColor .set(0.0000f,0.0000f,0.0000f);
00248 specularColor.set(0.4400f,0.4400f,0.4400f);
00249 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00250 shininess = 0.0938f;
00251 transparency = 0.0000f;
00252 break;
00253 case METALIZED:
00254 ambientColor .set(0.1800f,0.1800f,0.1800f);
00255 diffuseColor .set(0.0000f,0.0000f,0.0000f);
00256 specularColor.set(0.4500f,0.4500f,0.4500f);
00257 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00258 shininess = 0.1300f;
00259 transparency = 0.0000f;
00260 break;
00261 case NEON_GNC:
00262 ambientColor .set(0.2000f,0.2000f,0.2000f);
00263 diffuseColor .set(0.0000f,0.0000f,0.0000f);
00264 specularColor.set(0.6200f,0.6200f,0.6200f);
00265 emissiveColor.set(1.0000f,1.0000f,0.0000f);
00266 shininess = 0.0500f;
00267 transparency = 0.0000f;
00268 break;
00269 case CHROME:
00270 ambientColor .set(0.3500f,0.3500f,0.3500f);
00271 diffuseColor .set(0.4000f,0.4000f,0.4000f);
00272 specularColor.set(0.9746f,0.9746f,0.9746f);
00273 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00274 shininess = 0.1000f;
00275 transparency = 0.0000f;
00276 break;
00277 case ALUMINIUM:
00278 ambientColor .set(0.3000f,0.3000f,0.3000f);
00279 diffuseColor .set(0.3000f,0.3000f,0.3000f);
00280 specularColor.set(0.7000f,0.7000f,0.8000f);
00281 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00282 shininess = 0.0900f;
00283 transparency = 0.0000f;
00284 break;
00285 case OBSIDIAN:
00286 ambientColor .set(0.0538f,0.0500f,0.0662f);
00287 diffuseColor .set(0.1828f,0.1700f,0.2253f);
00288 specularColor.set(0.3327f,0.3286f,0.3464f);
00289 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00290 shininess = 0.3000f;
00291 transparency = 0.0000f;
00292 break;
00293 case NEON_PHC:
00294 ambientColor .set(1.0000f,1.0000f,1.0000f);
00295 diffuseColor .set(1.0000f,1.0000f,1.0000f);
00296 specularColor.set(0.6200f,0.6200f,0.6200f);
00297 emissiveColor.set(0.0000f,0.9000f,0.4140f);
00298 shininess = 0.0500f;
00299 transparency = 0.0000f;
00300 break;
00301 case JADE:
00302 ambientColor .set(0.1350f,0.2225f,0.1575f);
00303 diffuseColor .set(0.5400f,0.8900f,0.6300f);
00304 specularColor.set(0.3162f,0.3162f,0.3162f);
00305 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00306 shininess = 0.1000f;
00307 transparency = 0.0000f;
00308 break;
00309 case RUBY:
00310 ambientColor .set(0.1745f,0.0118f,0.0118f);
00311 diffuseColor .set(0.6142f,0.0414f,0.0414f);
00312 specularColor.set(0.7278f,0.6279f,0.6267f);
00313 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00314 shininess = 0.6000f;
00315 transparency = 0.0000f;
00316 break;
00317 case EMERALD:
00318 ambientColor .set(0.0215f,0.1745f,0.0215f);
00319 diffuseColor .set(0.0757f,0.6142f,0.0757f);
00320 specularColor.set(0.6330f,0.7278f,0.6330f);
00321 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00322 shininess = 0.6000f;
00323 transparency = 0.0000f;
00324 break;
00325 case USER_DEFINED:
00326 break;
00327 default:
00328 ambientColor .set(0.2000f,0.2000f,0.2000f);
00329 diffuseColor .set(0.8000f,0.8000f,0.8000f);
00330 specularColor.set(0.0000f,0.0000f,0.0000f);
00331 emissiveColor.set(0.0000f,0.0000f,0.0000f);
00332 shininess = 0.2000f;
00333 transparency = 0.0000f;
00334 break;
00335 }
00336 }