- Timestamp:
- Jan 30, 2007, 9:51:21 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 7 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 -
trunk/src/world_entities/bsp_entity.cc
r10114 r10519 57 57 58 58 this->bspManager = NULL; 59 this->sortTransparency = 1; 60 this->sortTransparencyMore = 0; 61 59 62 60 63 this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) ); … … 74 77 75 78 this->bspManager = new BspManager(this); 79 this->bspManager->sortTransparency = this->sortTransparency; 80 this->bspManager->sortTransparencyMore = this->sortTransparencyMore; 76 81 77 82 if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) { … … 87 92 } 88 93 94 void BspEntity::setTransparency(int sort, int sortMore) 95 { 96 this->sortTransparency = sort; 97 this->sortTransparencyMore = sortMore; 98 99 if (this->bspManager != NULL) 100 { 101 this->bspManager->sortTransparency = sort; 102 this->bspManager->sortTransparencyMore = sortMore; 103 } 104 } 89 105 90 106 /** … … 101 117 .describe("Sets the of the BSP file."); 102 118 119 LoadParam(root, "Transparency", this, BspEntity, setTransparency) 120 .describe("1. argument: true -> sort transparent textures; 2. argument: true -> better but slower sorting") 121 .defaultValues(1, 0); 122 103 123 /* LoadParam(root, "Scale", this, BSpEntity, setScale) 104 124 .describe("Sets the scale factore of the bsp level."); -
trunk/src/world_entities/bsp_entity.h
r10033 r10519 26 26 27 27 void setName(const std::string& name); 28 void setTransparency(int sort, int sortMore = 0); 28 29 29 30 void init(); … … 44 45 std::string name_write; //!< temp variable to store name 45 46 int name_handle; //!< handle for name 46 47 int sortTransparency; //!< sort transparent textures 48 int sortTransparencyMore; //!< sort transparent textures better 47 49 }; 48 50 -
trunk/src/world_entities/environments/rotor.cc
r10280 r10519 30 30 { 31 31 this->registerObject(this, Rotor::_objectList); 32 this->toList(OM_ GROUP_00);33 32 this->toList(OM_ENVIRON); 33 34 34 //PRINTF(0)("loading Rotor"); 35 35 … … 63 63 { 64 64 this->shiftDir(Quaternion(rotation.x*dt, Vector(1,0,0)) * Quaternion(rotation.y*dt, Vector(0,1,0)) * Quaternion(rotation.z*dt, Vector(0,0,1))); 65 65 66 66 } 67 67 -
trunk/src/world_entities/npcs/mover.cc
r10487 r10519 20 20 21 21 #include "mover.h" 22 #include "state.h" 23 #include "camera.h" 22 24 23 25 … … 31 33 { 32 34 this->registerObject(this, Mover::_objectList); 33 this->toList(OM_ COMMON);35 this->toList(OM_ENVIRON); 34 36 35 37 this->targetCoordinates = Vector(0, 0, 0); … … 224 226 if (distance < this->actionRadius) 225 227 { 226 this->soundSource_starting.setSourceNode( entity); // bad hack!227 this->soundSource_moving.setSourceNode( entity); // TODO: make the sound louder without228 this->soundSource_ending.setSourceNode( entity); // attaching him to the player228 this->soundSource_starting.setSourceNode((PNode*)State::getCamera()); // bad hack! 229 this->soundSource_moving.setSourceNode((PNode*)State::getCamera()); // TODO: make the sound louder without 230 this->soundSource_ending.setSourceNode((PNode*)State::getCamera()); // attaching him to the player 229 231 return true; 230 232 } -
trunk/src/world_entities/particles/particle_system.cc
r10516 r10519 264 264 emitter->system = this; 265 265 this->emitters.push_back(emitter); 266 267 // init the emitertter with the coordinates of the system 268 emitter->setAbsCoor(this->getAbsCoor()); 269 266 270 } 267 271
Note: See TracChangeset
for help on using the changeset viewer.