Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10519 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jan 30, 2007, 9:51:21 PM (18 years ago)
Author:
patrick
Message:

emitter fix

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/bsp/bsp_manager.cc

    r10337 r10519  
    2121
    2222
     23#include "limits.h"
    2324#include "vector.h"
    2425#include "bsp_file.h"
     
    300301
    301302  // 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++)
    332313      {
    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();
    343348      }
    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  }
    348432
    349433
  • trunk/src/lib/graphics/importer/bsp/bsp_manager.h

    r10314 r10519  
    7878                                                      If a collision has been detected, the collides-function of worldEntity will be called.*/
    7979
     80  int sortTransparency;              //!< sort transparent textures
     81  int sortTransparencyMore;          //!< sort transparent textures better
     82
    8083private:
    8184  // collision functions
  • trunk/src/world_entities/bsp_entity.cc

    r10114 r10519  
    5757
    5858  this->bspManager = NULL;
     59  this->sortTransparency = 1;
     60  this->sortTransparencyMore = 0;
     61
    5962
    6063  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) );
     
    7477
    7578    this->bspManager = new BspManager(this);
     79    this->bspManager->sortTransparency = this->sortTransparency;
     80    this->bspManager->sortTransparencyMore = this->sortTransparencyMore;
    7681
    7782    if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) {
     
    8792}
    8893
     94void 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}
    89105
    90106/**
     
    101117  .describe("Sets the of the BSP file.");
    102118
     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 
    103123  /*  LoadParam(root, "Scale", this, BSpEntity, setScale)
    104124        .describe("Sets the scale factore of the bsp level.");
  • trunk/src/world_entities/bsp_entity.h

    r10033 r10519  
    2626
    2727  void setName(const std::string& name);
     28  void setTransparency(int sort, int sortMore = 0);
    2829
    2930  void init();
     
    4445   std::string name_write;             //!< temp variable to store name
    4546   int name_handle;                    //!< handle for name
    46 
     47   int sortTransparency;              //!< sort transparent textures
     48   int sortTransparencyMore;          //!< sort transparent textures better
    4749};
    4850
  • trunk/src/world_entities/environments/rotor.cc

    r10280 r10519  
    3030{
    3131  this->registerObject(this, Rotor::_objectList);
    32   this->toList(OM_GROUP_00);
    33  
     32  this->toList(OM_ENVIRON);
     33
    3434  //PRINTF(0)("loading Rotor");
    3535
     
    6363{
    6464     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
    6666}
    6767
  • trunk/src/world_entities/npcs/mover.cc

    r10487 r10519  
    2020
    2121#include "mover.h"
     22#include "state.h"
     23#include "camera.h"
    2224
    2325
     
    3133{
    3234    this->registerObject(this, Mover::_objectList);
    33     this->toList(OM_COMMON);
     35    this->toList(OM_ENVIRON);
    3436
    3537    this->targetCoordinates = Vector(0, 0, 0);
     
    224226        if (distance < this->actionRadius)
    225227        {
    226             this->soundSource_starting.setSourceNode(entity);   // bad hack!
    227             this->soundSource_moving.setSourceNode(entity);     // TODO: make the sound louder without
    228             this->soundSource_ending.setSourceNode(entity);     // attaching him to the player
     228            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
    229231            return true;
    230232        }
  • trunk/src/world_entities/particles/particle_system.cc

    r10516 r10519  
    264264  emitter->system = this;
    265265  this->emitters.push_back(emitter);
     266
     267  // init the emitertter with the coordinates of the system
     268  emitter->setAbsCoor(this->getAbsCoor());
     269
    266270}
    267271
Note: See TracChangeset for help on using the changeset viewer.