Changeset 10519 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Jan 30, 2007, 9:51:21 PM (18 years ago)
- Location:
- trunk/src/lib/graphics/importer/bsp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/bsp/bsp_manager.cc
r10337 r10519 21 21 22 22 23 #include "limits.h" 23 24 #include "vector.h" 24 25 #include "bsp_file.h" … … 300 301 301 302 // now sort the transparent faces in the right order 302 int size = this->trasparent.size(); 303 304 // bubble sort 305 bool hasSwapped = true; 306 Vector v1, v2; 307 308 while( hasSwapped) 309 { 310 hasSwapped = false; 311 312 for( int i = 0; i < size - 1; i++) 313 { 314 // sorting test 315 face& fac1 = (this->bspFile->faces)[this->trasparent[i]]; 316 face& fac2 = (this->bspFile->faces)[this->trasparent[i+1]]; 317 318 // get center of face 1 319 const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; 320 321 // assign the values of the vertices 322 v1(curVertex[fac1.vertex].position[0], curVertex[fac1.vertex].position[1], curVertex[fac1.vertex].position[2]); 323 v2(curVertex[fac2.vertex].position[0], curVertex[fac2.vertex].position[1], curVertex[fac2.vertex].position[2]); 324 // relativly to observer 325 v1 = this->cam - v1; 326 v2 = this->cam - v2; 327 328 329 330 // swap if necessary 331 if( v1.len() - v2.len() > 1) 303 if (this->sortTransparency == 1) { 304 int size = this->trasparent.size(); 305 306 // bubble sort 307 bool hasSwapped = true; 308 Vector v1, v2; 309 310 // initialize distance array 311 float * distToPlayer = new float [size]; 312 for (int i = 0; i < size; i++) 332 313 { 333 // swap elements 334 int tmp = this->trasparent[i+1]; 335 this->trasparent[i+1] = this->trasparent[i]; 336 this->trasparent[i] = tmp; 337 338 //printf( "has swapped: %d\n", i ); 339 340 //v1.debug(); 341 //v2.debug(); 342 hasSwapped = true; 314 face& fac1 = (this->bspFile->faces)[this->trasparent[i]]; 315 // face& fac2 = (this->bspFile->faces)[this->trasparent[i+1]]; 316 317 // get center of face 1 318 const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; 319 320 if (this->sortTransparencyMore == 1) 321 { 322 // assign the values of the vertices 323 float maxDist = 0; 324 float curDist = 0; 325 int maxVert = fac1.vertex; 326 for (int v = 0; v < fac1.n_vertexes; v++) 327 { 328 v1(curVertex[fac1.vertex + v].position[0], curVertex[fac1.vertex + v].position[1], curVertex[fac1.vertex + v].position[2]); 329 curDist = (this->cam - v1).len(); 330 if (curDist > maxDist) 331 { 332 maxDist = curDist; 333 maxVert = fac1.vertex + v; 334 } 335 } 336 v1(curVertex[maxVert].position[0], curVertex[maxVert].position[1], curVertex[maxVert].position[2]); 337 } 338 else 339 { 340 v1(curVertex[fac1.vertex].position[0], curVertex[fac1.vertex].position[1], curVertex[fac1.vertex].position[2]); 341 } 342 343 // relativly to observer 344 v1 = this->cam - v1; 345 346 // save in array 347 distToPlayer[i] = v1.len(); 343 348 } 344 } 345 } 346 //printf("hasSwapped == false\n"); 347 349 350 while( hasSwapped) 351 { 352 hasSwapped = false; 353 354 for( int i = 0; i < size - 1; i++) 355 { 356 /* 357 // sorting test 358 face& fac1 = (this->bspFile->faces)[this->trasparent[i]]; 359 face& fac2 = (this->bspFile->faces)[this->trasparent[i+1]]; 360 361 // get center of face 1 362 const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; 363 364 if (this->sortTransparencyMore == 1) 365 { 366 // assign the values of the vertices 367 float maxDist = 0; 368 float curDist = 0; 369 int maxVert = fac1.vertex; 370 for (int v = 0; v < fac1.n_vertexes; v++) 371 { 372 v1(curVertex[fac1.vertex + v].position[0], curVertex[fac1.vertex + v].position[1], curVertex[fac1.vertex + v].position[2]); 373 curDist = (this->cam - v1).len(); 374 if (curDist > maxDist) 375 { 376 maxDist = curDist; 377 maxVert = fac1.vertex + v; 378 } 379 } 380 v1(curVertex[maxVert].position[0], curVertex[maxVert].position[1], curVertex[maxVert].position[2]); 381 382 maxDist = 0; 383 curDist = 0; 384 maxVert = fac1.vertex; 385 for (int v = 0; v < fac2.n_vertexes; v++) 386 { 387 v2(curVertex[fac2.vertex + v].position[0], curVertex[fac2.vertex + v].position[1], curVertex[fac2.vertex + v].position[2]); 388 curDist = (this->cam - v2).len(); 389 if (curDist > maxDist) 390 { 391 maxDist = curDist; 392 maxVert = fac2.vertex + v; 393 } 394 } 395 v2(curVertex[maxVert].position[0], curVertex[maxVert].position[1], curVertex[maxVert].position[2]); 396 } 397 else 398 { 399 v1(curVertex[fac1.vertex].position[0], curVertex[fac1.vertex].position[1], curVertex[fac1.vertex].position[2]); 400 v2(curVertex[fac2.vertex].position[0], curVertex[fac2.vertex].position[1], curVertex[fac2.vertex].position[2]); 401 } 402 403 // relativly to observer 404 v1 = this->cam - v1; 405 v2 = this->cam - v2; 406 407 408 */ 409 // swap if necessary 410 // if( v1.len() - v2.len() > 1) 411 if( distToPlayer[i] - distToPlayer[i+1] > 1) 412 { 413 // swap elements 414 float tmp1 = distToPlayer[i+1]; 415 distToPlayer[i+1] = distToPlayer[i]; 416 distToPlayer[i] = tmp1; 417 418 int tmp2 = this->trasparent[i+1]; 419 this->trasparent[i+1] = this->trasparent[i]; 420 this->trasparent[i] = tmp2; 421 422 //printf( "has swapped: %d\n", i ); 423 424 //v1.debug(); 425 //v2.debug(); 426 hasSwapped = true; 427 } 428 } 429 } 430 //printf("hasSwapped == false\n"); 431 } 348 432 349 433 -
trunk/src/lib/graphics/importer/bsp/bsp_manager.h
r10314 r10519 78 78 If a collision has been detected, the collides-function of worldEntity will be called.*/ 79 79 80 int sortTransparency; //!< sort transparent textures 81 int sortTransparencyMore; //!< sort transparent textures better 82 80 83 private: 81 84 // collision functions
Note: See TracChangeset
for help on using the changeset viewer.