Changeset 3195 in orxonox.OLD for orxonox/trunk/importer/material.cc
- Timestamp:
- Dec 17, 2004, 12:03:30 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/importer/material.cc
r3186 r3195 36 36 PathList::PathList() 37 37 { 38 pathName = NULL;39 next = NULL;38 this->pathName = NULL; 39 this->next = NULL; 40 40 } 41 41 … … 48 48 PathList::PathList(char* pName) 49 49 { 50 pathName = new char [strlen(pName)+1];51 strcpy ( pathName, pName);52 next = NULL;50 this->pathName = new char [strlen(pName)+1]; 51 strcpy (this->pathName, pName); 52 this->next = NULL; 53 53 } 54 54 … … 60 60 PathList::~PathList() 61 61 { 62 if ( pathName)63 delete [] pathName;64 if ( next)65 delete next;62 if (this->pathName) 63 delete []this->pathName; 64 if (this->next) 65 delete this->next; 66 66 } 67 67 … … 114 114 Material::Material() 115 115 { 116 init();117 118 setName ("");116 this->init(); 117 118 this->setName (""); 119 119 } 120 120 … … 125 125 Material::Material (char* mtlName) 126 126 { 127 init();128 129 setName (mtlName);127 this->init(); 128 129 this->setName (mtlName); 130 130 } 131 131 … … 136 136 { 137 137 if (verbose >= 2) 138 printf ("delete Material %s.\n", name);139 if ( name)140 delete [] name;141 if ( diffuseTextureSet)142 glDeleteTextures (1, & diffuseTexture);143 if ( nextMat)144 delete nextMat;138 printf ("delete Material %s.\n", this->name); 139 if (this->name) 140 delete []this->name; 141 if (this->diffuseTextureSet) 142 glDeleteTextures (1, &this->diffuseTexture); 143 if (this->nextMat) 144 delete this->nextMat; 145 145 } 146 146 … … 171 171 if (verbose >= 3) 172 172 printf ("initializing new Material.\n"); 173 nextMat = NULL;174 name ="";175 setIllum(1);176 setDiffuse(0,0,0);177 setAmbient(0,0,0);178 setSpecular(.5,.5,.5);179 setShininess(2.0);180 setTransparency(0.0);181 182 if (! pathList)183 pathList = new PathList("");184 185 186 diffuseTextureSet = false;187 ambientTextureSet = false;188 specularTextureSet = false;173 this->nextMat = NULL; 174 this->name =""; 175 this->setIllum(1); 176 this->setDiffuse(0,0,0); 177 this->setAmbient(0,0,0); 178 this->setSpecular(.5,.5,.5); 179 this->setShininess(2.0); 180 this->setTransparency(0.0); 181 182 if (!this->pathList) 183 this->pathList = new PathList(""); 184 185 186 this->diffuseTextureSet = false; 187 this->ambientTextureSet = false; 188 this->specularTextureSet = false; 189 189 190 190 … … 227 227 // setting diffuse color 228 228 // glColor3f (diffuse[0], diffuse[1], diffuse[2]); 229 glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);229 glMaterialfv(GL_FRONT, GL_DIFFUSE, this->diffuse); 230 230 231 231 // setting ambient color 232 glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);232 glMaterialfv(GL_FRONT, GL_AMBIENT, this->ambient); 233 233 234 234 // setting up Sprecular 235 glMaterialfv(GL_FRONT, GL_SPECULAR, specular);235 glMaterialfv(GL_FRONT, GL_SPECULAR, this->specular); 236 236 237 237 // setting up Shininess 238 glMaterialf(GL_FRONT, GL_SHININESS, shininess);238 glMaterialf(GL_FRONT, GL_SHININESS, this->shininess); 239 239 240 240 // setting illumination Model 241 if ( illumModel == 1)241 if (this->illumModel == 1) //! \todo make this work, if no vertex-normals are read. 242 242 glShadeModel(GL_FLAT); 243 else if ( illumModel >= 2)243 else if (this->illumModel >= 2) 244 244 glShadeModel(GL_SMOOTH); 245 245 246 if ( diffuseTextureSet)247 glBindTexture(GL_TEXTURE_2D, diffuseTexture);246 if (this->diffuseTextureSet) 247 glBindTexture(GL_TEXTURE_2D, this->diffuseTexture); 248 248 else 249 249 glBindTexture(GL_TEXTURE_2D, 0); … … 258 258 void Material::setName (char* mtlName) 259 259 { 260 name = new char [strlen(mtlName)+1];261 strcpy( name, mtlName);260 this->name = new char [strlen(mtlName)+1]; 261 strcpy(this->name, mtlName); 262 262 if (verbose >= 3) 263 printf("setting Material Name to %s.\n", name);263 printf("setting Material Name to %s.\n", this->name); 264 264 265 265 // printf ("adding new Material: %s, %p\n", this->getName(), this); … … 271 271 char* Material::getName (void) 272 272 { 273 return name;273 return this->name; 274 274 } 275 275 … … 281 281 { 282 282 if (verbose >= 3) 283 printf("setting illumModel of Material %s to %i\n", name, illum);284 illumModel = illum;283 printf("setting illumModel of Material %s to %i\n", this->name, illum); 284 this->illumModel = illum; 285 285 // printf ("setting illumModel to: %i\n", illumModel); 286 286 } … … 290 290 */void Material::setIllum (char* illum) 291 291 { 292 setIllum (atoi(illum));292 this->setIllum (atoi(illum)); 293 293 } 294 294 … … 302 302 { 303 303 if (verbose >= 3) 304 printf ("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", name, r, g, b);305 diffuse[0] = r;306 diffuse[1] = g;307 diffuse[2] = b;308 diffuse[3] = 1.0;304 printf ("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b); 305 this->diffuse[0] = r; 306 this->diffuse[1] = g; 307 this->diffuse[2] = b; 308 this->diffuse[3] = 1.0; 309 309 310 310 } … … 317 317 float r,g,b; 318 318 sscanf (rgb, "%f %f %f", &r, &g, &b); 319 setDiffuse (r, g, b);319 this->setDiffuse (r, g, b); 320 320 } 321 321 … … 329 329 { 330 330 if (verbose >=3) 331 printf ("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", name, r, g, b);332 ambient[0] = r;333 ambient[1] = g;334 ambient[2] = b;335 ambient[3] = 1.0;331 printf ("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b); 332 this->ambient[0] = r; 333 this->ambient[1] = g; 334 this->ambient[2] = b; 335 this->ambient[3] = 1.0; 336 336 } 337 337 /** … … 343 343 float r,g,b; 344 344 sscanf (rgb, "%f %f %f", &r, &g, &b); 345 setAmbient (r, g, b);345 this->setAmbient (r, g, b); 346 346 } 347 347 … … 355 355 { 356 356 if (verbose >= 3) 357 printf ("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", name, r, g, b);358 specular[0] = r;359 specular[1] = g;360 specular[2] = b;361 specular[3] = 1.0;357 printf ("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b); 358 this->specular[0] = r; 359 this->specular[1] = g; 360 this->specular[2] = b; 361 this->specular[3] = 1.0; 362 362 } 363 363 /** … … 369 369 float r,g,b; 370 370 sscanf (rgb, "%f %f %f", &r, &g, &b); 371 setSpecular (r, g, b);371 this->setSpecular (r, g, b); 372 372 } 373 373 … … 378 378 void Material::setShininess (float shini) 379 379 { 380 shininess = shini;380 this->shininess = shini; 381 381 } 382 382 /** … … 386 386 void Material::setShininess (char* shini) 387 387 { 388 setShininess (atof(shini));388 this->setShininess (atof(shini)); 389 389 } 390 390 … … 396 396 { 397 397 if (verbose >= 3) 398 printf ("setting Transparency of Material %s to %f.\n", name, trans);399 t ransparency = trans;398 printf ("setting Transparency of Material %s to %f.\n", this->name, trans); 399 this->transparency = trans; 400 400 } 401 401 /** … … 405 405 void Material::setTransparency (char* trans) 406 406 { 407 setTransparency (atof(trans));407 this->setTransparency (atof(trans)); 408 408 } 409 409 … … 414 414 void Material::addTexturePath(char* pathName) 415 415 { 416 pathList->addPath (pathName);416 this->pathList->addPath (pathName); 417 417 } 418 418 … … 464 464 465 465 // diffuseTextureSet = loadBMP(dMap, &diffuseTexture); 466 diffuseTextureSet = loadImage(dMap, &diffuseTexture);466 this->diffuseTextureSet = this->loadImage(dMap, &this->diffuseTexture); 467 467 468 468 } … … 471 471 \brief Sets the Materials Ambient Map 472 472 \param aMap the Name of the Image to Use 473 \todo implement this 473 474 */ 474 475 void Material::setAmbientMap(char* aMap) … … 481 482 \brief Sets the Materials Specular Map 482 483 \param sMap the Name of the Image to Use 484 \todo implement this 483 485 */ 484 486 void Material::setSpecularMap(char* sMap) … … 491 493 \brief Sets the Materials Bumpiness 492 494 \param bump the Name of the Image to Use 495 \todo implemet this 493 496 */ 494 497 void Material::setBump(char* bump) … … 544 547 pImage->data[i+2] = temp; 545 548 } 546 loadTexToGL (pImage, texture);549 this->loadTexToGL (pImage, texture); 547 550 } 548 551 else … … 570 573 if (verbose >=2) 571 574 printf ("Requested bmp-image. Trying to Import.\n"); 572 return loadBMP(imgNameWithPath, texture);575 return this->loadBMP(imgNameWithPath, texture); 573 576 } 574 577 … … 577 580 if (verbose >=2) 578 581 printf ("Requested jpeg-image. Trying to Import\n"); 579 return loadJPG(imgNameWithPath, texture);582 return this->loadJPG(imgNameWithPath, texture); 580 583 } 581 584 else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".tga", 4)) … … 583 586 if (verbose >=2) 584 587 printf ("Requested tga-image. Trying to Import\n"); 585 return loadTGA(imgNameWithPath, texture);588 return this->loadTGA(imgNameWithPath, texture); 586 589 } 587 590 else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".png", 4)) … … 589 592 if (verbose >=2) 590 593 printf ("Requested png-image. Trying to Import\n"); 591 return loadPNG(imgNameWithPath, texture);594 return this->loadPNG(imgNameWithPath, texture); 592 595 } 593 596 else … … 704 707 pImage->data[i+2] = temp; 705 708 } 706 loadTexToGL (pImage, texture); 707 708 return true; 709 this->loadTexToGL (pImage, texture); 710 709 711 710 712 if (pImage) … … 717 719 free(pImage); 718 720 } 721 return true; 719 722 720 723 } … … 802 805 exit(0); 803 806 804 loadTexToGL (pImage, texture);807 this->loadTexToGL (pImage, texture); 805 808 if (pImage) 806 809 { … … 947 950 } 948 951 949 loadTexToGL (pImage, texture);952 this->loadTexToGL (pImage, texture); 950 953 951 954 return true; … … 1130 1133 while(currentpixel < pixelcount); // Loop while there are still pixels left 1131 1134 1132 loadTexToGL (pImage, texture);1135 this->loadTexToGL (pImage, texture); 1133 1136 1134 1137 return true; … … 1265 1268 } 1266 1269 */ 1267 loadTexToGL (pImage, texture);1270 this->loadTexToGL (pImage, texture); 1268 1271 1269 1272 free(pImage->data);
Note: See TracChangeset
for help on using the changeset viewer.