Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6142 in orxonox.OLD for trunk/src/story_entities


Ignore:
Timestamp:
Dec 16, 2005, 7:13:57 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merge the ObjectManager to the trunk
merged with command:
svn merge -r6082:HEAD objectmanager/ ../trunk/

conflicts resolution was easy this time :)
but specially merged the world to network_world

Location:
trunk/src/story_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/network_world.cc

    r6139 r6142  
    3838#include "shell.h"
    3939
    40 #include "garbage_collector.h"
    4140#include "fast_factory.h"
    4241#include "animation_player.h"
     
    123122  PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n");
    124123
    125 
    126   // here everything that is alocated by the NetworkWorld is deleted
    127   delete this->entities;
    128   State::setWorldEntityList(NULL);
    129 
    130124  delete this->localPlayer;
    131125
     
    141135  SoundEngine::getInstance()->flushAllSources();
    142136
    143 
     137  if (State::getObjectManager() == &this->objectManager)
     138    State::setObjectManager(NULL);
    144139  // erease everything that is left.
    145140  delete PNode::getNullParent();
     
    180175  this->music = NULL;
    181176  this->shell = NULL;
    182   this->entities = NULL;
    183177  this->localPlayer = NULL;
    184178  this->localCamera = NULL;
     
    214208ErrorMessage NetworkWorld::preLoad()
    215209{
    216   State::setWorldEntityList(this->entities = new tList<WorldEntity>());
     210  State::setObjectManager(&this->objectManager);
    217211  this->cycle = 0;
    218212
     
    233227
    234228  GraphicsEngine::getInstance()->displayFPS(true);
    235 
    236   CDEngine::getInstance()->setEntityList( this->entities);
    237229}
    238230
     
    630622
    631623/**
    632  *  gets the list of entities from the world
    633  * @returns entity list
    634 */
    635 tList<WorldEntity>* NetworkWorld::getEntities()
    636 {
    637   return this->entities;
    638 }
    639 
    640 
    641 /**
    642624 *  this returns the current game time
    643625 * @returns elapsed game time
     
    648630}
    649631
    650 
    651632/**
    652633 *  function to put your own debug stuff into it. it can display informations about
    653634   the current class/procedure
    654635*/
    655 void NetworkWorld::debug()
    656 {
    657   PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");
    658   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    659   WorldEntity* entity = iterator->firstElement();
    660   while( entity != NULL)
    661   {
    662     PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
    663     entity = iterator->nextElement();
    664   }
    665   delete iterator;
    666 }
     636// void NetworkWorld::debug()
     637// {
     638//   PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");
     639//   tIterator<WorldEntity>* iterator = this->entities->getIterator();
     640//   WorldEntity* entity = iterator->firstElement();
     641//   while( entity != NULL)
     642//   {
     643//     PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
     644//     entity = iterator->nextElement();
     645//   }
     646//   delete iterator;
     647// }
    667648
    668649
     
    682663    {
    683664      ++this->cycle;
    684       PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());
     665//      PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());
    685666      // Network
    686667      this->synchronize ();
     
    727708}
    728709
     710void NetworkWorld::tick(std::list<WorldEntity*> entityList, float dt)
     711{
     712  std::list<WorldEntity*>::iterator entity;
     713  for (entity = entityList.begin(); entity != entityList.end(); entity++)
     714    (*entity)->tick(dt);
     715
     716}
    729717
    730718/**
     
    763751      this->gameTime += this->dtS;
    764752
    765       tIterator<WorldEntity>* iterator = this->entities->getIterator();
    766       WorldEntity* entity = iterator->firstElement();
    767       while( entity != NULL)
    768         {
    769           entity->tick (this->dtS);
    770           entity = iterator->nextElement();
    771         }
    772       delete iterator;
     753/*      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
     754      this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
     755      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/
     756      this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
     757      this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
    773758
    774759      /* update tick the rest */
     
    780765
    781766      ParticleEngine::getInstance()->tick(this->dtS);
    782       GarbageCollector::getInstance()->tick(this->dtS);
    783767
    784768
     
    805789void NetworkWorld::update()
    806790{
    807   GarbageCollector::getInstance()->update();
    808791  GraphicsEngine::getInstance()->update(this->dtS);
    809792  PNode::getNullParent()->updateNode (this->dtS);
     
    816799void NetworkWorld::collide()
    817800{
    818   CDEngine::getInstance()->checkCollisions();
     801  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
     802                                            this->objectManager.getObjectList(OM_GROUP_01_PROJ));
     803  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),
     804                                            this->objectManager.getObjectList(OM_COMMON));
    819805}
    820806
     
    846832void NetworkWorld::draw ()
    847833{
    848   /* draw entities */
    849   WorldEntity* entity;
    850   glLoadIdentity();
    851   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    852   entity = iterator->firstElement();
    853   while( entity != NULL )
    854   {
    855     if( entity->isVisible() ) entity->draw();
    856     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
    857     entity = iterator->nextElement();
    858   }
    859   delete iterator;
     834  GraphicsEngine* engine = GraphicsEngine::getInstance();
     835  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
     836  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));
     837  engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));
     838  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));
     839  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));
     840  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
     841
     842//   {
     843//     if( entity->isVisible() ) entity->draw();
     844  //FIXME
     845//     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
     846//     entity = iterator->nextElement();
     847//   }
    860848
    861849  glCallList (objectList);
     
    866854    PNode::getNullParent()->debugDraw(0);
    867855
    868   GraphicsEngine::getInstance()->draw();
     856  engine->draw();
    869857  //TextEngine::getInstance()->draw();
    870858}
     
    876864void NetworkWorld::spawn(WorldEntity* entity)
    877865{
    878   this->entities->add (entity);
     866//   this->entities->add (entity);
    879867  entity->postSpawn ();
    880868}
     
    889877void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    890878{
    891   this->entities->add (entity);
     879//   this->entities->add (entity);
    892880
    893881  entity->setAbsCoor (*absCoor);
     
    915903      entity->setRelDir (*relDir);
    916904
    917       this->entities->add (entity);
     905//       this->entities->add (entity);
    918906
    919907      entity->postSpawn ();
  • trunk/src/story_entities/network_world.h

    r6139 r6142  
    1111#include "story_entity.h"
    1212#include "p_node.h"
     13#include "object_manager.h"
    1314
    1415class NetworkWorld;
     16
    1517class WorldEntity;
    1618class Camera;
     
    1820class GLMenuImageScreen;
    1921class Terrain;
    20 class GarbageCollector;
    21 class Text;
    2222class TiXmlElement;
    2323
    2424class Shell;
    2525class OggPlayer;
    26 template<class T> class tList;
    2726
    2827//! The game world
     
    6160  bool command (Command* cmd);
    6261
    63   tList<WorldEntity>* getEntities();
    64 
    6562  /* interface to world */
    6663  void spawn (WorldEntity* entity);
     
    8481  void synchronize ();
    8582  void handleInput ();
     83  void tick (std::list<WorldEntity*> worldEntity, float dt);
    8684  void tick ();
    8785  void update ();
     
    104102    bool bPause;                        //!< pause mode
    105103
     104    ObjectManager      objectManager;   //!< The ObjectManager of this World.
     105
    106106    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    107107
     
    118118
    119119    GLuint objectList;                  //!< temporary: @todo this will be ereased soon
    120     tList<WorldEntity>* entities;       //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
     120
    121121    Player* localPlayer;                //!< The Player, you fly through the level.
    122122};
  • trunk/src/story_entities/world.cc

    r6074 r6142  
    3838#include "shell.h"
    3939
    40 #include "garbage_collector.h"
    4140#include "fast_factory.h"
    4241#include "animation_player.h"
     
    123122  PRINTF(3)("World::~World() - deleting current world\n");
    124123
    125 
    126   // here everything that is alocated by the World is deleted
    127   delete this->entities;
    128   State::setWorldEntityList(NULL);
    129 
    130124  delete this->localPlayer;
    131125
     
    141135  SoundEngine::getInstance()->flushAllSources();
    142136
    143 
     137  if (State::getObjectManager() == &this->objectManager)
     138    State::setObjectManager(NULL);
    144139  // erease everything that is left.
    145140  delete PNode::getNullParent();
     
    180175  this->music = NULL;
    181176  this->shell = NULL;
    182   this->entities = NULL;
    183177  this->localPlayer = NULL;
    184178  this->localCamera = NULL;
     
    214208ErrorMessage World::preLoad()
    215209{
    216   State::setWorldEntityList(this->entities = new tList<WorldEntity>());
     210  State::setObjectManager(&this->objectManager);
    217211  this->cycle = 0;
    218212
     
    233227
    234228  GraphicsEngine::getInstance()->displayFPS(true);
    235 
    236   CDEngine::getInstance()->setEntityList( this->entities);
    237229}
    238230
     
    588580
    589581/**
    590  *  gets the list of entities from the world
    591  * @returns entity list
    592 */
    593 tList<WorldEntity>* World::getEntities()
    594 {
    595   return this->entities;
    596 }
    597 
    598 
    599 /**
    600582 *  this returns the current game time
    601583 * @returns elapsed game time
     
    605587  return this->gameTime;
    606588}
    607 
    608 
    609 /**
    610  *  function to put your own debug stuff into it. it can display informations about
    611    the current class/procedure
    612 */
    613 void World::debug()
    614 {
    615   PRINTF(0)("Printing out the List of alive WorldEntities:\n");
    616   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    617   WorldEntity* entity = iterator->firstElement();
    618   while( entity != NULL)
    619   {
    620     PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
    621     entity = iterator->nextElement();
    622   }
    623   delete iterator;
    624 }
    625 
    626589
    627590/**
     
    640603    {
    641604      ++this->cycle;
    642       PRINTF(4)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
    643605      // Network
    644606      this->synchronize ();
     
    685647}
    686648
     649void World::tick(std::list<WorldEntity*> entityList, float dt)
     650{
     651  std::list<WorldEntity*>::iterator entity;
     652  for (entity = entityList.begin(); entity != entityList.end(); entity++)
     653    (*entity)->tick(dt);
     654
     655}
    687656
    688657/**
     
    721690      this->gameTime += this->dtS;
    722691
    723       tIterator<WorldEntity>* iterator = this->entities->getIterator();
    724       WorldEntity* entity = iterator->firstElement();
    725       while( entity != NULL)
    726         {
    727           entity->tick (this->dtS);
    728           entity = iterator->nextElement();
    729         }
    730       delete iterator;
     692/*      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
     693      this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
     694      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/
     695      this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
     696      this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
    731697
    732698      /* update tick the rest */
     
    738704
    739705      ParticleEngine::getInstance()->tick(this->dtS);
    740       GarbageCollector::getInstance()->tick(this->dtS);
    741706
    742707
     
    763728void World::update()
    764729{
    765   GarbageCollector::getInstance()->update();
    766730  GraphicsEngine::getInstance()->update(this->dtS);
    767731  PNode::getNullParent()->updateNode (this->dtS);
     
    774738void World::collide()
    775739{
    776   CDEngine::getInstance()->checkCollisions();
     740  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
     741                                            this->objectManager.getObjectList(OM_GROUP_01_PROJ));
     742  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),
     743                                            this->objectManager.getObjectList(OM_COMMON));
    777744}
    778745
     
    804771void World::draw ()
    805772{
    806   /* draw entities */
    807   WorldEntity* entity;
    808   glLoadIdentity();
    809   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    810   entity = iterator->firstElement();
    811   while( entity != NULL )
    812   {
    813     if( entity->isVisible() ) entity->draw();
    814     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
    815     entity = iterator->nextElement();
    816   }
    817   delete iterator;
     773  GraphicsEngine* engine = GraphicsEngine::getInstance();
     774  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
     775  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));
     776  engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));
     777  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));
     778  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));
     779  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
     780
     781//   {
     782//     if( entity->isVisible() ) entity->draw();
     783  //FIXME
     784//     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
     785//     entity = iterator->nextElement();
     786//   }
    818787
    819788  glCallList (objectList);
     
    824793    PNode::getNullParent()->debugDraw(0);
    825794
    826   GraphicsEngine::getInstance()->draw();
     795  engine->draw();
    827796  //TextEngine::getInstance()->draw();
    828797}
     
    834803void World::spawn(WorldEntity* entity)
    835804{
    836   this->entities->add (entity);
     805//   this->entities->add (entity);
    837806  entity->postSpawn ();
    838807}
     
    847816void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    848817{
    849   this->entities->add (entity);
     818//   this->entities->add (entity);
    850819
    851820  entity->setAbsCoor (*absCoor);
     
    873842      entity->setRelDir (*relDir);
    874843
    875       this->entities->add (entity);
     844//       this->entities->add (entity);
    876845
    877846      entity->postSpawn ();
  • trunk/src/story_entities/world.h

    r6048 r6142  
    1111#include "story_entity.h"
    1212#include "p_node.h"
     13#include "object_manager.h"
    1314
    14 class World;
     15
    1516class WorldEntity;
    1617class Camera;
     
    1819class GLMenuImageScreen;
    1920class Terrain;
    20 class GarbageCollector;
    21 class Text;
    2221class TiXmlElement;
    2322
    2423class Shell;
    2524class OggPlayer;
    26 template<class T> class tList;
    2725
    2826//! The game world
     
    6159  bool command (Command* cmd);
    6260
    63   tList<WorldEntity>* getEntities();
    64 
    6561  /* interface to world */
    6662  void spawn (WorldEntity* entity);
     
    8480  void synchronize ();
    8581  void handleInput ();
     82  void tick (std::list<WorldEntity*> worldEntity, float dt);
    8683  void tick ();
    8784  void update ();
     
    104101    bool bPause;                        //!< pause mode
    105102
     103    ObjectManager      objectManager;   //!< The ObjectManager of this World.
     104
    106105    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    107106
     
    118117
    119118    GLuint objectList;                  //!< temporary: @todo this will be ereased soon
    120     tList<WorldEntity>* entities;       //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
     119
    121120    Player* localPlayer;                //!< The Player, you fly through the level.
    122121};
Note: See TracChangeset for help on using the changeset viewer.