Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 5, 2006, 4:39:02 PM (18 years ago)
Author:
bensch
Message:

merged the presentation back

Location:
trunk/src/story_entities
Files:
6 edited

Legend:

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

    r9110 r9235  
    6262#include "game_rules.h"
    6363
    64 using namespace std;
    65 
    6664#include "script_class.h"
    6765CREATE_SCRIPTABLE_CLASS(GameWorld, CL_GAME_WORLD,
    6866                        addMethod("setPlaymode", ExecutorLua1<GameWorld,const std::string&>(&GameWorld::setPlaymode))
     67                        ->addMethod("setSoundtrack", ExecutorLua1<GameWorld, const std::string&>(&GameWorld::setSoundtrack))
    6968                       );
    7069
     
    158157
    159158  PRINTF(3)("> Loading world: '%s'\n", getLoadFile().c_str());
    160 //  TiXmlElement* element;
    161 //  GameLoader* loader = GameLoader::getInstance();
     159  //  TiXmlElement* element;
     160  //  GameLoader* loader = GameLoader::getInstance();
    162161
    163162  if( getLoadFile().empty())
     
    233232
    234233
     234void GameWorld::setSoundtrack(const std::string& soundTrack)
     235{
     236  if (this->dataTank != NULL)
     237  {
     238    this->dataTank->setSoundTrack(soundTrack);
     239    this->dataTank->music->play();
     240  }
     241}
     242
     243
    235244/**
    236245 *  starts the GameWorld
     
    312321    /* update the state */
    313322    //this->update (); /// LESS REDUNDANCY.
    314 //      PNode::getNullParent()->updateNode(this->dtS);
     323    //      PNode::getNullParent()->updateNode(this->dtS);
    315324    PNode::getNullParent()->updateNode(this->dtS);
    316325
     
    459468  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
    460469      this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ));
    461   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
    462       this->dataTank->objectManager->getObjectList(OM_GROUP_01));
     470  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
     471    this->dataTank->objectManager->getObjectList(OM_GROUP_00));
     472
     473  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
     474  this->dataTank->objectManager->getObjectList(OM_GROUP_02));
     475  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_02),
     476  this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
     477
    463478
    464479  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
     
    536551void GameWorld::renderPassReflection()
    537552{
    538     // clear buffer
     553  // clear buffer
    539554  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    540 //  glLoadIdentity();
     555  //  glLoadIdentity();
    541556
    542557  const std::list<BaseObject*>* reflectedWaters;
     
    562577      // draw everything to be included in the reflection
    563578      this->drawEntityList(State::getObjectManager()->getReflectionList());
    564 //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
    565 //         this->drawEntityList(State::getObjectManager()->getObjectList(this->dataTank->drawLists[i]));
     579      //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
     580      //         this->drawEntityList(State::getObjectManager()->getObjectList(this->dataTank->drawLists[i]));
    566581
    567582      // clean up from reflection rendering
     
    578593void GameWorld::renderPassRefraction()
    579594{
    580     // clear buffer
     595  // clear buffer
    581596  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    582597  //glLoadIdentity();
     
    602617      // draw everything to be included in the reflection
    603618      this->drawEntityList(State::getObjectManager()->getReflectionList());
    604 //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
    605 //         this->drawEntityList(State::getObjectManager()->getObjectList(this->dataTank->drawLists[i]));
     619      //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
     620      //         this->drawEntityList(State::getObjectManager()->getObjectList(this->dataTank->drawLists[i]));
    606621
    607622      // clean up from reflection rendering
  • trunk/src/story_entities/game_world.h

    r8740 r9235  
    3131class GameWorld : public StoryEntity
    3232{
    33   public:
    34     GameWorld ();
    35     virtual ~GameWorld ();
     33public:
     34  GameWorld ();
     35  virtual ~GameWorld ();
    3636
    37     virtual void loadParams(const TiXmlElement* root);
     37  virtual void loadParams(const TiXmlElement* root);
    3838
    39     /* functions from story-entity */
    40     virtual ErrorMessage init();
    41     virtual ErrorMessage loadData();
    42     virtual ErrorMessage unloadData();
     39  /* functions from story-entity */
     40  virtual ErrorMessage init();
     41  virtual ErrorMessage loadData();
     42  virtual ErrorMessage unloadData();
    4343
    44     virtual bool start();
    45     virtual bool stop();
    46     virtual bool pause();
    47     virtual bool resume();
    48     virtual void run();
     44  virtual bool start();
     45  virtual bool stop();
     46  virtual bool pause();
     47  virtual bool resume();
     48  virtual void run();
    4949
    50     void setPlaymode(Playable::Playmode playmode);
    51     void setPlaymode(const std::string& playmode);
    52     /**  this returns the current game time @returns elapsed game time     */
    53     inline double getGameTime() { return this->gameTime; }
    54     /** sets the game speed @param speed speed of the Game */
    55     inline void setSpeed(float speed) { this->speed = speed; };
    56     /**  returns the track path of this world @returns the track path */
    57 
    58     void togglePNodeVisibility();
    59     void toggleBVVisibility(int level);
    60 
    61     inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; }
     50  void setPlaymode(Playable::Playmode playmode);
     51  void setPlaymode(const std::string& playmode);
     52  /**  this returns the current game time @returns elapsed game time     */
     53  inline double getGameTime() { return this->gameTime; }
     54  /** sets the game speed @param speed speed of the Game */
     55  inline void setSpeed(float speed) { this->speed = speed; };
     56  /**  returns the track path of this world @returns the track path */
    6257
    6358
    64   protected:
    65     /* world - running functions */
    66     virtual void synchronize();
    67     virtual void handleInput();
    68     virtual void tick(ObjectManager::EntityList worldEntity, float dt);
    69     virtual void tick();
    70     virtual void update();
    71     virtual void checkGameRules();
    72     virtual void collisionDetection();
    73     virtual void collisionReaction();
     59  void setSoundtrack(const std::string& soundTrack);
     60  void togglePNodeVisibility();
     61  void toggleBVVisibility(int level);
    7462
    75     void applyCameraSettings();
    76     void drawEntityList(const ObjectManager::EntityList& drawList ) const;
    77     virtual void renderPassReflection();
    78     virtual void renderPassRefraction();
    79     virtual void renderPassAll();
     63  inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; }
    8064
    8165
    82     virtual void display();
     66protected:
     67  /* world - running functions */
     68  virtual void synchronize();
     69  virtual void handleInput();
     70  virtual void tick(ObjectManager::EntityList worldEntity, float dt);
     71  virtual void tick();
     72  virtual void update();
     73  virtual void checkGameRules();
     74  virtual void collisionDetection();
     75  virtual void collisionReaction();
     76
     77  void applyCameraSettings();
     78  void drawEntityList(const ObjectManager::EntityList& drawList ) const;
     79  virtual void renderPassReflection();
     80  virtual void renderPassRefraction();
     81  virtual void renderPassAll();
    8382
    8483
    85   private:
    86     void displayLoadScreen();
    87     void releaseLoadScreen();
     84  virtual void display();
    8885
    8986
    90   protected:
    91     GameWorldData*      dataTank;                     //!< reference to the GameWorld Data Tank
    92     TiXmlElement*       dataXML;                      //!< The XML-Element this World has been loaded with.
     87private:
     88  void displayLoadScreen();
     89  void releaseLoadScreen();
    9390
    94     bool                showPNodes;                   //!< if the PNodes should be visible.
    95     bool                showBV;                       //!< if the Bounding Volumes should be visible.
    96     int                 showBVLevel;                  //!< the depth level of the displayed bounding volumes
    9791
    98     /* world timing */
    99     double              lastFrame;                    //!< last time of frame (in MiliSeconds)
    100     Uint32              cycle;                        //!< The cycle we are in (starts with 0 and rises with every frame)
    101     float               dtS;                          //!< The time needed for caluculations in seconds
    102     float               speed;                        //!< how fast the game flows
    103     double              gameTime;                     //!< this is where the game time is saved
    104     double              frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.
     92protected:
     93  GameWorldData*      dataTank;                     //!< reference to the GameWorld Data Tank
     94  TiXmlElement*       dataXML;                      //!< The XML-Element this World has been loaded with.
    10595
    106     GameRules*          gameRules;                    //!< Pointer to the data structure containig the game rules
     96  bool                showPNodes;                   //!< if the PNodes should be visible.
     97  bool                showBV;                       //!< if the Bounding Volumes should be visible.
     98  int                 showBVLevel;                  //!< the depth level of the displayed bounding volumes
    10799
    108   private:
    109     /* external modules interfaces */
    110     ScriptManager       scriptManager;
    111     OrxShell::Shell*    shell;
     100  /* world timing */
     101  double              lastFrame;                    //!< last time of frame (in MiliSeconds)
     102  Uint32              cycle;                        //!< The cycle we are in (starts with 0 and rises with every frame)
     103  float               dtS;                          //!< The time needed for caluculations in seconds
     104  float               speed;                        //!< how fast the game flows
     105  double              gameTime;                     //!< this is where the game time is saved
     106  double              frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.
     107
     108  GameRules*          gameRules;                    //!< Pointer to the data structure containig the game rules
     109
     110private:
     111  /* external modules interfaces */
     112  ScriptManager       scriptManager;
     113  OrxShell::Shell*    shell;
    112114};
    113115
  • trunk/src/story_entities/game_world_data.cc

    r9019 r9235  
    249249  this->tickLists.push_back(OM_GROUP_01);
    250250  this->tickLists.push_back(OM_GROUP_01_PROJ);
     251  this->tickLists.push_back(OM_GROUP_02);
    251252
    252253  this->drawLists.push_back(OM_ENVIRON_NOTICK);
    253254  this->drawLists.push_back(OM_ENVIRON);
    254   this->drawLists.push_back(OM_COMMON);
    255255  this->drawLists.push_back(OM_GROUP_00);
    256256  this->drawLists.push_back(OM_GROUP_00_PROJ);
    257257  this->drawLists.push_back(OM_GROUP_01);
    258258  this->drawLists.push_back(OM_GROUP_01_PROJ);
     259  this->drawLists.push_back(OM_GROUP_02);
     260  this->drawLists.push_back(OM_COMMON);
    259261
    260262  /* init the pnode tree */
     
    343345  LoadParamXML(root, "GameRule", this, GameWorldData, loadGameRule);
    344346
     347  LoadParam(root, "clip-region", this->localCamera, Camera, setClipRegion);
     348
    345349
    346350  //LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);
    347351  //LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
    348352
    349   this->localCamera->setClipRegion(1, 10000.0);
    350353  if( this->sky != NULL)
    351354    this->localCamera->addChild(this->sky);
  • trunk/src/story_entities/menu/game_menu.cc

    r9110 r9235  
    4040
    4141#include "network_manager.h"
     42
     43#include "preferences.h"
    4244
    4345//! This creates a Factory to fabricate a GameMenu
     
    126128  this->levelsBox = NULL;
    127129  this->networkBox = NULL;
    128  
     130
    129131  this->clientNetworkBox = NULL;
    130132  this->serverNetworkBox = NULL;
     
    239241    {
    240242      OrxGui::GLGuiBox * box = new OrxGui::GLGuiBox();
    241      
     243
    242244      OrxGui::GLGuiButton* clientButton = new OrxGui::GLGuiPushButton("Client");
    243245      box->pack(clientButton);
     
    247249      box->pack(serverButton);
    248250      serverButton->connect(SIGNAL(serverButton, released), this, SLOT(GameMenu, showServerMenu));
    249      
     251
    250252      networkBox->pack( box );
    251253    }
     
    340342  OrxGui::GLGuiHandler::getInstance()->activateCursor();
    341343  OrxGui::GLGuiHandler::getInstance()->activate();
    342   OrxGui::GLGuiHandler::getInstance()->cursor()->loadTextureSequence(ResourceManager::getInstance()->getDataDir() + "/" + "maps/reap_mouse/reap_mouse_##.png", 1, 49);
    343344
    344345  /* now call the underlying*/
     
    518519    //this->serverNetworkBox = NULL;
    519520  }
    520  
     521
    521522  if ( !this->clientNetworkBox )
    522523  {
     
    526527      text->setText( "Host:" );
    527528      this->clientNetworkBox->pack( text );
    528      
     529
    529530      this->ipInputLine = new OrxGui::GLGuiInputLine( );
    530       this->ipInputLine->setText( "tardis-d08" );
     531      this->ipInputLine->setText( Preferences::getInstance()->getString( "multiplayer", "lastVisitedServer", "localhost" ) );
    531532      this->clientNetworkBox->pack( this->ipInputLine );
    532533      this->ipInputLine->connect(SIGNAL(ipInputLine, enterPushed), this, SLOT(GameMenu, connectToServer));
    533534      this->ipInputLine->select();
    534      
     535
    535536      OrxGui::GLGuiButton* connectButton = new OrxGui::GLGuiPushButton("Connect");
    536537      clientNetworkBox->pack(connectButton);
     
    538539    }
    539540  }
    540  
     541
    541542  this->networkBox->pack( this->clientNetworkBox );
    542  
     543
    543544  this->clientNetworkBox->showAll();
    544  
     545
    545546  //this->clientNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
    546547}
     
    558559    //this->clientNetworkBox = NULL;
    559560  }
    560  
     561
    561562  if ( !this->serverNetworkBox )
    562563  {
     
    566567      text->setText( "Map:" );
    567568      this->serverNetworkBox->pack( text );
    568      
     569
    569570      OrxGui::GLGuiText * text2 = new OrxGui::GLGuiText();
    570571      text2->setText( "Multiplayer TeamDeathMatch Arena" );
    571572      this->serverNetworkBox->pack( text2 );
    572      
     573
    573574      OrxGui::GLGuiButton* createButton = new OrxGui::GLGuiPushButton("Create Server");
    574575      serverNetworkBox->pack(createButton);
     
    576577    }
    577578  }
    578  
     579
    579580  this->networkBox->pack( this->serverNetworkBox );
    580  
     581
    581582  this->serverNetworkBox->showAll();
    582  
     583
    583584  //this->serverNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
    584585}
     
    590591{
    591592  PRINTF(0)("Connecting to %s\n", this->ipInputLine->_getText().c_str() );
    592  
     593
    593594  State::setOnline(true);
    594595  NetworkManager::getInstance()->establishConnection( this->ipInputLine->_getText(), 9999 );
    595  
     596
     597  Preferences::getInstance()->setString( "multiplayer", "lastVisitedServer", this->ipInputLine->_getText() );
     598
    596599  this->startLevel( 5 );
    597600}
     
    600603{
    601604  PRINTF(0)("Create server\n" );
    602  
     605
    603606  State::setOnline(true);
    604607  NetworkManager::getInstance()->createServer( 9999 );
    605  
     608
    606609  this->startLevel( 5 );
    607610}
  • trunk/src/story_entities/multi_player_world.cc

    r9110 r9235  
    9797  //CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), this->dataTank->objectManager->getObjectList(OM_PLAYERS));
    9898
    99   PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_PLAYERS_PROJ\n\n");
    100   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ),
    101   this->dataTank->objectManager->getObjectList(OM_PLAYERS));
    10299  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n");
    103100  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
     
    106103  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
    107104    this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
     105  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_PLAYERS_PROJ\n\n");
    108106  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
    109     this->dataTank->objectManager->getObjectList(OM_GROUP_00));
    110   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
    111     this->dataTank->objectManager->getObjectList(OM_GROUP_01));
     107    this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ));
     108
     109  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
     110  this->dataTank->objectManager->getObjectList(OM_PLAYERS));
     111  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
     112  this->dataTank->objectManager->getObjectList(OM_PLAYERS));
    112113
    113114
  • trunk/src/story_entities/multi_player_world_data.cc

    r9008 r9235  
    109109ErrorMessage MultiPlayerWorldData::loadWorldEntities(const TiXmlElement* root)
    110110{
    111   /* load the spawning points */
    112   const TiXmlElement* element = root->FirstChildElement("SpawningPoints");
    113   if( element == NULL)
    114   {
    115     PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n");
    116   }
    117   else
    118   {
    119     element = element->FirstChildElement();
    120     // load Players/Objects/Whatever
    121     PRINTF(4)("Loading Spawning Points\n");
    122     while( element != NULL)
    123     {
    124       BaseObject* created = Factory::fabricate(element);
    125       if( created != NULL )
    126         printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());
    127 
    128       element = element->NextSiblingElement();
    129       glmis->step();
    130     }
    131     PRINTF(4)("Done loading Spawning Points\n");
     111  const TiXmlElement* element = NULL;
     112 
     113  if( NetworkManager::getInstance()->isGameServer() )
     114  {
     115    /* load the spawning points */
     116    element = root->FirstChildElement("SpawningPoints");
     117    if( element == NULL)
     118    {
     119      PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n");
     120    }
     121    else
     122    {
     123      element = element->FirstChildElement();
     124      // load Players/Objects/Whatever
     125      PRINTF(4)("Loading Spawning Points\n");
     126      while( element != NULL)
     127      {
     128        BaseObject* created = Factory::fabricate(element);
     129        if( created != NULL )
     130          printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());
     131
     132        element = element->NextSiblingElement();
     133        glmis->step();
     134      }
     135      PRINTF(4)("Done loading Spawning Points\n");
     136    }
    132137  }
    133138
Note: See TracChangeset for help on using the changeset viewer.