Changeset 7544 in orxonox.OLD for branches/bsp_model
- Timestamp:
- May 5, 2006, 8:23:48 PM (19 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
r7524 r7544 45 45 int size; 46 46 struct stat results; 47 name = "/ home/stefalie/svn/orxonox/data/Kanti175.bsp";47 name = "/root/data/Kanti175.bsp"; 48 48 49 49 if (stat( name , &results) == 0) { … … 256 256 glTexImage2D(GL_TEXTURE_2D, 257 257 0, 258 GL_RGB ,258 GL_RGBA8, 259 259 1, 260 260 1, … … 264 264 (const GLvoid *)&(this->whiteTexture)); 265 265 266 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, 1, 1,267 GL_RGB, GL_FLOAT,(const GLvoid *) &(this->whiteTexture));266 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA8, 1, 1, 267 GL_RGB, GL_UNSIGNED_BYTE,(const GLvoid *) &(this->whiteTexture)); 268 268 269 269 … … 373 373 void BspFile::load_textures() 374 374 { 375 char absFileName [228];375 ::std::string absFileName; 376 376 char fileName [228]; 377 377 char ext [100]; 378 378 struct stat results; 379 379 380 380 381 this->Materials = new AMat[this->numTextures]; 381 382 for(int i = 0 ; i < this->numTextures; i++) { 382 383 PRINTF(0)("BSP FILE: Texture : %s. \n", &this->textures[8+ 72*i]); 383 384 385 386 strcpy(fileName, &this->textures[8+ 72*i]); 387 if(strlen(fileName) == 0) 388 { 389 // Default Material 390 this->Materials[i].mat = new Material(); 391 this->Materials[i].mat->setDiffuse(0.1,0.1,0.1); 392 this->Materials[i].mat->setAmbient(0.1,0.1,0.1 ); 393 this->Materials[i].mat->setSpecular(0.4,0.4,0.4); 394 //this->Materials[i]->setShininess(100.0); 395 this->Materials[i].mat->setTransparency(1.0); 396 this->Materials[i].mat->setDiffuseMap("pictures/ground.tga"); 397 this->Materials[i].mat->setAmbientMap("pictures/ground.tga"); 398 this->Materials[i].mat->setSpecularMap("pictures/ground.tga"); 399 this->Materials[i].alpha = false; 400 continue; 401 } 402 403 384 404 // Check for tga 385 405 strcpy(fileName, &this->textures[8+ 72*i]); 386 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");387 406 strcpy(ext, ".tga"); 388 407 strncat (fileName, ext, strlen(fileName)); 389 strncat(absFileName,fileName,strlen(fileName)); 390 //absFileName = ResourceManager::getFullName(fileName);391 392 if( stat( absFileName , &results) == 0) {408 409 absFileName = ResourceManager::getFullName(fileName); 410 411 if(ResourceManager::isFile(absFileName)) { 393 412 PRINTF(0)("BSP FILE: gefunden . \n"); 394 413 this->Materials[i] = this->loadMat(fileName); … … 397 416 // Check for TGA 398 417 strcpy(fileName, &this->textures[8+ 72*i]); 399 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");400 418 strcpy(ext, ".TGA"); 401 419 strncat (fileName, ext, strlen(fileName)); 402 strncat(absFileName,fileName,strlen(fileName)); 403 // absFileName = ResourceManager::getFullName(fileName); 404 405 if(stat( absFileName , &results) == 0) { 420 absFileName = ResourceManager::getFullName(fileName); 421 422 if(ResourceManager::isFile(absFileName)/*stat( absFileName.c_str() , &results) == 0*/) { 406 423 PRINTF(0)("BSP FILE: gefunden . \n"); 407 424 this->Materials[i] = this->loadMat(fileName); … … 410 427 // Check for jpg 411 428 strcpy(fileName, &this->textures[8+ 72*i]); 412 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");413 429 strcpy(ext, ".jpg"); 414 430 strncat (fileName, ext, strlen(fileName)); 415 strncat(absFileName,fileName,strlen(fileName)); 416 // absFileName = ResourceManager::getFullName(fileName); 417 if(stat( absFileName , &results) == 0) { 431 absFileName = ResourceManager::getFullName(fileName); 432 if(ResourceManager::isFile(absFileName)) { 418 433 PRINTF(0)("BSP FILE: gefunden . \n"); 419 434 this->Materials[i] =this->loadMat(fileName); … … 424 439 // Check for JPG 425 440 strcpy(fileName, &this->textures[8+ 72*i]); 426 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");427 441 strcpy(ext, ".JPG"); 428 442 strncat (fileName, ext, strlen(fileName)); 429 strncat(absFileName,fileName,strlen(fileName)); 430 // absFileName = ResourceManager::getFullName(fileName); 431 if(stat( absFileName , &results) == 0) { 443 absFileName = ResourceManager::getFullName(fileName); 444 if(ResourceManager::isFile(absFileName)) { 432 445 PRINTF(0)("BSP FILE: gefunden . \n"); 433 446 this->Materials[i] =this->loadMat(fileName); … … 435 448 } 436 449 437 // Check for jpeg 450 451 452 // Check for bmp 438 453 strcpy(fileName, &this->textures[8+ 72*i]); 439 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/"); 440 strcpy(ext, ".jpeg"); 454 strcpy(ext, ".bmp"); 441 455 strncat (fileName, ext, strlen(fileName)); 442 strncat(absFileName,fileName,strlen(fileName));443 // absFileName = ResourceManager::getFullName(fileName); 444 if( stat( absFileName , &results) == 0) {456 absFileName = ResourceManager::getFullName(fileName); 457 458 if(ResourceManager::isFile(absFileName)) { 445 459 PRINTF(0)("BSP FILE: gefunden . \n"); 446 460 this->Materials[i] =this->loadMat(fileName); … … 448 462 } 449 463 450 451 // Check for JPEG452 strcpy(fileName, &this->textures[8+ 72*i]);453 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");454 strcpy(ext, ".JPEG");455 strncat (fileName, ext, strlen(fileName));456 strncat(absFileName,fileName,strlen(fileName));457 // absFileName = ResourceManager::getFullName(fileName);458 PRINTF(0)("BSP FILE: %s . \n", absFileName);459 if(stat( absFileName , &results) == 0) {460 PRINTF(0)("BSP FILE: gefunden . \n");461 this->Materials[i] =this->loadMat(fileName);462 continue;463 }464 465 // Check for bmp466 strcpy(fileName, &this->textures[8+ 72*i]);467 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");468 strcpy(ext, ".bmp");469 strncat (fileName, ext, strlen(fileName));470 strncat(absFileName,fileName,strlen(fileName));471 // absFileName = ResourceManager::getFullName(fileName);472 473 if(stat( absFileName , &results) == 0) {474 PRINTF(0)("BSP FILE: gefunden . \n");475 this->Materials[i] =this->loadMat(fileName);476 477 }478 479 464 // Check for BMP 480 465 strcpy(fileName, &this->textures[8+ 72*i]); 481 strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");482 466 strcpy(ext, ".BMP"); 483 467 strncat (fileName, ext, strlen(fileName)); 484 strncat(absFileName,fileName,strlen(fileName)); 485 // absFileName = ResourceManager::getFullName(fileName); 486 487 if(false /*stat( absFileName , &results) == 0*/) { 468 absFileName = ResourceManager::getFullName(fileName); 469 470 if(ResourceManager::isFile(absFileName)) { 488 471 PRINTF(0)("BSP FILE: gefunden . \n"); 489 472 this->Materials[i] = this->loadMat(fileName); 490 473 continue; 491 474 } 475 476 492 477 // Default Material 493 478 this->Materials[i].mat = new Material(); … … 501 486 this->Materials[i].mat->setSpecularMap("pictures/ground.tga"); 502 487 this->Materials[i].alpha = false; 488 503 489 } 504 490 } … … 524 510 525 511 tmp->setDiffuseMap(mat); 526 tmp->setAmbientMap(mat);527 tmp->setSpecularMap(mat);528 512 529 513 tmpAMat.mat = tmp; … … 535 519 { 536 520 int errorCode = 0; //!< the error code for the texture loading functions 537 unsigned int lightMap; 521 unsigned int lightMap; //!< the OpenGL texture handle 538 522 int mipmapLevel = 0; //!< the maximum mipmap level for this texture 539 523 int mipmapWidth = 0; //!< the width of the mipmap … … 544 528 { 545 529 sc = ((unsigned char *)(&lightMapTexture))[i]; 546 sc *= 1 0.5/255.0;530 sc *= 1/255.0; 547 531 scale = 1.0; 548 532 if(sc > 1.0f && (temp = (1.0f/sc)) < scale) scale=temp; 549 533 scale*=255.0; 550 534 sc*=scale; 551 ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc; 552 553 535 if(sc <= 205) 536 ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 50; 537 else 538 ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc; 554 539 } 555 540 -
branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
r7511 r7544 189 189 } 190 190 if(curFace.type == 3) return; 191 // if(this->bspFile->Materials[curFace.texture] != NULL) 192 //if(this->lastTex != curFace.texture) { 191 // if(this->bspFile->Materials[curFace.texture] != NULL) 192 193 if(this->lastTex != curFace.texture) { 193 194 this->bspFile->Materials[curFace.texture].mat->select(); 194 //this->lastTex = curFace.texture;195 //}195 this->lastTex = curFace.texture; 196 } 196 197 197 198 if(curFace.lm_index < 0) … … 208 209 } 209 210 210 glColor4f(3.0,3.0,3.0, 0.9);211 glEnableClientState(GL_VERTEX_ARRAY ); 212 //glEnableClientState(GL_TEXTURE_COORD_ARRAY );211 glColor4f(3.0,3.0,3.0,1.0); 212 glEnableClientState(GL_VERTEX_ARRAY ); 213 glEnableClientState(GL_TEXTURE_COORD_ARRAY ); 213 214 glEnableClientState(GL_NORMAL_ARRAY ); 214 215 // glEnableClientState(GL_COLOR_ARRAY); … … 223 224 glClientActiveTextureARB(GL_TEXTURE1_ARB); 224 225 glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1])); 225 glEnableClientState(GL_TEXTURE_COORD_ARRAY);226 //glEnableClientState(GL_TEXTURE_COORD_ARRAY); 226 227 227 228 … … 287 288 void BspManager::draw_patch(face* Face) 288 289 { 289 //if(this->lastTex != Face->texture) {290 if(this->lastTex != Face->texture) { 290 291 this->bspFile->Materials[Face->texture].mat->select(); 291 //this->lastTex = Face->texture;292 //}292 this->lastTex = Face->texture; 293 } 293 294 294 295 … … 306 307 glEnable(GL_TEXTURE_2D); 307 308 } 308 glColor4f(3.0,3.0,3.0, 0.9);309 glColor4f(3.0,3.0,3.0,1.0); 309 310 310 311 glEnable( GL_AUTO_NORMAL); … … 328 329 glClientActiveTextureARB(GL_TEXTURE1_ARB); 329 330 glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[1][0])); 330 glEnableClientState(GL_TEXTURE_COORD_ARRAY);331 //glEnableClientState(GL_TEXTURE_COORD_ARRAY); 331 332 332 333
Note: See TracChangeset
for help on using the changeset viewer.