Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3238 in orxonox.OLD for orxonox/branches/sound/src/world.cc


Ignore:
Timestamp:
Dec 20, 2004, 2:42:54 AM (21 years ago)
Author:
bensch
Message:

orxonox/branches: updated branches: buerli, nico, sound. And moved bezierTrack to old.bezierTrack. Conflicts resolved in a usefull order.
Conflics mostly resolved in favor of trunk
merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound/src/world.cc

    r2644 r3238  
    2222#include "command_node.h"
    2323#include "camera.h"
     24#include "environment.h"
    2425
    2526using namespace std;
     
    3536  this->worldName = name;
    3637  this->debugWorldNr = -1;
    37   this->entities = new List<WorldEntity>();
     38  this->entities = new tList<WorldEntity>();
    3839}
    3940
     
    4243  this->debugWorldNr = worldID;
    4344  this->worldName = NULL;
    44   this->entities = new List<WorldEntity>();
     45  this->entities = new tList<WorldEntity>();
    4546}
    4647
     
    5051World::~World ()
    5152{
    52   Orxonox *orx = Orxonox::getInstance();
    53   orx->get_localinput()->unbind (this->localPlayer);
     53  printf("World::~World() - deleting current world\n");
     54  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
     55  cn->unbind(this->localPlayer);
     56  cn->reset();
     57  this->localCamera->destroy();
     58
     59  WorldEntity* entity = entities->enumerate(); 
     60  while( entity != NULL )
     61    {
     62      entity->destroy();
     63      entity = entities->nextElement();
     64    }
     65  this->entities->destroy();
     66
    5467  delete this->entities;
    5568  delete this->localCamera;
    56 }
    57 
    58 
    59 /**
    60     \brief initialize the world before use.
    61 */
    62 Error World::init()
     69  /* this->localPlayer hasn't to be deleted explicitly, it is
     70     contained in entities*/
     71}
     72
     73
     74ErrorMessage World::init()
    6375{
    6476  this->bPause = false;
    65 }
    66 
    67 Error World::start()
    68 {
     77  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
     78  cn->addToWorld(this);
     79  cn->enable(true);
     80}
     81
     82ErrorMessage World::start()
     83{
     84  printf("World::start() - starting current World: nr %i\n", this->debugWorldNr);
     85  this->bQuitOrxonox = false;
     86  this->bQuitCurrentGame = false;
    6987  this->mainLoop();
    7088}
    7189
    72 Error World::stop()
    73 {
     90ErrorMessage World::stop()
     91{
     92  printf("World::stop() - got stop signal\n");
    7493  this->bQuitCurrentGame = true;
    75   this->localCamera->setWorld(NULL);
    76   this->~World();
    77 }
    78 
    79 Error World::pause()
     94}
     95
     96ErrorMessage World::pause()
    8097{
    8198  this->isPaused = true;
    8299}
    83100
    84 Error World::resume()
     101ErrorMessage World::resume()
    85102{
    86103  this->isPaused = false;
    87104}
    88105
     106void World::destroy()
     107{
     108
     109}
     110
    89111void World::load()
    90112{
     
    93115      switch(this->debugWorldNr)
    94116        {
     117          /*
     118            this loads the hard-coded debug world. this only for simplicity and will be
     119            removed by a reald world-loader, which interprets a world-file.
     120            if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
     121            make whatever you want...
     122           */
    95123        case DEBUG_WORLD_0:
    96124          {
     
    98126            this->pathnodes = new Vector[6];
    99127            this->pathnodes[0] = Vector(0, 0, 0);
    100             this->pathnodes[1] = Vector(-100, 40, 0);
    101             this->pathnodes[2] = Vector(-100, 140, 0);
    102             this->pathnodes[3] = Vector(0, 180, 0);
    103             this->pathnodes[4] = Vector(100, 140, 0);
    104             this->pathnodes[5] = Vector(100, 40, 0);
     128            this->pathnodes[1] = Vector(1000, 0, 0);
     129            //      this->pathnodes[2] = Vector(-100, 140, 0);
     130            //      this->pathnodes[3] = Vector(0, 180, 0);
     131            //      this->pathnodes[4] = Vector(100, 140, 0);
     132            //      this->pathnodes[5] = Vector(100, 40, 0);
    105133           
    106134            // create the tracks
    107             this->tracklen = 6;
    108             this->track = new Track[6];
     135            this->tracklen = 2;
     136            this->track = new Track[2];
    109137            for( int i = 0; i < this->tracklen; i++)
    110138              {
    111139                this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
    112140              }
    113            
     141            // !\todo old track-system has to be removed
     142
    114143            // create a player
    115             //WorldEntity* myPlayer = (WorldEntity*) this->spawn<Player>();
    116144            WorldEntity* myPlayer = new Player();
    117145            this->spawn(myPlayer);
     
    120148            // bind input
    121149            Orxonox *orx = Orxonox::getInstance();
    122             orx->get_localinput()->bind (myPlayer);
     150            orx->getLocalInput()->bind (myPlayer);
    123151           
    124152            // bind camera
    125153            this->localCamera = new Camera(this);
    126154            this->getCamera()->bind (myPlayer);
     155
     156            Placement* plc = new Placement;
     157            plc->r = Vector(100, 10, 10);
     158            plc->w = Quaternion();
     159            WorldEntity* env = new Environment();
     160            this->spawn(env, plc);
     161
    127162            break;
    128163          }
     
    145180                this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
    146181              }
    147            
     182
    148183            // create a player
    149             //WorldEntity* myPlayer = (WorldEntity*) this->spawn<Player>();
    150184            WorldEntity* myPlayer = new Player();
    151185            this->spawn(myPlayer);
    152             this->localPlayer = myPlayer;
     186            this->localPlayer = myPlayer;           
    153187           
    154188            // bind input
    155189            Orxonox *orx = Orxonox::getInstance();
    156             orx->get_localinput()->bind (myPlayer);
     190            orx->getLocalInput()->bind (myPlayer);
    157191           
    158192            // bind camera
     
    169203
    170204    }
     205
     206  // initialize debug coord system
     207  objectList = glGenLists(1);
     208  glNewList (objectList, GL_COMPILE);
     209  glLoadIdentity();
     210  glColor3f(1.0,0,0);
     211  glBegin(GL_QUADS);
     212
     213  int sizeX = 100;
     214  int sizeY = 80;
     215  float length = 1000;
     216  float width = 200;
     217  float widthX = float (length /sizeX);
     218  float widthY = float (width /sizeY);
     219 
     220  float height [sizeX][sizeY];
     221  Vector normal_vectors[sizeX][sizeY];
     222 
     223 
     224  for ( int i = 0; i<sizeX-1; i+=1)
     225    for (int j = 0; j<sizeY-1;j+=1)
     226      //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
     227#ifdef __WIN32__
     228      height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
     229#else
     230      height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
     231#endif
     232
     233  //Die Hügel ein wenig glätten
     234  for (int h=1; h<2;h++)
     235    for (int i=1;i<sizeX-2 ;i+=1 )
     236      for(int j=1;j<sizeY-2;j+=1)
     237        height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
     238 
     239  //Berechnung von normalen Vektoren
     240
     241  for(int i=1;i<sizeX-2;i+=1)
     242    for(int j=1;j<sizeY-2 ;j+=1)
     243      {
     244        Vector v1 = Vector (widthX*(1),      widthY*(j)  ,      height[i][j]);
     245        Vector v2 = Vector (widthX*(i-1),    widthY*(j)  ,      height[i-1][j]);
     246        Vector v3 = Vector (widthX*(i),      widthY*(j+1),      height[i][j+1]);
     247        Vector v4 = Vector (widthX*(i+1),    widthY*(j),        height[i+1][j]);
     248        Vector v5 = Vector (widthX*(i),      widthY*(j-1),      height[i][j-1]);
     249       
     250        Vector c1 = v2 - v1;
     251        Vector c2 = v3 - v1;
     252        Vector c3=  v4 - v1;
     253        Vector c4 = v5 - v1;
     254        Vector zero = Vector (0,0,0);
     255        normal_vectors[i][j]=c1.cross(v4-v2)+c2.cross(v1-v3)+c3.cross(v2-v4)+c4.cross(v3-v1);
     256        normal_vectors[i][j].normalize();
     257      }
     258
     259  int snowheight=3;
     260  for ( int i = 0; i<sizeX; i+=1)
     261    for (int j = 0; j<sizeY;j+=1)
     262      {   
     263        Vector v1 = Vector (widthX*(i),      widthY*(j)  -width/2,      height[i][j]-20 );
     264        Vector v2 = Vector (widthX*(i+1),    widthY*(j)  -width/2,      height[i+1][j]-20);
     265        Vector v3 = Vector (widthX*(i+1),    widthY*(j+1)-width/2,    height[i+1][j+1]-20);
     266        Vector v4 = Vector (widthX*(i),      widthY*(j+1)-width/2,    height[i][j+1]-20);
     267        float a[3];
     268        if(height[i][j]<snowheight){
     269          a[0]=0;
     270          a[1]=1.0-height[i][j]/10-.3;
     271          a[2]=0;
     272          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     273        }
     274        else{
     275            a[0]=1.0;
     276            a[1]=1.0;
     277            a[2]=1.0;
     278            glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     279           
     280        }
     281        glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
     282        glVertex3f(v1.x, v1.y, v1.z);
     283        if(height[i+1][j]<snowheight){
     284          a[0]=0;
     285          a[1] =1.0-height[i+1][j]/10-.3;
     286          a[2]=0;
     287          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     288        }
     289        else{
     290          a[0]=1.0;
     291          a[1]=1.0;
     292          a[2]=1.0;
     293          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     294         
     295        }
     296        glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
     297        glVertex3f(v2.x, v2.y, v2.z);
     298        if(height[i+1][j+1]<snowheight){
     299          a[0]=0;
     300          a[1] =1.0-height[i+1][j+1]/10-.3;
     301          a[2]=0;
     302          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     303        }
     304        else{
     305          a[0]=1.0;
     306          a[1]=1.0;
     307          a[2]=1.0;
     308          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     309         
     310         
     311        }
     312        glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
     313        glVertex3f(v3.x, v3.y, v3.z);
     314        if(height[i][j+1]<snowheight){
     315          a[0]=0;
     316          a[1] =1.0-height[i+1][j+1]/10-.3;
     317          a[2]=0;
     318          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     319        }
     320        else{
     321          a[0]=1.0;
     322          a[1]=1.0;
     323          a[2]=1.0;
     324          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     325        }
     326        glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
     327        glVertex3f(v4.x, v4.y, v4.z);
     328       
     329      }
     330  glEnd();
     331  /* 
     332  glBegin(GL_LINES);
     333  for( float x = -128.0; x < 128.0; x += 25.0)
     334    {
     335      for( float y = -128.0; y < 128.0; y += 25.0)
     336        {
     337          glColor3f(1,0,0);
     338          glVertex3f(x,y,-128.0);
     339          glVertex3f(x,y,0.0);
     340          glColor3f(0.5,0,0);
     341          glVertex3f(x,y,0.0);
     342          glVertex3f(x,y,128.0);
     343        }
     344    }
     345  for( float y = -128.0; y < 128.0; y += 25.0)
     346    {
     347      for( float z = -128.0; z < 128.0; z += 25.0)
     348        {
     349          glColor3f(0,1,0);
     350          glVertex3f(-128.0,y,z);
     351          glVertex3f(0.0,y,z);
     352          glColor3f(0,0.5,0);
     353          glVertex3f(0.0,y,z);
     354          glVertex3f(128.0,y,z);
     355        }
     356    }
     357  for( float x = -128.0; x < 128.0; x += 25.0)
     358    {
     359      for( float z = -128.0; z < 128.0; z += 25.0)
     360        {
     361          glColor3f(0,0,1);
     362          glVertex3f(x,-128.0,z);
     363          glVertex3f(x,0.0,z);
     364          glColor3f(0,0,0.5);
     365          glVertex3f(x,0.0,z);
     366          glVertex3f(x,128.0,z);
     367        }
     368     
     369    }
     370  */ 
     371  //draw track
     372  glBegin(GL_LINES);
     373  glColor3f(0,1,1);
     374  for( int i = 0; i < tracklen; i++)
     375    {
     376      glVertex3f(pathnodes[i].x,pathnodes[i].y,pathnodes[i].z);
     377      glVertex3f(pathnodes[(i+1)%tracklen].x,pathnodes[(i+1)%tracklen].y,pathnodes[(i+1)%tracklen].z);
     378    }
     379  glEnd();
     380  glEndList();
    171381}
    172382
     
    181391void World::collide ()
    182392{
    183   List<WorldEntity> *a, *b;
     393  /*
     394  List *a, *b;
    184395  WorldEntity *aobj, *bobj;
    185  
    186   a = entities->get_next();
     396   
     397  a = entities;
    187398 
    188399  while( a != NULL)
    189400    {
    190       aobj = a->get_object();
     401      aobj = a->nextElement();
    191402      if( aobj->bCollide && aobj->collisioncluster != NULL)
    192403        {
    193           b = a->get_next();
     404          b = a->nextElement();
    194405          while( b != NULL )
    195406            {
    196               bobj = b->get_object();
     407              bobj = b->nextElement();
    197408              if( bobj->bCollide && bobj->collisioncluster != NULL )
    198409                {
     
    206417                  }
    207418                }
    208               b = b->get_next();
     419              b = b->nextElement();
    209420            }
    210421        }
    211       a = a->get_next();
    212     }
     422      a = a->enumerate();
     423    }
     424  */
    213425}
    214426
     
    221433 
    222434  // draw entities
    223   List<WorldEntity> *l;
    224435  WorldEntity* entity;
    225436 
    226   l = entities->get_next(); 
    227   while( l != NULL )
     437  entity = this->entities->enumerate();
     438  while( entity != NULL )
    228439    {
    229       entity = l->get_object();
    230440      if( entity->bDraw ) entity->draw();
    231       l = l->get_next();
     441      entity = this->entities->nextElement();
    232442    }
    233443 
    234444 
    235445  // draw debug coord system
    236   glLoadIdentity();
    237  
    238 
    239   glBegin(GL_LINES);
    240  
    241   for( float x = -128.0; x < 128.0; x += 25.0)
    242     {
    243       for( float y = -128.0; y < 128.0; y += 25.0)
    244         {
    245           glColor3f(1,0,0);
    246           glVertex3f(x,y,-128.0);
    247           glVertex3f(x,y,0.0);
    248           glColor3f(0.5,0,0);
    249           glVertex3f(x,y,0.0);
    250           glVertex3f(x,y,128.0);
    251         }
    252     }
    253   for( float y = -128.0; y < 128.0; y += 25.0)
    254     {
    255       for( float z = -128.0; z < 128.0; z += 25.0)
    256         {
    257           glColor3f(0,1,0);
    258           glVertex3f(-128.0,y,z);
    259           glVertex3f(0.0,y,z);
    260           glColor3f(0,0.5,0);
    261           glVertex3f(0.0,y,z);
    262           glVertex3f(128.0,y,z);
    263         }
    264     }
    265   for( float x = -128.0; x < 128.0; x += 25.0)
    266     {
    267       for( float z = -128.0; z < 128.0; z += 25.0)
    268         {
    269           glColor3f(0,0,1);
    270           glVertex3f(x,-128.0,z);
    271           glVertex3f(x,0.0,z);
    272           glColor3f(0,0,0.5);
    273           glVertex3f(x,0.0,z);
    274           glVertex3f(x,128.0,z);
    275         }
    276      
    277     }
    278  
    279   //draw track
    280   glColor3f(0,1,1);
    281   for( int i = 0; i < tracklen; i++)
    282     {
    283       glVertex3f(pathnodes[i].x,pathnodes[i].y,pathnodes[i].z);
    284       glVertex3f(pathnodes[(i+1)%tracklen].x,pathnodes[(i+1)%tracklen].y,pathnodes[(i+1)%tracklen].z);
    285     }
    286   glEnd();
     446  glCallList (objectList);
     447
     448
    287449}
    288450
     
    297459void World::update ()
    298460{
    299   List<WorldEntity> *l;
     461  //List<WorldEntity> *l;
    300462  WorldEntity* entity;
    301463  Location* loc;
     
    303465  Uint32 t;
    304466 
    305   l = entities->get_next(); 
    306   while( l != NULL )
     467  //  l = entities->enumerate();
     468  entity = this->entities->enumerate();
     469  while( entity != NULL )
    307470    {
    308       entity = l->get_object();
     471
    309472     
    310473      if( !entity->isFree() )
    311474        {
    312           loc = entity->get_location();
    313           plc = entity->get_placement();
     475          loc = entity->getLocation();
     476          plc = entity->getPlacement();
    314477          t = loc->part;
    315478         
     
    318481            {
    319482              printf("An entity is out of the game area\n");
    320               entity->left_world ();
     483              entity->leftWorld ();
    321484            }
    322485          else
    323486            {
    324               while( track[t].map_coords( loc, plc) )
     487              while( track[t].mapCoords( loc, plc) )
    325488                {
    326                   track[t].post_leave (entity);
     489                  track[t].postLeave (entity);
    327490                  if( loc->part >= tracklen )
    328491                    {
    329492                      printf("An entity has left the game area\n");
    330                       entity->left_world ();
     493                      entity->leftWorld ();
    331494                      break;
    332495                    }
    333                   track[loc->part].post_enter (entity);
     496                  track[loc->part].postEnter (entity);
    334497                }
    335498            }
     
    337500      else
    338501        {
    339           /* TO DO: implement check whether this particular free entity
     502          /* \todo: implement check whether this particular free entity
    340503             is out of the game area
    341              TO DO: call function to notify the entity that it left
     504             \todo: call function to notify the entity that it left
    342505             the game area
    343506          */
    344507        }
    345508     
    346       l = l->get_next();
     509      entity = entities->nextElement();
    347510    }
    348511 
     
    353516    \param deltaT: the time passed since the last frame in milliseconds
    354517*/
    355 void World::time_slice (Uint32 deltaT)
    356 {
    357   List<WorldEntity> *l;
     518void World::timeSlice (Uint32 deltaT)
     519{
     520  //List<WorldEntity> *l;
    358521  WorldEntity* entity;
    359   float seconds = deltaT;
    360  
    361   seconds /= 1000;
    362  
    363   l = entities->get_next(); 
    364   while( l != NULL)
     522  float seconds = deltaT / 1000.0;
     523 
     524  entity = entities->enumerate();
     525  while( entity != NULL)
    365526    {
    366       entity = l->get_object();
    367527      entity->tick (seconds);
    368       l = l->get_next();
    369     }
    370  
    371   for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
     528      entity = entities->nextElement();
     529    }
     530
     531  //for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
    372532}
    373533
     
    387547   Camera Placement
    388548*/
    389 void World::calc_camera_pos (Location* loc, Placement* plc)
    390 {
    391   track[loc->part].map_camera (loc, plc);
     549void World::calcCameraPos (Location* loc, Placement* plc)
     550{
     551  track[loc->part].mapCamera (loc, plc);
    392552}
    393553
     
    403563}
    404564
     565
     566
     567/**
     568   \brief function to put your own debug stuff into it. it can display informations about
     569   the current class/procedure
     570*/
    405571void World::debug()
    406572{
    407   List<WorldEntity> *l;
     573  //List<WorldEntity> *l;
    408574  WorldEntity* entity;
    409575 
    410576  printf("counting all entities\n");
    411   l = entities->get_next(); 
    412   while( l != NULL )
     577  printf("World::debug() - enumerate()\n");
     578  entity = entities->enumerate(); 
     579  while( entity != NULL )
    413580    {
    414       entity = l->get_object();
    415581      if( entity->bDraw ) printf("got an entity\n");
    416       l = l->get_next();
    417     }
    418 }
    419 
    420 
     582      entity = entities->nextElement();
     583    }
     584}
     585
     586
     587/*
     588  \brief main loop of the world: executing all world relevant function
     589
     590  in this loop we synchronize (if networked), handle input events, give the heart-beat to
     591  all other member-entities of the world (tick to player, enemies etc.), checking for
     592  collisions drawing everything to the screen.
     593*/
    421594void World::mainLoop()
    422595{
    423596  this->lastFrame = SDL_GetTicks();
    424   this->bQuitOrxonox = false;
    425   this->bQuitCurrentGame = false;
    426   printf("World|Entering main loop\n");
    427   while(!this->bQuitOrxonox && !this->bQuitCurrentGame) /* pause pause pause ?!?!?*/
    428     {
    429       //debug routine
    430       //debug();
     597  printf("World::mainLoop() - Entering main loop\n");
     598  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
     599    {
    431600      // Network
    432601      synchronize();
    433602      // Process input
    434       handle_input();
     603      handleInput();
     604      if( this->bQuitCurrentGame || this->bQuitOrxonox)
     605        {
     606          printf("World::mainLoop() - leaving loop earlier...\n");
     607          break;
     608        }
    435609      // Process time
    436       time_slice();
     610      timeSlice();
    437611      // Process collision
    438612      collision();
    439613      // Draw
    440614      display();
    441     }
    442   printf("World|Exiting the main loop\n");
     615 
     616      for(int i = 0; i < 10000000; i++) {}
     617    }
     618  printf("World::mainLoop() - Exiting the main loop\n");
    443619}
    444620
     
    454630/**
    455631   \brief run all input processing
    456 */
    457 void World::handle_input ()
     632
     633   the command node is the central input event dispatcher. the node uses the even-queue from
     634   sdl and has its own event-passing-queue.
     635*/
     636void World::handleInput ()
    458637{
    459638  // localinput
    460   Orxonox::getInstance()->get_localinput()->process();
     639  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
     640  cn->process();
    461641  // remoteinput
    462642}
     
    464644/**
    465645   \brief advance the timeline
    466 */
    467 void World::time_slice ()
     646
     647   this calculates the time used to process one frame (with all input handling, drawing, etc)
     648   the time is mesured in ms and passed to all world-entities and other classes that need
     649   a heart-beat.
     650*/
     651void World::timeSlice ()
    468652{
    469653  Uint32 currentFrame = SDL_GetTicks();
     
    471655    {
    472656      Uint32 dt = currentFrame - this->lastFrame;
    473       /*
     657     
    474658      if(dt > 0)
    475659        {
     
    479663      else
    480664        {
    481           printf("fps = 1000\n");
    482         }
    483       */
    484       this->time_slice (dt);
     665          /* the frame-rate is limited to 100 frames per second, all other things are for
     666             nothing.
     667          */
     668          printf("fps = 1000 - frame rate is adjusted\n");
     669          SDL_Delay(10);
     670          dt = 10;
     671        }
     672      this->timeSlice (dt);
    485673      this->update ();
    486       this->localCamera->time_slice (dt);
     674      this->localCamera->timeSlice(dt);
    487675    }
    488676  this->lastFrame = currentFrame;
    489677}
    490678
     679
    491680/**
    492681   \brief compute collision detection
     
    497686}
    498687
    499 /**
    500    \brief handle keyboard commands that are not meant for WorldEntities
    501    \param cmd: the command to handle
    502    \return true if the command was handled by the system or false if it may be passed to the WorldEntities
    503 */
    504 bool World::system_command (Command* cmd)
    505 {
    506   if( !strcmp( cmd->cmd, "quit"))
    507     {
    508       if( !cmd->bUp) this->bQuitOrxonox = true;
    509       return true;
    510     }
    511   return false;
    512 }
    513 
    514 /**
    515         \brief render the current frame
     688
     689/**
     690   \brief render the current frame
     691   
     692   clear all buffers and draw the world
    516693*/
    517694void World::display ()
     
    528705}
    529706
     707/**
     708   \brief give back active camera
     709   
     710   this passes back the actualy active camera
     711   \todo ability to define more than one camera or camera-places
     712*/
    530713Camera* World::getCamera()
    531714{
     
    534717
    535718
     719/**
     720   \brief add and spawn a new entity to this world
     721   \param entity to be added
     722*/
    536723void World::spawn(WorldEntity* entity)
    537724{
     
    539726  Location* loc = NULL;
    540727  WorldEntity* owner;
    541   //T* entity = new T();
    542   entities->add (entity, LIST_ADD_NEXT);
    543   //if( loc == NULL)
    544   //{
    545       zeroloc.dist = 0;
    546       zeroloc.part = 0;
    547       zeroloc.pos = Vector();
    548       zeroloc.rot = Quaternion();
    549       loc = &zeroloc;
    550       //}
     728
     729  entities->add (entity);
     730  zeroloc.dist = 0;
     731  zeroloc.part = 0;
     732  zeroloc.pos = Vector();
     733  zeroloc.rot = Quaternion();
     734  loc = &zeroloc;
    551735  entity->init (loc, owner);
    552736  if (entity->bFree)
    553737    {
    554       this->track[loc->part].map_coords( loc, entity->get_placement());
    555     }
    556   entity->post_spawn ();
     738      this->track[loc->part].mapCoords( loc, entity->getPlacement());
     739    }
     740  entity->postSpawn ();
     741}
     742
     743
     744/**
     745   \brief add and spawn a new entity to this world
     746   \param entity to be added
     747   \param location where to add
     748*/
     749void World::spawn(WorldEntity* entity, Location* loc)
     750{
     751  Location zeroLoc;
     752  WorldEntity* owner;
     753  this->entities->add (entity);
     754  if( loc == NULL)
     755    {
     756      zeroLoc.dist = 0;
     757      zeroLoc.part = 0;
     758      zeroLoc.pos = Vector();
     759      zeroLoc.rot = Quaternion();
     760      loc = &zeroLoc;
     761    }
     762  entity->init (loc, owner);
     763  if (entity->bFree)
     764    {
     765      this->track[loc->part].mapCoords( loc, entity->getPlacement());
     766    }
     767  entity->postSpawn ();
    557768  //return entity;
    558769}
     770
     771
     772/**
     773   \brief add and spawn a new entity to this world
     774   \param entity to be added
     775   \param place where to be added
     776*/
     777void World::spawn(WorldEntity* entity, Placement* plc)
     778{
     779  Placement zeroPlc;
     780  WorldEntity* owner;
     781  if( plc == NULL)
     782    {
     783      zeroPlc.r = Vector();
     784      zeroPlc.w = Quaternion();
     785      plc = &zeroPlc;
     786    }
     787  this->entities->add (entity);
     788  entity->init (plc, owner);
     789  entity->postSpawn ();
     790  //return entity;
     791}
     792
     793
     794/*
     795  \brief commands that the world must catch
     796  \returns false if not used by the world
     797*/
     798bool World::command(Command* cmd)
     799{
     800  return false;
     801}
Note: See TracChangeset for help on using the changeset viewer.