Changeset 7511 in orxonox.OLD for branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
- Timestamp:
- May 3, 2006, 2:51:12 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
r7510 r7511 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: bottac@ee.ethz.ch … … 36 36 {} 37 37 38 /** 39 * Loads a quake3 level (*.bsp) 40 * @param name the Name of the *.bsp file 41 */ 38 42 int BspFile::read(char* name) 39 43 { … … 222 226 PRINTF(4)("BSP FILE: Texture 0: %s. \n", &this->textures[8+ 72*i]); 223 227 this->load_textures(); 224 228 225 229 // Load the lightMaps 226 230 this->glLightMapTextures = new GLuint[this->numLightMaps]; 227 231 for(int i = 0; i < this->numLightMaps; i++) 228 232 this->glLightMapTextures[i] = this->loadLightMapToGL(this->lightMaps[i]); 229 233 230 234 //Create white texture for if no lightmap specified 231 235 glGenTextures(1, &this->whiteLightMap); 232 236 glBindTexture(GL_TEXTURE_2D, this->whiteLightMap); 233 237 //Create texture 234 238 this->whiteTexture[0]=255; 235 239 this->whiteTexture[1]=255; 236 240 this->whiteTexture[2]=255; 237 241 238 242 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 239 243 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); … … 244 248 245 249 246 250 247 251 /* control the mipmap levels */ 248 252 glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MIN_LOD, 5); … … 252 256 glTexImage2D(GL_TEXTURE_2D, 253 257 0, 254 GL_RGB A8,258 GL_RGB, 255 259 1, 256 260 1, … … 260 264 (const GLvoid *)&(this->whiteTexture)); 261 265 262 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA8, 1, 1,266 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, 1, 1, 263 267 GL_RGB, GL_FLOAT,(const GLvoid *) &(this->whiteTexture)); 264 265 268 269 266 270 267 271 // Get the number of patches … … 313 317 } 314 318 319 /** 320 * Called by BspFile::build_tree() only. 321 */ 315 322 BspTreeNode* BspFile::build_tree_rec(int i) 316 323 { … … 324 331 float z1 =(((plane *) this->planes) [planeIndex]).z; 325 332 thisNode->leafIndex = 0; 326 thisNode->d 333 thisNode->d = (((plane *) this->planes) [planeIndex]).d; 327 334 328 335 thisNode->plane = Vector(x1,y1,z1); … … 356 363 } 357 364 365 /** 366 * returns the root node of the bsp-tree 367 */ 358 368 BspTreeNode* BspFile::get_root() 359 369 { … … 464 474 PRINTF(0)("BSP FILE: gefunden . \n"); 465 475 this->Materials[i] =this->loadMat(fileName); 466 476 467 477 } 468 478 … … 480 490 continue; 481 491 } 482 // 492 // Default Material 483 493 this->Materials[i].mat = new Material(); 484 494 this->Materials[i].mat->setDiffuse(0.1,0.1,0.1); … … 503 513 if(this->testSurf != NULL) { 504 514 if(this->testSurf->format->Amask != 0 ) tmpAMat.alpha = true; 505 else 515 else tmpAMat.alpha = false; 506 516 } else tmpAMat.alpha = false; 507 517 … … 510 520 tmp->setAmbient(1.0,1.0,1.0 ); 511 521 tmp->setSpecular(1.0,1.0,1.0); 512 // 513 // 522 // tmp->setShininess(.5); 523 // tmp->setTransparency(1.0); 514 524 515 525 tmp->setDiffuseMap(mat); … … 539 549 scale*=255.0; 540 550 sc*=scale; 541 ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc; 542 543 551 ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc; 552 553 544 554 } 545 555 546 556 glGenTextures(1, &lightMap); 547 557 glBindTexture(GL_TEXTURE_2D, lightMap); … … 569 579 (const GLvoid *)&lightMapTexture); 570 580 571 581 572 582 // build the MipMaps automaticaly 573 583 errorCode = gluBuild2DMipmaps(GL_TEXTURE_2D, … … 579 589 (const GLvoid *)&lightMapTexture 580 590 ); 581 591 582 592 583 593 … … 587 597 } 588 598 599 /** 600 * Generates a vertex-array, a indice-array and a texture-coordinates-array for iface. 601 * @param iface integer index of face 602 * @todo cleanup this function, let the user choose the level of tesselation 603 */ 604 605 589 606 void BspFile::tesselate(int iface) 590 607 { … … 715 732 716 733 717 //Vertice[u*(tesselation+1)+v]= 734 //Vertice[u*(tesselation+1)+v]= temp[0]*((1.0f-px)*(1.0f-px))+ temp[1]*((1.0f-px)*px*2)+ temp[2]*(px*px); 718 735 Vertice[u*(level1)+v].position[0]=temp[0].position[0]*((1.0f-px)*(1.0f-px))+temp[1].position[0]*((1.0f-px)*px*2)+temp[2].position[0]*(px*px); 719 736 Vertice[u*(level1)+v].position[1]=temp[0].position[1]*((1.0f-px)*(1.0f-px))+temp[1].position[1]*((1.0f-px)*px*2)+temp[2].position[1]*(px*px); … … 750 767 // Debug Model 751 768 //*********************************************************************************************************************** 769 752 770 this->VertexArrayModels[this->patchOffset] = new VertexArrayModel(); 753 771 VertexArrayModel* tmp = this->VertexArrayModels[this->patchOffset];
Note: See TracChangeset
for help on using the changeset viewer.