Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6424 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jan 7, 2006, 11:07:22 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the branche network back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r 6351:HEAD
no conflicts

Location:
trunk/src
Files:
4 deleted
35 edited
19 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r6222 r6424  
    4848                  story_entities/story_entity.cc \
    4949                  story_entities/campaign.cc \
    50                   story_entities/world.cc \
    51                   story_entities/network_world.cc \
     50                  story_entities/campaign_data.cc \
     51                  story_entities/game_world.cc \
     52                  story_entities/game_world_data.cc \
     53                  story_entities/single_player_world.cc \
     54                  story_entities/single_player_world_data.cc \
     55                  story_entities/multi_player_world.cc \
     56                  story_entities/multi_player_world_data.cc \
    5257                  world_entities/world_entity.cc \
    5358                  world_entities/camera.cc \
     
    96101                 story_entities/story_def.h \
    97102                 story_entities/campaign.h \
    98                  story_entities/world.h \
    99                  story_entities/network_world.h \
     103                 story_entities/campaign_data.h \
     104                 story_entities/game_world.h \
     105                 story_entities/game_world_data.h \
     106                 story_entities/single_player_world.h \
     107                 story_entities/single_player_world_data.h \
     108                 story_entities/multi_player_world.h \
     109                 story_entities/multi_player_world_data.h \
    100110                 world_entities/world_entity.h \
    101111                 world_entities/camera.h \
  • trunk/src/defs/class_id.h

    r6341 r6424  
    147147  // StoryEntities (range from 0x00000100 to 0x000001ff)
    148148  CL_CAMPAIGN                   =    0x00000101,
    149   CL_WORLD                      =    0x00000102,
    150 
     149  CL_CAMPAIGN_DATA              =    0x00000102,
     150  CL_GAME_WORLD                 =    0x00000103,
     151  CL_GAME_WORLD_DATA            =    0x00000104,
     152  CL_SINGLE_PLAYER_WORLD        =    0x00000105,
     153  CL_SINGLE_PLAYER_WORLD_DATA   =    0x00000106,
     154  CL_MULTI_PLAYER_WORLD         =    0x00000107,
     155  CL_MULTI_PLAYER_WORLD_DATA    =    0x00000108,
    151156
    152157  // WorldEntities (range from 0x00000200 to 0x000004ff)
  • trunk/src/lib/Makefile.am

    r6074 r6424  
    3636                        lang/base_object.cc \
    3737                        lang/class_list.cc \
     38                        data/data_tank.cc \
    3839                        util/substring.cc \
    3940                        util/color.cc \
     
    4748noinst_HEADERS =        coord/p_node.h \
    4849                        lang/base_object.h \
     50                        data/data_tank.h \
    4951                        graphics/render2D/element_2d.h \
    5052                        graphics/render2D/render_2d.h \
     
    7072          particles \
    7173          collision_detection \
    72           network \
     74                network \
    7375          parser \
    7476          shell \
  • trunk/src/lib/coord/p_node.cc

    r6341 r6424  
    2929
    3030#include "synchronizeable.h"
     31
     32#include "shell_command.h"
     33SHELL_COMMAND(debugNode, PNode, debugNodeSC);
    3134
    3235using namespace std;
     
    152155  }
    153156}
     157
     158
     159/**
     160 *  init the pnode to a well definied state
     161 *
     162 * this function actualy only updates the PNode tree
     163 */
     164void PNode::init()
     165{
     166  /* just update all aboslute positions via timestep 0.001ms */
     167  this->updateNode(0.001f);
     168  this->updateNode(0.001f);
     169}
     170
    154171
    155172/**
  • trunk/src/lib/coord/p_node.h

    r6341 r6424  
    7878
    7979  void loadParams(const TiXmlElement* root);
     80
     81  void init();
    8082
    8183  // ACTIVATION //
     
    172174  // DEBUG //
    173175  void countChildNodes(int& nodes) const;
     176  void debugNodeSC (unsigned int depth = 1, unsigned int level = 0) { this->debugNode(depth, level); };
    174177  void debugNode (unsigned int depth = 1, unsigned int level = 0) const;
    175178  void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1, 0, 0), unsigned int level = 0) const;
  • trunk/src/lib/network/network_game_manager.cc

    r6341 r6424  
    2323#include "network_stream.h"
    2424#include "converter.h"
     25
     26#include "p_node.h"
     27
    2528
    2629/* include your own header */
     
    237240 * @param classID: The ID of the class of which an entity should be created
    238241 */
    239 BaseObject* NetworkGameManager::createEntity( TiXmlElement* element)
     242BaseObject* NetworkGameManager::createEntity(const TiXmlElement* element)
    240243{
    241244  if ( this->isServer() )
     
    252255    if ( !b )
    253256    {
    254       PRINTF(1)("Could not fabricate Object with classID %x\n", element->Value() );
     257      PRINTF(1)("Could not fabricate Object with className %s\n", element->Value() );
    255258      return NULL;
    256259    }
     
    391394  //PRINTF(0)("SendEntityList: n = %d\n", networkStream->getSyncCount()-2 );
    392395
     396  int n = 0;
     397
    393398  while ( it != e )
    394399  {
     
    403408    if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getOwner()) ) )
    404409      return;
     410
     411
     412    PRINTF(0)("id = %x %s %s\n", (int)((*it)->getLeafClassID()), (*it)->getClassName(), (*it)->getName());
     413
     414
     415    /*if ( (*it)->isA(CL_WORLD_ENTITY) )
     416    {
     417      n = dynamic_cast<WorldEntity*>((*it))->readState( outBuffer[userID].buffer, outBuffer[userID].maxLength-outBuffer[userID].length );
     418      if ( n = 0 )
     419      {
     420        PRINTF(2)("n = 0\n");
     421      }
     422      outBuffer[userID].length += n;
     423  }*/
    405424
    406425    it++;
     
    436455 * @param owner: owner of this synchronizealbe
    437456 */
    438 void NetworkGameManager::doCreateEntity( ClassID classID, int uniqueID, int owner )
     457BaseObject* NetworkGameManager::doCreateEntity( ClassID classID, int uniqueID, int owner )
    439458{
    440459  BaseObject * b = Factory::fabricate( classID );
     
    443462  {
    444463    PRINTF(1)("Could not fabricate Object with classID %x\n", classID);
    445     return;
     464    return NULL;
    446465  }
    447466
     
    455474      s->setIsOutOfSync( true );
    456475    PRINTF(0)("Fabricated %s with id %d\n", s->getClassName(), s->getUniqueID());
     476    return b;
    457477  }
    458478  else
     
    461481    delete b;
    462482  }
     483  return NULL;
    463484}
    464485
     
    695716    i += Converter::byteArrayToInt( &data[i], &owner );
    696717
     718    PRINTF(0)("before fabricate\n");
    697719    if ( classID != CL_NETWORK_GAME_MANAGER && classID != CL_HANDSHAKE )
    698       doCreateEntity( (ClassID)classID, uniqueID, owner );
    699 
    700   }
     720    {
     721      BaseObject* b = doCreateEntity( (ClassID)classID, uniqueID, owner );
     722
     723      /*if ( b != NULL )
     724      {
     725        if ( b->isA(CL_WORLD_ENTITY) )
     726        {
     727          int n = dynamic_cast<WorldEntity*>(b)->writeState( data, length, sender );
     728
     729          i += n;
     730        }
     731    }*/
     732    }
     733
     734  }
     735
    701736  return true;
    702737}
  • trunk/src/lib/network/network_game_manager.h

    r6341 r6424  
    7575
    7676    void createEntity( ClassID classID, int owner = 0 );
    77     BaseObject* createEntity( TiXmlElement* element);
     77    BaseObject* createEntity(const TiXmlElement* element);
    7878    void removeEntity( int uniqueID );
    7979    void sendYouAre( int uniqueID, int userID );
     
    9494    void executeRequestSync( int uniqueID, int user );
    9595
    96     void doCreateEntity(ClassID classID, int uniqueID, int owner);
     96    BaseObject* doCreateEntity(ClassID classID, int uniqueID, int owner);
    9797    void doRemoveEntity(int uniqueID);
    9898    void doRequestSync(int uniqueID, int userID);
  • trunk/src/lib/network/synchronizeable.cc

    r6341 r6424  
    3636  this->networkStream = NULL;
    3737  this->setRequestedSync( false );
     38  this->setIsOutOfSync( !(this->isServer()) );
    3839}
    3940
  • trunk/src/orxonox.cc

    r6142 r6424  
    409409    else if(!strcmp( "--server", argv[i])   || !strcmp("-s", argv[i]))
    410410      return startNetworkOrxonox(argc, argv);
    411     else if(!strcmp( "--license", argv[i])  || !strcmp("-s", argv[i]))
     411    else if(!strcmp( "--license", argv[i])  || !strcmp("-l", argv[i]))
    412412      return PRINT(0)(ORXONOX_LICENSE_SHORT);
    413413  }
  • trunk/src/story_entities/campaign.cc

    r6153 r6424  
    1313   ### File Specific:
    1414   main-programmer: Patrick Boenzli
    15    co-programmer:
    1615*/
    1716
     
    2019
    2120#include "factory.h"
    22 #include "game_loader.h"
    23 #include "story_entity.h"
    24 
    25 #include "world.h"
    26 #include "camera.h"
    27 
    2821#include "load_param.h"
    2922
     23#include "campaign_data.h"
    3024
    3125using namespace std;
    3226
    3327
    34 Campaign::Campaign ()
    35 {
    36   this->setClassID(CL_CAMPAIGN, "Campaign");
    37   this->isInit = false;
    38 }
    39 
     28/**
     29 *  the constructor
     30 * @param root the XML root element
     31 *
     32 * this constructor is always called in a XML context (loading procedure)
     33 */
    4034Campaign::Campaign ( TiXmlElement* root)
    4135{
     
    4337
    4438  PRINTF(4)("Loading Campaign...\n");
    45 
    4639  assert( root != NULL);
    4740
    48   this->isInit = false;
    49 
     41  this->campaignData = new CampaignData(root);
    5042  this->loadParams(root);
    5143
    52 
    53   //if( lastCreated != NULL)
    54   //lastCreated->setStoryID( WORLD_ID_GAMEEND);
    55 }
    56 
    57 Campaign::~Campaign ()
    58 {}
    59 
    60 
    61 ErrorMessage Campaign::init()
    62 {
    63   this->isInit = true;
    64 }
    65 
    66 /**
    67   \brief loads the Parameters of a Campaign
    68 * @param root: The XML-element to load from
    69  */
    70 void Campaign::loadParams(const TiXmlElement* root)
    71 {
    72   static_cast<BaseObject*>(this)->loadParams(root);
    73 
    74   LoadParam(root, "identifier", this, Campaign, setStoryID)
    75      .describe("A Unique Identifier for this Campaign");
    76 
    77    LoadParamXML(root, "WorldList", this, Campaign, loadWorldListParams)
    78       .describe("A List of Worlds to be loaded in this Campaign");
    79 }
    80 
    81 /**
    82   \brief loads a WorldList
    83 * @param root: the XML-element to load from
    84  */
    85 void Campaign::loadWorldListParams(const TiXmlElement* root)
    86 {
    87   if (root == NULL)
    88     return;
    89 
    90   LOAD_PARAM_START_CYCLE(root, element);
    91   {
    92     PRINTF(5)("Campaign: Constructor: adding a world\n");
    93     StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
    94     if( created != NULL)
    95     {
    96       this->addEntity( created);
    97     }
    98   }
    99   LOAD_PARAM_END_CYCLE(element);
    100 }
    101 
    102 ErrorMessage Campaign::start()
    103 {
    104   this->start(0);
    105 }
    106 
    107 //! @todo boky -> fix it
    108 ErrorMessage Campaign::start(int storyID = 0)
    109 {
    110   ErrorMessage errorCode;
    111   if( !this->isInit) return errorCode;
    112   if( storyID == WORLD_ID_GAMEEND) return errorCode;
    113   this->running = true;
    114   StoryEntity* se = this->getStoryEntity(storyID);
    115   this->currentEntity = se;
    116   while( se != NULL && this->running)
    117     {
    118       PRINTF(0)("Starting new StoryEntity Nr:%i\n", se->getStoryID());
    119       se->preLoad();
    120       se->load();
    121       se->postLoad();
    122 
    123       se->init();
    124       se->preStart();
    125       se->start();
    126       se->destroy();
    127 
    128       int nextWorldID = se->getNextStoryID();
    129 
    130       this->entities.remove(se);
    131       delete se;
    132 
    133       //printf("Campaing::start() - got nextWorldID = %i\n", nextWorldID);
    134       se = this->getStoryEntity(nextWorldID);
    135       this->currentEntity = se;
    136       if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) )
    137         {
    138           PRINTF(4)("Quitting campaing story loop\n");
    139           if(se != NULL)
    140             delete se;
    141           return errorCode;
    142         }
    143     }
    144 
    145     /* clean up all world that have not been loaded and therefore are still in the world list  -
    146        this probably does not belong into the start function. remove this later
    147     */
    148     list<StoryEntity*>::iterator it;
    149     for(it = this->entities.begin(); it != entities.end(); it++)
    150     {
    151       delete (*it);
    152     }
    153     PRINTF(1)("There is no StoryEnity left to play, quitting\n");
    154 }
    155 
    156 
    157 ErrorMessage Campaign::pause()
    158 {
    159   if(this->currentEntity != NULL)
    160     this->isPaused = true;
    161 }
    162 
    163 
    164 ErrorMessage Campaign::resume()
    165 {
    166   if(this->currentEntity != NULL)
    167     this->isPaused = false;
    168 }
    169 
    170 
    171 ErrorMessage Campaign::stop()
    172 {
    173   this->running = false;
    174   if(this->currentEntity != NULL)
    175     {
    176       this->currentEntity->stop();
    177     }
    178 }
    179 
    180 
    181 ErrorMessage Campaign::destroy()
    182 {
    183   if(this->currentEntity != NULL)
    184     {
    185       this->currentEntity->destroy();
    186       delete this->currentEntity;
    187       this->currentEntity = NULL;
    188     }
    18944}
    19045
    19146
    19247/**
    193   *  adds an game stroy entity to the campaign
    194 
    195   * @param se: The entity
    196   * @param storyID: The number that identifies the entity in the campaign. Each ID only used once in a Campaign
    197 
    198     An entity can be a world (playable), a cinematic, a shop, sounds, whatever you
    199     want to queue up in the campaign.
    200 */
    201 void Campaign::addEntity(StoryEntity* se, int storyID)
     48 * the campaign destructor
     49 */
     50Campaign::~Campaign ()
    20251{
    203   se->setStoryID(storyID);
    204   this->addEntity(se);
    205 }
    206 
    207 void Campaign::addEntity(StoryEntity* se)
    208 {
    209   this->entities.push_back(se);
     52  if( this->campaignData)
     53    delete this->campaignData;
    21054}
    21155
    21256
    213 void Campaign::removeEntity(int storyID)
     57/**
     58 *  loads the Parameters of a Campaign
     59 * @param root: The XML-element to load from
     60 */
     61void Campaign::loadParams(const TiXmlElement* root)
    21462{
    215   this->removeEntity(this->getStoryEntity(storyID));
     63  static_cast<StoryEntity*>(this)->loadParams(root);
    21664
     65  PRINTF(4)("Loaded Campaign specific stuff\n");
    21766}
    21867
    21968
    220 void Campaign::removeEntity(StoryEntity* se)
     69/**
     70 *  starts the campaing with a specific ID
     71 * @param storyID the id of the StoryEntity
     72 */
     73bool Campaign::start()
    22174{
    222   this->entities.remove(se);
     75  PRINTF(2)("Starting Campaign nr. %i\n", this->getStoryID());
     76
     77  this->isRunning = true;
     78  this->run();
    22379}
    22480
    22581
    226 /*
    227   \brief this changes to the next level
    228 */
    229 void Campaign::nextLevel()
     82/**
     83 *  pauses the campaign
     84 */
     85bool Campaign::pause()
    23086{
    231   PRINTF(4)("Campaign:nextLevel()\n");
     87  this->isPaused = true;
     88}
     89
     90
     91/**
     92 *  resumes the campaign after a pause
     93 */
     94bool Campaign::resume()
     95{
     96  PRINTF(4)("Resuming the current Campaign\n");
     97  this->isPaused = false;
     98}
     99
     100
     101/**
     102 *  stops the campaign
     103 */
     104bool Campaign::stop()
     105{
     106  PRINTF(4)("Stopping the current Campaign\n");
     107  this->isRunning = false;
     108  if( this->currentEntity != NULL)
     109  {
     110    this->currentEntity->stop();
     111  }
     112}
     113
     114
     115/**
     116 *  runs the campaign
     117 */
     118void Campaign::run()
     119{
     120  ErrorMessage       errorCode;
     121  int                storyID = WORLD_ID_0;
     122
     123  for( this->currentEntity = this->campaignData->getFirstLevel(), this->isRunning = true;
     124       this->currentEntity != NULL && this->isRunning;
     125       this->currentEntity = this->campaignData->getNextLevel())
     126  {
     127    PRINTF(0)("Campaign is starting StoryEntity nr:%i\n", this->currentEntity->getStoryID());
     128
     129    this->currentEntity->init();
     130
     131    this->currentEntity->loadData();
     132    this->currentEntity->start();
     133    this->currentEntity->unloadData();
     134  }
     135  PRINTF(2)("There is no StoryEnity left to play, quitting\n");
     136}
     137
     138
     139/**
     140 *  this changes to the next level
     141 */
     142void Campaign::switchToNextLevel()
     143{
     144  PRINTF(4)("Switching to the next StoryEntity\n");
    232145  this->currentEntity->stop();
    233146}
    234147
    235 /*
    236   \brief change to the previous level - not implemented
    237148
    238   this propably useless
    239 */
    240 void Campaign::previousLevel()
    241 {}
    242 
    243 
    244 /*
    245   \brief lookup a entity with a given id
    246 * @param story id to be lookuped
    247   @returns the entity found or NULL if search ended without match
    248 */
    249 StoryEntity* Campaign::getStoryEntity(int storyID)
    250 {
    251   //printf("Campaing::getStoryEntity(%i) - getting next Entity\n", storyID);
    252   if( storyID == WORLD_ID_GAMEEND)
    253     return NULL;
    254 
    255   /*
    256   tList<StoryEntity>* l;
    257   StoryEntity* entity = NULL;
    258   l = this->entities->getNext();
    259   while( l != NULL)
    260     {
    261       entity = l->getObject();
    262       l = l->getNext();
    263 
    264       int id = entity->getStoryID();
    265       //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
    266       if(id == storyID)
    267         {
    268           //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
    269           return entity;
    270         }
    271 
    272     }
    273   */
    274 
    275 
    276   list<StoryEntity*>::iterator it;
    277   for (it = this->entities.begin(); it != this->entities.end(); it++)
    278   {
    279       int id = (*it)->getStoryID();
    280       //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
    281       if(id == storyID)
    282         {
    283           //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
    284           return (*it);
    285         }
    286     }
    287 
    288 
    289 
    290   return NULL;
    291 }
  • trunk/src/story_entities/campaign.h

    r5774 r6424  
     1/*!
     2 * @file campaign.h
     3 * definition of the campaign
     4 */
    15
    26#ifndef _CAMPAIGN_H
    37#define _CAMPAIGN_H
    48
     9
    510#include "story_entity.h"
    611
    7 #include <list>
    812
    9 class World;
    1013class TiXmlElement;
     14class CampaignData;
    1115
    12 class Campaign : public StoryEntity {
    1316
    14  public:
    15   Campaign ();
    16   Campaign ( TiXmlElement* root);
    17   virtual ~Campaign ();
     17//! A class that represents a game Campaign that contains other StoryEntities like GameWorlds, movies, etc.
     18class Campaign : public StoryEntity
     19{
    1820
    19   void loadParams(const TiXmlElement* root);
    20   void loadWorldListParams(const TiXmlElement* root);
     21  public:
     22    Campaign( TiXmlElement* root);
     23    virtual ~Campaign ();
    2124
    22   StoryEntity* currentEntity;
     25    void loadParams(const TiXmlElement* root);
    2326
    24   virtual ErrorMessage init();
    25   virtual ErrorMessage start();
    26   virtual ErrorMessage start(int storyID);
    27   virtual ErrorMessage pause();
    28   virtual ErrorMessage resume();
    29   virtual ErrorMessage stop();
    30   virtual ErrorMessage destroy();
     27    virtual bool start();
     28    virtual bool stop();
     29    virtual bool pause();
     30    virtual bool resume();
     31    virtual void run();
    3132
    32   void addEntity(StoryEntity* se, int storyID);
    33   void addEntity(StoryEntity* se);
    34   void removeEntity(int storyID);
    35   void removeEntity(StoryEntity* se);
     33    void switchToNextLevel();
    3634
    37   void nextLevel();
    38   void previousLevel();
    3935
    40  private:
    41   //ListTemplate<StoryEntity>* entities;
    42    std::list<StoryEntity*> entities;
    43    bool running;
    44 
    45    StoryEntity* getStoryEntity(int storyID);
     36  private:
     37    StoryEntity*                        currentEntity;          //!< reference to the current StoryEntity
     38    CampaignData*                       campaignData;           //!< reference to the CampaignData
    4639};
    4740
  • trunk/src/story_entities/debug_world.cc

    r6222 r6424  
    1 /*
    2    orxonox - the future of 3D-vertical-scrollers
    3 
    4    Copyright (C) 2004 orx
    5 
    6    This program is free software; you can redistribute it and/or modify
    7    it under the terms of the GNU General Public License as published by
    8    the Free Software Foundation; either version 2, or (at your option)
    9    any later version.
    10 
    11    ### File Specific:
    12    main-programmer: Patrick Boenzli
    13    co-programmer: Christian Meyer
    14    co-programmer: Benjamin Grauer
    15 */
    16 
    17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
    18 
    19 #include "world.h"
    20 
    21 #include "shell_command.h"
    22 
    23 #include "state.h"
    24 
    25 #include "p_node.h"
    26 #include "pilot_node.h"
    27 #include "world_entity.h"
    28 #include "player.h"
    29 #include "camera.h"
    30 #include "environment.h"
    31 #include "skysphere.h"
    32 #include "skybox.h"
    33 #include "satellite.h"
    34 #include "test_entity.h"
    35 #include "terrain.h"
    36 #include "light.h"
    37 #include "load_param.h"
    38 #include "shell.h"
    39 
    40 #include "fast_factory.h"
    41 #include "animation_player.h"
    42 #include "particle_engine.h"
    43 #include "graphics_engine.h"
    44 #include "physics_engine.h"
    45 #include "fields.h"
    46 
    47 #include "md2Model.h"
    48 
    49 #include "glmenu_imagescreen.h"
    50 #include "game_loader.h"
    51 
    52 #include "animation3d.h"
    53 
    54 #include "substring.h"
    55 
    56 #include "factory.h"
    57 
    58 #include "weapons/projectile.h"
    59 #include "event_handler.h"
    60 #include "sound_engine.h"
    61 #include "ogg_player.h"
    62 
    63 #include "class_list.h"
    64 
    65 #include "cd_engine.h"
    66 #include "npcs/npc_test1.h"
    67 #include "shader.h"
    68 
    69 #include "playable.h"
    70 #include "network_manager.h"
    71 #include "playable.h"
    72 
    73 
    74 SHELL_COMMAND(speed, World, setSpeed);
    75 SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);
    76 SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);
    77 
    78 using namespace std;
    79 
    80 //! This creates a Factory to fabricate a World
    81 CREATE_FACTORY(World, CL_WORLD);
    82 
    83 World::World(const TiXmlElement* root)
    84 {
    85   this->constuctorInit("", -1);
    86   this->path = NULL;
    87 
    88   this->loadParams(root);
    89 }
    90 
    91 /**
    92   *  create a new World
    93 
    94     This creates a new empty world!
    95 */
    96 World::World (const char* name)
    97 {
    98   this->path = NULL;
    99   this->constuctorInit(name, -1);
    100 }
    101 
    102 /**
    103  *  creates a new World...
    104  * @param worldID with this ID
    105 */
    106 World::World (int worldID)
    107 {
    108   this->path = NULL;
    109   this->constuctorInit(NULL, worldID);
    110 }
    111 
    112 /**
    113  *  remove the World from memory
    114 
    115     delete everything explicitly, that isn't contained in the parenting tree!
    116     things contained in the tree are deleted automaticaly
    117  */
    118 World::~World ()
    119 {
    120   delete this->shell;
    121   PRINTF(3)("World::~World() - deleting current world\n");
    122 
    123   delete this->localPlayer;
    124 
    125   // delete all the initialized Engines.
    126   FastFactory::flushAll(true);
    127   delete LightManager::getInstance();
    128   delete ParticleEngine::getInstance();
    129   delete AnimationPlayer::getInstance();
    130   delete PhysicsEngine::getInstance();
    131 
    132   // external engines initialized by the orxonox-class get deleted
    133   SoundEngine::getInstance()->flushAllBuffers();
    134   SoundEngine::getInstance()->flushAllSources();
    135 
    136   if (State::getObjectManager() == &this->objectManager)
    137     State::setObjectManager(NULL);
    138   // erease everything that is left.
    139   delete PNode::getNullParent();
    140 
    141   //secondary cleanup of PNodes;
    142   const std::list<BaseObject*>* nodeList = ClassList::getList(CL_PARENT_NODE);
    143   if (nodeList != NULL)
    144     while (!nodeList->empty())
    145       delete nodeList->front();
    146 
    147   Shader::suspendShader();
    148 
    149   // unload the resources !!
    150   ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
    151 
    152   delete[] this->path;
    153 }
    154 
    155 /**
    156  * initializes the world.
    157  * @param name the name of the world
    158  * @param worldID the ID of this world
    159  *
    160  * set all stuff here that is world generic and does not use to much memory
    161  * because the real init() function StoryEntity::init() will be called
    162  * shortly before start of the game.
    163  * since all worlds are initiated/referenced before they will be started.
    164  * NO LEVEL LOADING HERE - NEVER!
    165 */
    166 void World::constuctorInit(const char* name, int worldID)
    167 {
    168   this->setClassID(CL_WORLD, "World");
    169 
    170   this->setName(name);
    171   this->debugWorldNr = worldID;
    172   this->gameTime = 0.0f;
    173   this->setSpeed(1.0);
    174   this->music = NULL;
    175   this->shell = NULL;
    176   this->localPlayer = NULL;
    177   this->localCamera = NULL;
    178 
    179   this->showPNodes = false;
    180   this->showBV = false;
    181 }
    182 
    183 /**
    184  * loads the parameters of a World from an XML-element
    185  * @param root the XML-element to load from
    186  */
    187 void World::loadParams(const TiXmlElement* root)
    188 {
    189   PRINTF(4)("Creating a World\n");
    190 
    191   LoadParam(root, "identifier", this, World, setStoryID)
    192     .describe("Sets the StoryID of this world");
    193 
    194   LoadParam(root, "nextid", this, World, setNextStoryID)
    195     .describe("Sets the ID of the next world");
    196 
    197   LoadParam(root, "path", this, World, setPath)
    198     .describe("The Filename of this World (relative from the data-dir)");
    199 }
    200 
    201 /**
    202  * this is executed just before load
    203  *
    204  * since the load function sometimes needs data, that has been initialized
    205  * before the load and after the proceeding storyentity has finished
    206 */
    207 ErrorMessage World::preLoad()
    208 {
    209   State::setObjectManager(&this->objectManager);
    210   this->cycle = 0;
    211 
    212   /* init the world interface */
    213   this->shell = new Shell();
    214 
    215   LightManager::getInstance();
    216   PNode::getNullParent();
    217 
    218   AnimationPlayer::getInstance(); // initializes the animationPlayer
    219   ParticleEngine::getInstance();
    220   PhysicsEngine::getInstance();
    221 
    222   this->localCamera = new Camera();
    223   this->localCamera->setName ("World-Camera");
    224 
    225   State::setCamera(this->localCamera, this->localCamera->getTarget());
    226 
    227   GraphicsEngine::getInstance()->displayFPS(true);
    228 }
    229 
    230 
    231 /**
    232  *  loads the World by initializing all resources, and set their default values.
    233 */
    234 ErrorMessage World::load()
    235 {
    236   PRINTF(3)("> Loading world: '%s'\n", getPath());
    237   TiXmlElement* element;
    238   GameLoader* loader = GameLoader::getInstance();
    239 
    240   if( getPath() == NULL)
    241     {
    242       PRINTF(1)("World has no path specified for loading");
    243       this->loadDebugWorld(this->getStoryID());
    244       return (ErrorMessage){213,"Path not specified","World::load()"};
    245     }
    246 
    247   TiXmlDocument* XMLDoc = new TiXmlDocument( getPath());
    248   // load the campaign document
    249   if( !XMLDoc->LoadFile())
    250   {
    251     // report an error
    252     PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    253     delete XMLDoc;
    254     return (ErrorMessage){213,"XML File parsing error","World::load()"};
    255   }
    256 
    257   // check basic validity
    258   TiXmlElement* root = XMLDoc->RootElement();
    259   assert( root != NULL);
    260 
    261   if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
    262     {
    263       // report an error
    264       PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
    265       delete XMLDoc;
    266       return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
    267     }
    268 
    269   // load the parameters
    270   // name
    271   const char* string = grabParameter( root, "name");
    272   if( string == NULL)
    273     {
    274       PRINTF(2)("World is missing a proper 'name'\n");
    275       this->setName("Unknown");
    276     }
    277   else
    278     {
    279       this->setName(string);
    280     }
    281 
    282   ////////////////
    283   // LOADSCREEN //
    284   ////////////////
    285   element = root->FirstChildElement("LoadScreen");
    286   if (element == NULL)
    287     {
    288       PRINTF(2)("no LoadScreen specified, loading default\n");
    289 
    290       glmis->setBackgroundImage("pictures/load_screen.jpg");
    291       this->glmis->setMaximum(8);
    292       this->glmis->draw();
    293     }
    294   else
    295     {
    296       this->glmis->loadParams(element);
    297       this->glmis->draw();
    298     }
    299   this->glmis->draw();
    300 
    301   ////////////////////////
    302   // find WorldEntities //
    303   ////////////////////////
    304 
    305   element = root->FirstChildElement("WorldEntities");
    306 
    307   if( element == NULL)
    308     {
    309       PRINTF(1)("World is missing 'WorldEntities'\n");
    310     }
    311   else
    312     {
    313       element = element->FirstChildElement();
    314       // load Players/Objects/Whatever
    315       PRINTF(4)("Loading WorldEntities\n");
    316       while( element != NULL)
    317         {
    318           BaseObject* created = Factory::fabricate(element);
    319           if( created != NULL )
    320           {
    321             if(created->isA(CL_WORLD_ENTITY))
    322               this->spawn(dynamic_cast<WorldEntity*>(created));
    323             printf("Created a %s: %s\n", created->getClassName(), created->getName());
    324           }
    325 
    326           // if we load a 'Player' we use it as localPlayer
    327 
    328 
    329           //todo do this more elegant
    330           if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
    331             sky = dynamic_cast<SkyBox*>(created);
    332           if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    333           {
    334             terrain = dynamic_cast<Terrain*>(created);
    335             CDEngine::getInstance()->setTerrain(terrain);
    336           }
    337           element = element->NextSiblingElement();
    338           glmis->step(); //! @todo temporary
    339         }
    340       PRINTF(4)("Done loading WorldEntities\n");
    341     }
    342 
    343     //////////////////////////////
    344     // LOADING ADDITIONAL STUFF //
    345     //////////////////////////////
    346 
    347     LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);
    348 
    349    LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);
    350 //   LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
    351 
    352   // free the XML data
    353 
    354   delete XMLDoc;
    355   /* GENERIC LOADING PROCESS FINISHED */
    356 
    357 
    358   // Create a Player
    359   this->localPlayer = new Player();
    360 
    361   Playable* playable;
    362   const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
    363   if (playableList != NULL)
    364   {
    365     playable = dynamic_cast<Playable*>(playableList->front());
    366     this->localPlayer->setControllable(playable);
    367   }
    368 
    369   // bind camera
    370   playable->addChild (this->localCamera);
    371 
    372 //   //localCamera->setParent(TrackNode::getInstance());
    373 //  tn->addChild(this->localCamera);
    374   localCamera->setClipRegion(1, 10000.0);
    375   localCamera->lookAt(playable);
    376 //  this->localPlayer->setParentMode(PNODE_ALL);
    377   if (sky != NULL)
    378   {
    379     this->sky->setParent(this->localCamera);
    380     this->sky->setParentMode(PNODE_MOVEMENT);
    381   }
    382 
    383   // initialize debug coord system
    384   objectList = glGenLists(1);
    385   glNewList (objectList, GL_COMPILE);
    386 
    387   glEndList();
    388 
    389   SoundEngine::getInstance()->setListener(this->localCamera);
    390 
    391 
    392 
    393   ////////////
    394   // STATIC //
    395   ////////////
    396 
    397 
    398 //   TestEntity* testEntity = new TestEntity();
    399 //   testEntity->setRelCoor(Vector(570, 10, -15));
    400 //   testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    401 //   this->spawn(testEntity);
    402 
    403   for(int i = 0; i < 100; i++)
    404   {
    405     WorldEntity* tmp = new NPCTest1();
    406     char npcChar[10];
    407     sprintf (npcChar, "NPC_%d", i);
    408         tmp->setName(npcChar);
    409     tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
    410     this->spawn(tmp);
    411   }
    412 
    413   this->music = NULL;
    414   //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);
    415   //music->playback();
    416 }
    417 
    418 
    419 
    420 /**
    421  * creates a debug world: only for experimental stuff
    422 */
    423 void World::loadDebugWorld(int worldID)
    424 {
    425   /*monitor progress*/
    426   this->glmis->step();
    427   // stuff beyond this point remains to be loaded properly
    428 
    429   // LIGHT initialisation
    430   LightManager::getInstance()->setAmbientColor(.1,.1,.1);
    431 //  LightManager::getInstance()->addLight();
    432   LightManager::getInstance()->debug();
    433 
    434   switch(this->debugWorldNr)
    435     {
    436       /*
    437         this loads the hard-coded debug world. this only for simplicity and will be
    438         removed by a reald world-loader, which interprets a world-file.
    439         if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
    440         make whatever you want...
    441       */
    442     case DEBUG_WORLD_0:
    443       {
    444         LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0);
    445         /*monitor progress*/
    446         this->glmis->step();
    447 
    448         // bind camera
    449         this->localCamera = new Camera();
    450         this->localCamera->setName ("camera");
    451         /*monitor progress*/
    452         this->glmis->step();
    453 
    454 
    455         // Create SkySphere
    456         this->sky = new Skysphere("pictures/sky-replace.jpg");
    457         this->sky->setName("SkySphere");
    458         this->spawn(this->sky);
    459         this->localCamera->addChild(this->sky);
    460         this->sky->setParentMode(PNODE_MOVEMENT);
    461         /*monitor progress*/
    462         this->glmis->step();
    463 
    464 
    465         terrain = new Terrain("worlds/newGround.obj");
    466         terrain->setRelCoor(Vector(0,-10,0));
    467         this->spawn(terrain);
    468         /*monitor progress*/
    469         this->glmis->step();
    470 
    471         this->glmis->step();
    472         break;
    473       }
    474     case DEBUG_WORLD_1:
    475       {
    476 
    477         break;
    478       }
    479     case DEBUG_WORLD_2:
    480       {
    481 
    482         break;
    483       }
    484     default:
    485       break;
    486     }
    487 }
    488 
    489 /**
    490  *  initializes a new World shortly before start
    491  *
    492  * this is the function, that will be loaded shortly before the world is
    493  * started
    494 */
    495 ErrorMessage World::init()
    496 {
    497   this->bPause = false;
    498 
    499   /* update the object position before game start - so there are no wrong coordinates used in the first processing */
    500   PNode::getNullParent()->updateNode (0.001f);
    501   PNode::getNullParent()->updateNode (0.001f);
    502 
    503 }
    504 
    505 
    506 /**
    507  *  starts the World
    508 */
    509 ErrorMessage World::start()
    510 {
    511   PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
    512   this->bQuitOrxonox = false;
    513   this->bQuitCurrentGame = false;
    514   this->mainLoop();
    515 }
    516 
    517 /**
    518  *  stops the world.
    519 
    520    This happens, when the player decides to end the Level.
    521 */
    522 ErrorMessage World::stop()
    523 {
    524   PRINTF(3)("World::stop() - got stop signal\n");
    525   this->bQuitCurrentGame = true;
    526 }
    527 
    528 /**
    529  *  pauses the Game
    530 */
    531 ErrorMessage World::pause()
    532 {
    533   this->isPaused = true;
    534 }
    535 
    536 /**
    537  *  ends the pause Phase
    538 */
    539 ErrorMessage World::resume()
    540 {
    541   this->isPaused = false;
    542 }
    543 
    544 /**
    545  *  destroys the World
    546 */
    547 ErrorMessage World::destroy()
    548 {
    549 
    550 }
    551 
    552 /**
    553  *  shows the loading screen
    554 */
    555 void World::displayLoadScreen ()
    556 {
    557   PRINTF(3)("World::displayLoadScreen - start\n");
    558 
    559   //GLMenuImageScreen*
    560   this->glmis = new GLMenuImageScreen();
    561   this->glmis->setMaximum(8);
    562 
    563   PRINTF(3)("World::displayLoadScreen - end\n");
    564 }
    565 
    566 /**
    567  *  removes the loadscreen, and changes over to the game
    568 
    569    @todo take out the delay
    570 */
    571 void World::releaseLoadScreen ()
    572 {
    573   PRINTF(3)("World::releaseLoadScreen - start\n");
    574   this->glmis->setValue(this->glmis->getMaximum());
    575   PRINTF(3)("World::releaseLoadScreen - end\n");
    576   delete this->glmis;
    577 }
    578 
    579 
    580 /**
    581  *  this returns the current game time
    582  * @returns elapsed game time
    583 */
    584 double World::getGameTime()
    585 {
    586   return this->gameTime;
    587 }
    588 
    589 /**
    590   \brief main loop of the world: executing all world relevant function
    591 
    592   in this loop we synchronize (if networked), handle input events, give the heart-beat to
    593   all other member-entities of the world (tick to player, enemies etc.), checking for
    594   collisions drawing everything to the screen.
    595 */
    596 void World::mainLoop()
    597 {
    598   this->lastFrame = SDL_GetTicks ();
    599   PRINTF(3)("World::mainLoop() - Entering main loop\n");
    600 
    601   while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */
    602     {
    603       ++this->cycle;
    604       // Network
    605       this->synchronize ();
    606       // Process input
    607       this->handleInput ();
    608       if( this->bQuitCurrentGame || this->bQuitOrxonox)
    609           break;
    610       // Process time
    611       this->tick ();
    612       // Process collision
    613       this->collide ();
    614       // Update the state
    615       this->update ();
    616       // Draw
    617       this->display ();
    618     }
    619 
    620   PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
    621 }
    622 
    623 
    624 /**
    625  *  synchronize local data with remote data
    626 */
    627 void World::synchronize ()
    628 {
    629   // Get remote input
    630   // Update synchronizables
    631 /*  NetworkManager::getInstance()->synchronize();*/
    632 }
    633 
    634 
    635 /**
    636  *  run all input processing
    637 
    638    the command node is the central input event dispatcher. the node uses the even-queue from
    639    sdl and has its own event-passing-queue.
    640 */
    641 void World::handleInput ()
    642 {
    643   EventHandler::getInstance()->process();
    644 
    645   // remoteinput
    646 }
    647 
    648 void World::tick(std::list<WorldEntity*> entityList, float dt)
    649 {
    650   std::list<WorldEntity*>::iterator entity;
    651   for (entity = entityList.begin(); entity != entityList.end(); entity++)
    652     (*entity)->tick(dt);
    653 
    654 }
    655 
    656 /**
    657  *  advance the timeline
    658 
    659    this calculates the time used to process one frame (with all input handling, drawing, etc)
    660    the time is mesured in ms and passed to all world-entities and other classes that need
    661    a heart-beat.
    662 */
    663 void World::tick ()
    664 {
    665   Uint32 currentFrame = SDL_GetTicks();
    666   if(!this->bPause)
    667     {
    668       this->dt = currentFrame - this->lastFrame;
    669 
    670       if( this->dt > 10)
    671         {
    672           float fps = 1000/dt;
    673 
    674           // temporary, only for showing how fast the text-engine is
    675           char tmpChar[20];
    676           sprintf(tmpChar, "fps: %4.0f", fps);
    677         }
    678       else
    679         {
    680           /* the frame-rate is limited to 100 frames per second, all other things are for
    681              nothing.
    682           */
    683           PRINTF(3)("fps = 1000 - frame rate is adjusted\n");
    684           SDL_Delay(10-dt);
    685           this->dt = 10;
    686         }
    687 
    688       this->dtS = (float)this->dt / 1000.0 * this->speed;
    689       this->gameTime += this->dtS;
    690 
    691 /*      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
    692       this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
    693       this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/
    694       this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
    695       this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
    696 
    697       /* update tick the rest */
    698       this->localCamera->tick(this->dtS);
    699       // tick the engines
    700       AnimationPlayer::getInstance()->tick(this->dtS);
    701 //      if (this->cycle > 5)
    702         PhysicsEngine::getInstance()->tick(this->dtS);
    703 
    704       ParticleEngine::getInstance()->tick(this->dtS);
    705 
    706 
    707       /** actualy the Graphics Engine should tick the world not the other way around...
    708          but since we like the things not too complicated we got it this way around
    709          until there is need or time to do it the other way around.
    710          @todo: GraphicsEngine ticks world: separation of processes and data...
    711 
    712         bensch: in my opinion the GraphicsEngine could draw the world, but not tick it,
    713          beceause graphics have nothing(or at least not much) to do with Motion.
    714       */
    715       GraphicsEngine::getInstance()->tick(this->dtS);
    716     }
    717   this->lastFrame = currentFrame;
    718 }
    719 
    720 
    721 /**
    722  *  this function gives the world a consistant state
    723 
    724    after ticking (updating the world state) this will give a constistant
    725    state to the whole system.
    726 */
    727 void World::update()
    728 {
    729   GraphicsEngine::getInstance()->update(this->dtS);
    730   PNode::getNullParent()->updateNode (this->dtS);
    731 
    732   SoundEngine::getInstance()->update();
    733   //music->update();
    734 }
    735 
    736 
    737 void World::collide()
    738 {
    739   CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
    740                                             this->objectManager.getObjectList(OM_GROUP_01_PROJ));
    741   CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),
    742                                             this->objectManager.getObjectList(OM_COMMON));
    743 }
    744 
    745 /**
    746  *  render the current frame
    747 
    748    clear all buffers and draw the world
    749 */
    750 void World::display ()
    751 {
    752   // clear buffer
    753   glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    754   // set camera
    755   this->localCamera->apply ();
    756   // draw world
    757   this->draw();
    758   // draw HUD
    759   /** @todo draw HUD */
    760   // flip buffers
    761   GraphicsEngine::swapBuffers();
    762   //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
    763   //SDL_Flip (screen);
    764 }
    765 
    766 
    767 /**
    768  *  runs through all entities calling their draw() methods
    769  */
    770 void World::draw ()
    771 {
    772   GraphicsEngine* engine = GraphicsEngine::getInstance();
    773   engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
    774   engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));
    775   engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));
    776   engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));
    777   engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));
    778   engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
    779 
    780 //   {
    781 //     if( entity->isVisible() ) entity->draw();
    782   //FIXME
    783 //     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
    784 //     entity = iterator->nextElement();
    785 //   }
    786 
    787   glCallList (objectList);
    788 
    789   ParticleEngine::getInstance()->draw();
    790 
    791   if (unlikely(this->showPNodes))
    792     PNode::getNullParent()->debugDraw(0);
    793 
    794   engine->draw();
    795   //TextEngine::getInstance()->draw();
    796 }
    797 
    798 /**
    799  *  add and spawn a new entity to this world
    800  * @param entity to be added
    801 */
    802 void World::spawn(WorldEntity* entity)
    803 {
    804 //   this->entities->add (entity);
    805   entity->postSpawn ();
    806 }
    807 
    808 
    809 /**
    810  *  add and spawn a new entity to this world
    811  * @param entity to be added
    812  * @param absCoor At what coordinates to add this entity.
    813  * @param absDir In which direction should it look.
    814 */
    815 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    816 {
    817 //   this->entities->add (entity);
    818 
    819   entity->setAbsCoor (*absCoor);
    820   entity->setAbsDir (*absDir);
    821 
    822   entity->postSpawn ();
    823 }
    824 
    825 
    826 /**
    827  *  add and spawn a new entity to this world
    828  * @param entity to be added
    829  * @param entity to be added to (PNode)
    830  * @param At what relative  coordinates to add this entity.
    831  * @param In which relative direction should it look.
    832 */
    833 void World::spawn(WorldEntity* entity, PNode* parentNode,
    834                   Vector* relCoor, Quaternion* relDir)
    835 {
    836   if( parentNode != NULL)
    837     {
    838       parentNode->addChild (entity);
    839 
    840       entity->setRelCoor (*relCoor);
    841       entity->setRelDir (*relDir);
    842 
    843 //       this->entities->add (entity);
    844 
    845       entity->postSpawn ();
    846     }
    847 }
    848 
    849 void World::setPath( const char* name)
    850 {
    851   if (this->path)
    852     delete this->path;
    853   if (ResourceManager::isFile(name))
    854   {
    855     this->path = new char[strlen(name)+1];
    856     strcpy(this->path, name);
    857   }
    858   else
    859     {
    860       this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];
    861       sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
    862     }
    863 }
    864 
    865 const char* World::getPath( void)
    866 {
    867   return path;
    868 }
  • trunk/src/story_entities/debug_world.h

    r6150 r6424  
    1 /*!
    2  * @file world.h
    3   *  Holds and manages all game data
    4 */
    5 
    6 #ifndef _WORLD_H
    7 #define _WORLD_H
    8 
    9 #include "stdincl.h"
    10 #include "comincl.h"
    11 #include "story_entity.h"
    12 #include "p_node.h"
    13 #include "object_manager.h"
    14 
    15 
    16 class WorldEntity;
    17 class Camera;
    18 class Player;
    19 class GLMenuImageScreen;
    20 class Terrain;
    21 class TiXmlElement;
    22 
    23 class Shell;
    24 class OggPlayer;
    25 
    26 //! The game world
    27 /**
    28    this class initializes everything that should be displayed inside of the current level.
    29    it is the main driving factor during gameplay.
    30 */
    31 class World : public StoryEntity {
    32 
    33  public:
    34   World (const char* name);
    35   World (int worldID);
    36   World (const TiXmlElement* root = NULL);
    37   virtual ~World ();
    38 
    39   void loadParams(const TiXmlElement* root);
    40 
    41   double getGameTime();
    42 
    43   /* classes from story-entity */
    44   virtual ErrorMessage preLoad();
    45   virtual ErrorMessage load ();
    46   virtual ErrorMessage init ();
    47   virtual ErrorMessage start ();
    48   virtual ErrorMessage stop ();
    49   virtual ErrorMessage pause ();
    50   virtual ErrorMessage resume ();
    51   virtual ErrorMessage destroy ();
    52 
    53   void loadDebugWorld(int worldID);
    54 
    55   virtual void displayLoadScreen();
    56   virtual void releaseLoadScreen();
    57 
    58   /* command node functions */
    59   bool command (Command* cmd);
    60 
    61   /* interface to world */
    62   void spawn (WorldEntity* entity);
    63   void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir);
    64   void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir);
    65 
    66   /** @param speed sets the speed of the Game */
    67   inline void setSpeed(float speed) { this->speed = speed; };
    68   const char* getPath();
    69   void setPath( const char* name);
    70 
    71   inline Camera* getLocalCamera() { return this->localCamera; };
    72 
    73   void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; };
    74   void toggleBVVisibility() { this->showBV = !this->showBV; };
    75 
    76  private:
    77   void constuctorInit(const char* name, int worldID);
    78   /* function for main-loop */
    79   void mainLoop ();
    80   void synchronize ();
    81   void handleInput ();
    82   void tick (std::list<WorldEntity*> worldEntity, float dt);
    83   void tick ();
    84   void update ();
    85   void collide ();
    86   void draw ();
    87   void display ();
    88   void debug ();
    89 
    90   private:
    91     bool   showPNodes;                  //!< if the PNodes should be visible.
    92     bool   showBV;                      //!< if the Bounding Volumes should be visible.
    93     Uint32 lastFrame;                   //!< last time of frame
    94     Uint32 cycle;                       //!< The cycle we are in (starts with 0 and rises with every frame)
    95     Uint32 dt;                          //!< time needed to calculate this frame (in milliSeconds)
    96     float dtS;                          //!< The time needed for caluculations in seconds
    97     float speed;                        //!< how fast the game flows
    98     double gameTime;                    //!< this is where the game time is saved
    99     bool bQuitOrxonox;                  //!< quit this application
    100     bool bQuitCurrentGame;              //!< quit only the current game and return to menu
    101     bool bPause;                        //!< pause mode
    102 
    103     ObjectManager      objectManager;   //!< The ObjectManager of this World.
    104 
    105     GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    106 
    107     int debugWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
    108     char* path;                         //!< The file from which this world is loaded
    109 
    110     Shell*     shell;
    111     OggPlayer* music;
    112 
    113   // IMPORTANT WORLD-ENTITIES
    114     Camera* localCamera;                //!< The current Camera
    115     WorldEntity* sky;                   //!< The Environmental Heaven of orxonox @todo insert this to environment insted
    116     Terrain* terrain;                   //!< The Terrain of the World.
    117 
    118     GLuint objectList;                  //!< temporary: @todo this will be ereased soon
    119 
    120     Player* localPlayer;                //!< The Player, you fly through the level.
    121 };
    122 
    123 #endif /* _WORLD_H */
  • trunk/src/story_entities/story_entity.cc

    r6153 r6424  
    1717
    1818
     19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
     20
     21
    1922#include "story_entity.h"
     23
     24#include "load_param.h"
    2025
    2126
     
    2328
    2429
    25 
     30/**
     31 *  default constructor initializes all needed data
     32 */
    2633StoryEntity::StoryEntity ()
    2734{
    2835  this->setClassID(CL_STORY_ENTITY, "StoryEntity");
     36
    2937  this->isInit = false;
    30   this->readyToRun = false;
    3138  this->isPaused = false;
    32   this->isSuspended = false;
    33 }
     39  this->isRunning = false;
    3440
    35 StoryEntity::~StoryEntity () {}
    36 
    37 
    38 /**
    39   *  sets the story ID
    40 
    41     sets the story id of the current entity, this enables it to be identified in a
    42     global context.
    43 */
    44 void StoryEntity::setStoryID(int storyID)
    45 {
    46   this->storyID = storyID;
     41  this->storyID = -1;
     42  this->nextStoryID = WORLD_ID_GAMEEND;
    4743}
    4844
    4945
    5046/**
    51   *  this reads the story id of the current entity
    52   * @returns the story entity id
    53 */
    54 int StoryEntity::getStoryID()
    55 {
    56   return this->storyID;
    57 }
     47 *  deconstructor
     48 */
     49StoryEntity::~StoryEntity ()
     50{}
    5851
    5952
    6053/**
    61   *  sets the id of the next story entity
     54 *  loads the Parameters of a Campaign
     55 * @param root: The XML-element to load from
     56 */
     57void StoryEntity::loadParams(const TiXmlElement* root)
     58{
     59  static_cast<BaseObject*>(this)->loadParams(root);
    6260
    63     StoryEntities can choose their following entity themselfs. the entity id defined here
    64     will be startet after this entity ends. this can be convenient if you want to have a
    65     non linear story with switches.
    66 */
    67 void StoryEntity::setNextStoryID(int nextStoryID)
    68 {
    69   this->nextStoryID = nextStoryID;
     61  LoadParam(root, "identifier", this, StoryEntity, setStoryID)
     62      .describe("A Unique Identifier for this StoryEntity");
     63
     64  LoadParam(root, "nextid", this, StoryEntity, setNextStoryID)
     65      .describe("Sets the ID of the next StoryEntity");
     66
     67  PRINTF(4)("Loaded StoryEntity specific stuff\n");
    7068}
    71 
    72 /**
    73   *  gets the story id of the current entity
    74   * @returns story id
    75 */
    76 int StoryEntity::getNextStoryID()
    77 {
    78   return this->nextStoryID;
    79 }
  • trunk/src/story_entities/story_entity.h

    r6153 r6424  
    11/*!
    22 * @file story_entity.h
    3   *  holds the base class of everything that is playable - that is part of the story
    4 */
     3 *  holds the base class of everything that is playable - that is part of the story
     4 */
    55
    66
     
    1212#include "error.h"
    1313
     14
     15typedef enum StoryEntityState
     16{
     17  SE_STATE_RUN     = 0,
     18  SE_STATE_STOP,
     19  SE_STATE_PAUSE,
     20
     21  SE_STATE_NUM
     22};
     23
     24
    1425//! A class that represents something to play in orxonox. it is a container for worlds, movies, mission briefings, etc...
    1526class StoryEntity : public BaseObject {
     
    1930  virtual ~StoryEntity ();
    2031
    21   // INIT AND LOAD //
    22   /** @brief initializes a Story Entity to default Values */
     32  void loadParams(const TiXmlElement* root);
     33
     34  /* initialisation and loading */
     35  /** initializes a Story Entity to the needed values */
    2336  virtual ErrorMessage init() {};
    24   /** @brief called before loading */
    25   virtual ErrorMessage preLoad() {};
    26   /** @brief called to load. */
    27   virtual ErrorMessage load() {};
    28   /** @brief called right after loading */
    29   virtual ErrorMessage postLoad() {};
    30   /** @brief called after postload to check for integrity. (optional) */
    31   virtual ErrorMessage check() {};
     37  /** called to load the data into the StoryEntity*/
     38  virtual ErrorMessage loadData() {};
     39  /** function that unloads the data from the StoryEntity */
     40  virtual ErrorMessage unloadData() {};
    3241
    33   // RUNNING //
    34   /** @brief called shortly before starting the Entity */
    35   virtual ErrorMessage preStart() {};
    36   /** @brief starts the Entity. Starts the main cycle */
    37   virtual ErrorMessage start() = 0;
    38   /** @brief pauses the Entity. call to resume required to get it running again */
    39   virtual ErrorMessage pause() = 0;
    40   /** @brief resumes the Entity after a stop/pause or suspend. */
    41   virtual ErrorMessage resume() = 0;
    42   /** @brief suspends the Entity detaches all mayor functions  (optional) */
    43   virtual ErrorMessage suspend() {};
    44   /** @brief rewinds to the beginning/last checkpoint */
    45   virtual ErrorMessage rewind() {};
    46   /** @brief leaves the Entity. Ends it */
    47   virtual ErrorMessage preStop() {};
    48   /** @brief Stops the entity. */
    49   virtual ErrorMessage stop() = 0;
     42  /* running, stopping and pausing */
     43  /** starts the Entity. Starts the main cycle */
     44  virtual bool start() = 0;
     45  /**  Stops the entity. */
     46  virtual bool stop() = 0;
     47  /** pauses the Entity, you can resume the game by calling the resume() function */
     48  virtual bool pause() = 0;
     49  /** resumes a paused StoryEntity */
     50  virtual bool resume() = 0;
     51  /** function that is been called when the StoryEntity is started via start() */
     52  virtual void run() = 0;
    5053
    51   // KILLING
    52   /** @brief kills the Entity. should also calls prestop stop */
    53   virtual ErrorMessage destroy() {};
     54  /* properties interface */
     55  /** returns the state of this StoryEntity */
     56  StoryEntityState getState();
    5457
    55   void setStoryID(int storyID);
    56   int getStoryID();
     58  /** sets the story id of the current entity, this enables it to be identified in a global context.  @param storyID the story id */
     59  inline void setStoryID(int storyID) { this->storyID = storyID; }
     60  /** sets the story id of the current entity, this enables it to be identified in a  global context. @returns  the story id  */
     61  inline int getStoryID() { return this->storyID; }
     62  /**  sets the id of the next story entity: StoryEntities can choose their following entity themselfs.
     63   * the entity id defined here  will be startet after this entity ends. this can be convenient if you
     64   * want to have a non linear story with switches.
     65   * @param nextStoryID the story id of the next StoryEntity   */
     66  inline void setNextStoryID(int nextStoryID) { this->nextStoryID = nextStoryID; }
     67  /**  gets the story id of the current entity @returns story id */
     68  inline int getNextStoryID() { return this->nextStoryID; }
    5769
    58   void setNextStoryID(int nextStoryID);
    59   int getNextStoryID();
     70
    6071
    6172  protected:
    6273    bool isInit;         //!< if the entity is initialized, this has to be true.
    63     bool readyToRun;     //!< If the entity is ready to run -> post-check.
     74    bool isRunning;      //!< is true if the entity is running
    6475    bool isPaused;       //!< is true if the entity is paused
    65     bool isSuspended;    //!< if the Entity is suspended.
     76
    6677
    6778 private:
  • trunk/src/subprojects/network/network_unit_test.cc

    r6341 r6424  
    136136
    137137  /* create a server stream */
    138   nm->createServer(*serverSync, port);
     138  nm->createServer(port);
    139139
    140140  /* esatblish a connection */
     
    289289  printf("%f = ", f);
    290290  printf(s); printf("\n");
    291  
     291
    292292  byte* res = Converter::floatToByteArray(f);
    293293  printf("Byte Array: ");
     
    295295    printf("%i  ", res[i]);
    296296  printf("\n");
    297  
     297
    298298  float b = Converter::byteArrayToFloat(res);
    299299  printf("ReConvert: %f \n", b);
     
    305305  printf("### %f = ", f);
    306306  printf(s); printf("\n");
    307  
     307
    308308  byte* res = Converter::_floatToByteArray(f);
    309309  printf("Byte Array: ");
     
    311311    printf("%i  ", res[i]);
    312312  printf("\n");
    313  
     313
    314314  float b = Converter::_byteArrayToFloat(res);
    315315  printf("ReConvert: %f \n", b);
     
    324324    printf("%i  ", res[i]);
    325325  printf("\n");
    326  
     326
    327327  int z = Converter::byteArrayToInt(res);
    328  
     328
    329329  printf("ReConvert: %i\n", z);
    330330
    331  
     331
    332332  //float a = 5.4f;
    333333  //float b = 2.0f;
    334334  //printf("%f mod %f = %f", a, b, a % b);
    335  
    336   printf("\n");
    337  
     335
     336  printf("\n");
     337
    338338  */
    339339  /*
    340340  float y;
    341341  char* s;
    342  
     342
    343343  y = 12.0f;
    344344  s = Converter::floatToBinString(y);
    345345  printf("%f = ", y);
    346346  printf(s); printf("\n");
    347  
     347
    348348  y = 24549026.0f;
    349349  s = Converter::floatToBinString(y);
    350350  printf("%f = ", y);
    351351  printf(s); printf("\n");
    352  
     352
    353353  y = 12.4e20f;
    354354  s = Converter::floatToBinString(y);
    355355  printf("%f = ", y);
    356356  printf(s); printf("\n");
    357  
     357
    358358  y = 4.7824f;
    359359  s = Converter::floatToBinString(y);
    360360  printf("%f = ", y);
    361361  printf(s); printf("\n");
    362  
     362
    363363  y = -4.7824f;
    364364  s = Converter::floatToBinString(y);
    365365  printf("%f = ", y);
    366366  printf(s); printf("\n");
    367  
     367
    368368  y = -14.35e14f;
    369369  s = Converter::floatToBinString(y);
     
    371371  printf(s); printf("\n");
    372372                                                            */
    373  
    374  
     373
     374
    375375  /*
    376376  float a = 12.3f;
    377  
     377
    378378  char* s = Converter::floatToBinString(a);
    379379  printf("%f = ", a);
    380380  printf(s); printf("\n");
    381  
     381
    382382  byte* res = Converter::floatToByteArray(a);
    383383  printf("Byte Array: \n");
     
    385385    printf("%i  ", res[i]);
    386386  printf("\n");
    387  
     387
    388388  float b = Converter::byteArrayToFloat(res);
    389389  printf("ReConvert: %f \n", b);
     
    392392//  testFloatConverter(134.26455646546548741661675165f); printf("\n");
    393393 // testFloatConverter(35.67e14f); printf("\n");
    394  
     394
    395395  testFloatConverter(12.3e-7f); printf("\n");
    396396  testFloatConverter(134.26455646546548741661675165f); printf("\n");
    397397  testFloatConverter(35.67e14f); printf("\n");
    398  
     398
    399399  return 0;
    400400}
  • trunk/src/util/loading/game_loader.cc

    r6152 r6424  
    6161}
    6262
    63 
    64 /**
    65  *  this class is a singleton class
    66  * @returns an instance of itself
    67  *
    68  * if you are unsure about singleton classes, check the theory out on the internet :)
    69  */
    70 GameLoader* GameLoader::getInstance()
    71 {
    72   if(singletonRef == NULL)
    73     singletonRef = new GameLoader();
    74   return singletonRef;
    75 }
    7663
    7764/**
     
    124111  if (campaignName)
    125112  {
    126     this->currentCampaign = this->fileToNetworkCampaign(campaignName);
     113    this->currentCampaign = this->fileToCampaign(campaignName);
    127114    delete[] campaignName;
    128115  }
     
    225212
    226213/**
    227  *  release the mem ATTENTION: not implemented
    228  */
    229 ErrorMessage GameLoader::destroy()
    230 {
    231 
    232 }
    233 
    234 
    235 /**
    236214 *  reads a campaign definition file into a campaign class
    237215 * @param fileName to be loaded
     
    285263
    286264
    287 /**
    288  *  reads a campaign definition file into a campaign class
    289  * @param fileName to be loaded
    290  * @returns the loaded campaign
    291  *
    292  *  this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    293  */
    294 Campaign* GameLoader::fileToNetworkCampaign(const char* fileName)
    295 {
    296   /* do not entirely load the campaign. just the current world
    297   before start of each world, it has to be initialized so it
    298   can load everything it needs into memory then.
    299   */
    300 
    301   if( fileName == NULL)
    302   {
    303     PRINTF(2)("No filename specified for loading");
    304     return NULL;
    305   }
    306 
    307   TiXmlDocument* XMLDoc = new TiXmlDocument( fileName);
    308   // load the campaign document
    309   if( !XMLDoc->LoadFile())
    310   {
    311       // report an error
    312     PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    313     delete XMLDoc;
    314     return NULL;
    315   }
    316 
    317   // check basic validity
    318   TiXmlElement* root = XMLDoc->RootElement();
    319   assert( root != NULL);
    320 
    321   if( strcmp( root->Value(), "Campaign"))
    322   {
    323       // report an error
    324     PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
    325     delete XMLDoc;
    326     return NULL;
    327   }
    328 
    329   // construct campaign
    330   Campaign* c = new Campaign( root);
    331 
    332   // free the XML data
    333   delete XMLDoc;
    334 
    335   return c;
    336 }
    337 
    338265
    339266/**
     
    347274    if( likely(event.bPressed))
    348275    {
    349       this->nextLevel();
    350     }
    351   }
    352   else if( event.type == KeyMapper::PEV_PREVIOUS_WORLD)
    353   {
    354     if( likely(event.bPressed))
    355     {
    356       this->previousLevel();
     276      this->switchToNextLevel();
    357277    }
    358278  }
     
    377297
    378298/**
    379  *  \brief this changes to the next level
    380  */
    381 void GameLoader::nextLevel()
    382 {
    383   if(this->currentCampaign != NULL)
    384     this->currentCampaign->nextLevel();
    385 }
    386 
    387 
    388 /**
    389  *  change to the previous level - not implemented
    390  *
    391  * this propably useless
    392  */
    393 void GameLoader::previousLevel()
    394 {
    395   if(this->currentCampaign != NULL)
    396     this->currentCampaign->previousLevel();
    397 }
     299 *  this changes to the next level
     300 */
     301void GameLoader::switchToNextLevel()
     302{
     303  if(this->currentCampaign != NULL)
     304    this->currentCampaign->switchToNextLevel();
     305}
     306
     307
  • trunk/src/util/loading/game_loader.h

    r6152 r6424  
    4141 public:
    4242  ~GameLoader ();
     43  /**  this class is a singleton class @returns an instance of itself  */
     44  static GameLoader* getInstance() { if(singletonRef == NULL) singletonRef = new GameLoader(); return singletonRef; }
    4345
    44   static GameLoader* getInstance();
     46  ErrorMessage loadCampaign(const char* name);
     47  ErrorMessage loadDebugCampaign(Uint32 campaignID);
     48  ErrorMessage loadNetworkCampaign(const char* fileName);
    4549
    4650  ErrorMessage init();
     
    4953  ErrorMessage pause();
    5054  ErrorMessage resume();
    51   ErrorMessage destroy();
    5255
    53   ErrorMessage loadCampaign(const char* name);
    54   ErrorMessage loadDebugCampaign(Uint32 campaignID);
    55   ErrorMessage loadNetworkCampaign(const char* fileName);
    56 
    57   void nextLevel();
    58   void previousLevel();
     56  void switchToNextLevel();
    5957
    6058  void process(const Event &event);
     
    6563
    6664  Campaign* fileToCampaign(const char* name);
    67   Campaign* fileToNetworkCampaign(const char* fileName);
    6865
    6966
  • trunk/src/world_entities/camera.cc

    r6222 r6424  
    1111   ### File Specific:
    1212   main-programmer: Christian Meyer
    13    co-programmer: ...
     13   co-programmer: Benjamin Grauer
    1414*/
    1515#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     
    1717#include "camera.h"
    1818
    19 #include "world.h"
    20 #include "world_entity.h"
    21 #include "vector.h"
    22 #include "event.h"
    2319#include "event_handler.h"
    2420
    2521using namespace std;
    2622
    27 ////////////
    28 // CAMERA //
    29 ////////////
    3023
    3124/**
     
    5851*/
    5952Camera::~Camera()
    60 {
    61 }
     53{}
    6254
    6355/**
     
    115107  currentMode = mode;
    116108  switch (mode)
    117     {
     109  {
    118110    default:
    119111    case VIEW_NORMAL:
    120112      this->toFovy = 60.0;
    121 /*      this->setParentSoft("TrackNode");
    122       this->target->setParentSoft("TrackNode"); */
     113      /*      this->setParentSoft("TrackNode");
     114            this->target->setParentSoft("TrackNode"); */
    123115      this->setRelCoorSoft(-10, 5, 0);
    124116      this->target->setRelCoorSoft(0,0,0);
    125117      break;
    126118    case VIEW_BEHIND:
    127 //      this->toFovy = 120.0;
    128 //      this->setRelCoorSoft(Vector(3.5, 0, 0));
    129   //    this->target->setRelCoorSoft(Vector(10,0,0));
    130 
    131 //       if (!strcmp(this->target->getParent()->getName(), "Player"))
    132 //         this->target->setParentSoft("TrackNode");
    133 //       else
    134 //         this->target->setParentSoft("Player");
    135 //       this->getParent()->debugNode(0);
    136 
    137 //      this->setParent("main-Turret");
    138 //      this->setParentMode(PNODE_ALL);
    139 //      this->target->setParentSoft("Player");
     119      //      this->toFovy = 120.0;
     120      //      this->setRelCoorSoft(Vector(3.5, 0, 0));
     121      //    this->target->setRelCoorSoft(Vector(10,0,0));
     122
     123      //       if (!strcmp(this->target->getParent()->getName(), "Player"))
     124      //         this->target->setParentSoft("TrackNode");
     125      //       else
     126      //         this->target->setParentSoft("Player");
     127      //       this->getParent()->debugNode(0);
     128
     129      //      this->setParent("main-Turret");
     130      //      this->setParentMode(PNODE_ALL);
     131      //      this->target->setParentSoft("Player");
    140132
    141133      break;
    142134    case VIEW_FRONT:
    143135      this->toFovy = 120.0;
    144 /*       this->setParentSoft("Player");
    145        this->target->setParentSoft("Player");*/
    146        this->setRelCoorSoft(4, 0, 0, 5);
    147        this->target->setRelCoorSoft(Vector(10,0,0), 5);
    148 //      this->target->setRelDirSoft(Quaternion(M_PI/4.0, Vector(0,1,0)));
     136      /*       this->setParentSoft("Player");
     137             this->target->setParentSoft("Player");*/
     138      this->setRelCoorSoft(4, 0, 0, 5);
     139      this->target->setRelCoorSoft(Vector(10,0,0), 5);
     140      //      this->target->setRelDirSoft(Quaternion(M_PI/4.0, Vector(0,1,0)));
    149141      break;
    150142    case VIEW_LEFT:
    151143      this->toFovy = 90;
    152 /*      this->setParentSoft("TrackNode");
    153       this->target->setParentSoft("TrackNode");*/
     144      /*      this->setParentSoft("TrackNode");
     145            this->target->setParentSoft("TrackNode");*/
    154146      this->setRelCoorSoft(0, 1, -10, .5);
    155147      this->target->setRelCoorSoft(0,0,0);
     
    157149    case VIEW_RIGHT:
    158150      this->toFovy = 90;
    159 /*      this->setParentSoft("TrackNode");
    160       this->target->setParentSoft("TrackNode");*/
     151      /*      this->setParentSoft("TrackNode");
     152            this->target->setParentSoft("TrackNode");*/
    161153      this->setRelCoorSoft(Vector(0, 1, 10));
    162154      this->target->setRelCoorSoft(0,0,0);
     
    164156    case VIEW_TOP:
    165157      this->toFovy= 120;
    166 /*      this->setParentSoft("TrackNode");
    167       this->target->setParentSoft("TrackNode");*/
     158      /*      this->setParentSoft("TrackNode");
     159            this->target->setParentSoft("TrackNode");*/
    168160      this->setRelCoorSoft(Vector(30, 50, 0));
    169161      this->target->setRelCoorSoft(35,0,0);
    170     }
     162  }
    171163}
    172164
     
    216208  // switching back to Modeling Matrix
    217209  glMatrixMode (GL_MODELVIEW);
    218 //  this->target->getParent()->getParent()->debugDraw(0, 2, Vector(1,0,0));
     210  //  this->target->getParent()->getParent()->debugDraw(0, 2, Vector(1,0,0));
    219211}
    220212
     
    226218{
    227219  if( event.type == KeyMapper::PEV_VIEW0)
    228     {
    229       this->setViewMode(VIEW_NORMAL);
    230     }
     220  {
     221    this->setViewMode(VIEW_NORMAL);
     222  }
    231223  else if( event.type == KeyMapper::PEV_VIEW1)
    232     {
    233       this->setViewMode(VIEW_BEHIND);
    234     }
     224  {
     225    this->setViewMode(VIEW_BEHIND);
     226  }
    235227  else if( event.type == KeyMapper::PEV_VIEW2)
    236     {
    237       this->setViewMode(VIEW_FRONT);
    238     }
     228  {
     229    this->setViewMode(VIEW_FRONT);
     230  }
    239231  else if( event.type == KeyMapper::PEV_VIEW3)
    240     {
    241       this->setViewMode(VIEW_LEFT);
    242     }
     232  {
     233    this->setViewMode(VIEW_LEFT);
     234  }
    243235  else if( event.type == KeyMapper::PEV_VIEW4)
    244     {
    245       this->setViewMode(VIEW_RIGHT);
    246     }
     236  {
     237    this->setViewMode(VIEW_RIGHT);
     238  }
    247239  else if( event.type == KeyMapper::PEV_VIEW5)
    248     {
    249       this->setViewMode(VIEW_TOP);
    250     }
     240  {
     241    this->setViewMode(VIEW_TOP);
     242  }
    251243}
    252244
     
    260252{
    261253  this->setClassID(CL_CAMERA_TARGET, "CameraTarget");
    262 //  this->setParentMode(PNODE_MOVEMENT);
    263 }
    264 
     254  //  this->setParentMode(PNODE_MOVEMENT);
     255}
     256
  • trunk/src/world_entities/power_ups/laser_power_up.cc

    r6222 r6424  
    1919#include "factory.h"
    2020#include "state.h"
     21#include "network_game_manager.h"
    2122
    2223#include "primitive_model.h"
     
    118119}
    119120
     121int LaserPowerUp::writeBytes( const byte * data, int length, int sender )
     122{
     123  setRequestedSync( false );
     124  setIsOutOfSync( false );
     125
     126  SYNCHELP_READ_BEGIN();
     127
     128  SYNCHELP_READ_FKT( PowerUp::writeState );
     129
     130  return SYNCHELP_READ_N;
     131}
     132
     133
     134
     135int LaserPowerUp::readBytes( byte * data, int maxLength, int * reciever )
     136{
     137  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     138  {
     139    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     140    setRequestedSync( true );
     141  }
     142
     143  int rec = this->getRequestSync();
     144  if ( rec > 0 )
     145  {
     146    *reciever = rec;
     147
     148    SYNCHELP_WRITE_BEGIN();
     149
     150    SYNCHELP_WRITE_FKT( PowerUp::readState );
     151
     152    return SYNCHELP_WRITE_N;
     153  }
     154
     155  *reciever = 0;
     156  return 0;
     157}
     158
  • trunk/src/world_entities/power_ups/laser_power_up.h

    r5511 r6424  
    2323  virtual void draw() const;
    2424
     25  virtual int writeBytes(const byte* data, int length, int sender);
     26  virtual int readBytes(byte* data, int maxLength, int * reciever );
     27
    2528  private:
    2629   void init();
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r6243 r6424  
    2525#include "factory.h"
    2626#include "load_param.h"
     27#include "network_game_manager.h"
    2728
    2829using namespace std;
     
    5354void ParamPowerUp::init()
    5455{
     56  this->setClassID(CL_PARAM_POWER_UP, "ParamPowerUp");
    5557  this->value = 0;
    5658  this->max_value = 0;
     
    6365  static_cast<PowerUp*>(this)->loadParams(root);
    6466  LoadParam(root, "type", this, ParamPowerUp, setType);
    65   if(root->FirstChildElement("value") != NULL) {
     67
     68  if( root != NULL && root->FirstChildElement("value") != NULL) {
     69
    6670    LoadParam(root, "value", this, ParamPowerUp, setValue);
    6771  }
     
    116120}
    117121
     122int ParamPowerUp::writeBytes( const byte * data, int length, int sender )
     123{
     124  setRequestedSync( false );
     125  setIsOutOfSync( false );
    118126
     127  SYNCHELP_READ_BEGIN();
     128
     129  SYNCHELP_READ_FKT( PowerUp::writeState );
     130
     131  int i;
     132  SYNCHELP_READ_INT( i );
     133  this->type = (EnumParamPowerUpType)i;
     134  SYNCHELP_READ_INT( this->value );
     135
     136  if ( this->value != 0 )
     137  {
     138    SYNCHELP_READ_INT( this->min_value );
     139    SYNCHELP_READ_INT( this->max_value );
     140  }
     141
     142  return SYNCHELP_READ_N;
     143}
     144
     145
     146
     147int ParamPowerUp::readBytes( byte * data, int maxLength, int * reciever )
     148{
     149  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     150  {
     151    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     152    setRequestedSync( true );
     153  }
     154
     155  int rec = this->getRequestSync();
     156  if ( rec > 0 )
     157  {
     158    *reciever = rec;
     159
     160    SYNCHELP_WRITE_BEGIN();
     161
     162    SYNCHELP_WRITE_FKT( PowerUp::readState );
     163
     164    int i = this->type;
     165    SYNCHELP_WRITE_INT( i );
     166    SYNCHELP_WRITE_INT( this->value );
     167
     168    if ( this->value != 0 )
     169    {
     170      SYNCHELP_WRITE_INT( this->min_value );
     171      SYNCHELP_WRITE_INT( this->max_value );
     172    }
     173
     174    return SYNCHELP_WRITE_N;
     175  }
     176
     177  *reciever = 0;
     178  return 0;
     179}
     180
  • trunk/src/world_entities/power_ups/param_power_up.h

    r6113 r6424  
    3030  int getValue();
    3131
     32  virtual int writeBytes(const byte* data, int length, int sender);
     33  virtual int readBytes(byte* data, int maxLength, int * reciever );
     34
    3235protected:
    3336  virtual void respawn();
  • trunk/src/world_entities/power_ups/power_up.cc

    r6282 r6424  
    2525PowerUp::PowerUp(float r, float g, float b)
    2626{
     27  this->setClassID(CL_POWER_UP, "PowerUp");
     28
    2729  this->respawnType = RESPAWN_NONE;
    2830/*  if(!PowerUp::sphereModel) {*/
     
    5254void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
    5355{
    54  if(entity->isA(CL_EXTENDABLE))
     56  if(entity->isA(CL_EXTENDABLE))
    5557  {
    5658    if(dynamic_cast<Extendable*>(entity)->pickup(this))
     
    9496}
    9597
     98/**
     99 * data copied in data will bee sent to another host
     100 * @param data pointer to data
     101 * @param maxLength max length of data
     102 * @return the number of bytes writen
     103 */
     104int PowerUp::readState( byte * data, int maxLength )
     105{
     106  SYNCHELP_WRITE_BEGIN();
     107  SYNCHELP_WRITE_FKT( WorldEntity::readState );
     108  return SYNCHELP_WRITE_N;
     109}
     110
     111/**
     112 * Writes data from network containing information about the state
     113 * @param data pointer to data
     114 * @param length length of data
     115 * @param sender hostID of sender
     116 */
     117int PowerUp::writeState( const byte * data, int length, int sender )
     118{
     119  SYNCHELP_READ_BEGIN();
     120  SYNCHELP_READ_FKT( WorldEntity::writeState );
     121  return SYNCHELP_READ_N;
     122}
     123
  • trunk/src/world_entities/power_ups/power_up.h

    r6282 r6424  
    2626  void setRespawnType(const char* type);
    2727
     28  int       writeState(const byte* data, int length, int sender);
     29  int       readState(byte* data, int maxLength );
     30
    2831protected:
    2932  PowerUp(float r, float g, float b);
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r6222 r6424  
    1818#include "turret_power_up.h"
    1919#include "factory.h"
     20#include "network_game_manager.h"
    2021#include "state.h"
    2122
     
    118119}
    119120
     121int TurretPowerUp::writeBytes( const byte * data, int length, int sender )
     122{
     123  setRequestedSync( false );
     124  setIsOutOfSync( false );
     125
     126  SYNCHELP_READ_BEGIN();
     127
     128  SYNCHELP_READ_FKT( PowerUp::writeState );
     129
     130  return SYNCHELP_READ_N;
     131}
     132
     133
     134
     135int TurretPowerUp::readBytes( byte * data, int maxLength, int * reciever )
     136{
     137  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     138  {
     139    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     140    setRequestedSync( true );
     141  }
     142
     143  int rec = this->getRequestSync();
     144  if ( rec > 0 )
     145  {
     146    *reciever = rec;
     147
     148    SYNCHELP_WRITE_BEGIN();
     149
     150    SYNCHELP_WRITE_FKT( PowerUp::readState );
     151
     152    return SYNCHELP_WRITE_N;
     153  }
     154
     155  *reciever = 0;
     156  return 0;
     157}
  • trunk/src/world_entities/power_ups/turret_power_up.h

    r5511 r6424  
    2323  virtual void draw() const;
    2424
     25  virtual int writeBytes(const byte* data, int length, int sender);
     26  virtual int readBytes(byte* data, int maxLength, int * reciever );
     27
    2528  private:
    2629   void init();
  • trunk/src/world_entities/power_ups/weapon_power_up.cc

    r6243 r6424  
    2020#include "state.h"
    2121#include "list.h"
     22#include "network_game_manager.h"
    2223
    2324#include "primitive_model.h"
     
    8586  this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name));
    8687}
     88
     89int WeaponPowerUp::writeBytes( const byte * data, int length, int sender )
     90{
     91  setRequestedSync( false );
     92  setIsOutOfSync( false );
     93
     94  SYNCHELP_READ_BEGIN();
     95
     96  SYNCHELP_READ_FKT( PowerUp::writeState );
     97
     98  //TODO: sync weapon class ( see loadParams )
     99
     100  return SYNCHELP_READ_N;
     101}
     102
     103
     104
     105int WeaponPowerUp::readBytes( byte * data, int maxLength, int * reciever )
     106{
     107  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     108  {
     109    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     110    setRequestedSync( true );
     111  }
     112
     113  int rec = this->getRequestSync();
     114  if ( rec > 0 )
     115  {
     116    *reciever = rec;
     117
     118    SYNCHELP_WRITE_BEGIN();
     119
     120    SYNCHELP_WRITE_FKT( PowerUp::readState );
     121
     122    //TODO: sync weapon class ( see loadParams )
     123
     124    return SYNCHELP_WRITE_N;
     125  }
     126
     127  *reciever = 0;
     128  return 0;
     129}
  • trunk/src/world_entities/power_ups/weapon_power_up.h

    r6113 r6424  
    2222  void setWeaponClass(const char* name);
    2323
     24  virtual int writeBytes(const byte* data, int length, int sender);
     25  virtual int readBytes(byte* data, int maxLength, int * reciever );
     26
    2427protected:
    2528  virtual void respawn();
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6341 r6424  
    3131#include "key_mapper.h"
    3232#include "event_handler.h"
     33
     34#include "network_game_manager.h"
    3335
    3436#include "power_ups/weapon_power_up.h"
     
    121123  PRINTF(4)("SPACESHIP INIT\n");
    122124
    123   //  EventHandler::getInstance()->grabEvents(true);
     125    EventHandler::getInstance()->grabEvents(true);
    124126
    125127  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
     
    516518  }
    517519}
     520
     521
     522int SpaceShip::writeBytes( const byte * data, int length, int sender )
     523{
     524  setRequestedSync( false );
     525  setIsOutOfSync( false );
     526
     527  SYNCHELP_READ_BEGIN();
     528
     529  SYNCHELP_READ_FKT( WorldEntity::writeState );
     530
     531  return SYNCHELP_READ_N;
     532}
     533
     534int SpaceShip::readBytes( byte * data, int maxLength, int * reciever )
     535{
     536  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     537  {
     538    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     539    setRequestedSync( true );
     540  }
     541
     542  int rec = this->getRequestSync();
     543  if ( rec > 0 )
     544  {
     545    *reciever = rec;
     546
     547    SYNCHELP_WRITE_BEGIN();
     548
     549    SYNCHELP_WRITE_FKT( WorldEntity::readState );
     550
     551    return SYNCHELP_WRITE_N;
     552  }
     553
     554  *reciever = 0;
     555  return 0;
     556}
  • trunk/src/world_entities/space_ships/space_ship.h

    r6243 r6424  
    4444    bool pickup(PowerUp* powerUp);
    4545
     46    virtual int       writeBytes(const byte* data, int length, int sender);
     47    virtual int       readBytes(byte* data, int maxLength, int * reciever);
     48
    4649
    4750  private:
  • trunk/src/world_entities/spawning_point.cc

    r6139 r6424  
    1616
    1717#include "spawning_point.h"
     18
    1819#include "load_param.h"
    1920#include "factory.h"
     21
    2022#include "compiler.h"
    21 #include "world.h" /* only temp. until the object manager is implemented*/
     23
    2224
    2325/**
     
    9799            this->frequency, this->seed);
    98100  BaseObject* spawningEntity = Factory::fabricate(this->classID);
    99   if( likely(this->world != NULL))
    100     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
     101
     102//   if( likely(this->world != NULL))
     103//     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
    101104}
    102105
  • trunk/src/world_entities/weapons/ground_turret.cc

    r6341 r6424  
    119119void GroundTurret::draw () const
    120120{
    121   glMatrixMode(GL_MODELVIEW);
    122   glPushMatrix();
    123   float matrix[4][4];
    124 
    125   /* translate */
    126   glTranslatef (this->getAbsCoor ().x,
    127                 this->getAbsCoor ().y,
    128                 this->getAbsCoor ().z);
    129   /* rotate */
    130   this->getAbsDir().matrix(matrix);
    131   glMultMatrixf((float*)matrix);
    132 
    133   if (this->getModel())
    134     this->getModel()->draw();
    135 
    136   glPopMatrix();
     121  WorldEntity::draw();
     122
    137123  if (this->left != NULL)
    138124    this->left->draw();
  • trunk/src/world_entities/world_entity.cc

    r6341 r6424  
    3535    ->defaultValues(2, "models/ships/fighter.obj", 1.0);
    3636
     37SHELL_COMMAND(debugEntity, WorldEntity, debugWE);
    3738
    3839/**
     
    4849
    4950  this->obbTree = NULL;
     51
     52  this->md2TextureFileName = NULL;
    5053
    5154  if (root != NULL)
     
    105108void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber)
    106109{
     110  this->scaling = scaling;
    107111  if ( fileName != NULL && strcmp(fileName, "") )
    108112  {
     
    123127      return;
    124128    }
    125 
     129    if (scaling == 0.0)
     130    {
     131      scaling = 1.0;
     132      PRINTF(1)("YOU GAVE ME A CRAPY SCALE resetting to 1\n");
     133    }
    126134    if(strstr(fileName, ".obj"))
    127135    {
     
    343351}
    344352
     353
     354/**
     355 * Debug the WorldEntity
     356 */
     357void WorldEntity::debugEntity() const
     358{
     359  PRINT(0)("WorldEntity %s::%s  (DEBUG)\n", this->getClassName(), this->getName());
     360  this->debugNode();
     361  PRINT(0)("List: %s ; ModelCount %d - ", ObjectManager::OMListToString(this->objectListNumber) , this->models.size());
     362  for (unsigned int i = 0; i < this->models.size(); i++)
     363  {
     364    if (models[i] != NULL)
     365      PRINT(0)(" : %d:%s", i, this->models[i]->getName());
     366  }
     367  PRINT(0)("\n");
     368
     369}
     370
     371
    345372/**
    346373 * Writes data from network containing information about the state
     
    359386  SYNCHELP_READ_FLOAT( scaling );
    360387  //check if modelFileName is relative to datadir or absolute
    361   if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) )
    362   {
    363     loadModel( modelFileName+strlen(ResourceManager::getInstance()->getDataDir()), scaling );
    364   }
    365   else
    366   {
    367     loadModel( modelFileName, scaling );
     388
     389  if ( strcmp(modelFileName, "") )
     390  {
     391
     392    if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) )
     393    {
     394      loadModel( modelFileName+strlen(ResourceManager::getInstance()->getDataDir()), scaling );
     395    }
     396    else
     397    {
     398      loadModel( modelFileName, scaling );
     399    }
    368400  }
    369401  delete[] modelFileName;
     402
     403  SYNCHELP_READ_STRINGM( modelFileName );
     404  if ( strcmp(modelFileName, "") )
     405    this->md2TextureFileName = modelFileName;
    370406
    371407  return SYNCHELP_READ_N;
     
    386422  SYNCHELP_WRITE_STRING( getModel( 0 )->getName() );
    387423  SYNCHELP_WRITE_FLOAT( scaling );
     424  if ( this->md2TextureFileName!=NULL && strcmp(this->md2TextureFileName, "") )
     425  {
     426    SYNCHELP_WRITE_STRING(this->md2TextureFileName);
     427  }
     428  else
     429  {
     430    SYNCHELP_WRITE_STRING("");
     431  }
     432
    388433  return SYNCHELP_WRITE_N;
    389434}
  • trunk/src/world_entities/world_entity.h

    r6341 r6424  
    6060  void drawBVTree(unsigned int depth, int drawMode) const;
    6161
     62
     63  void debugWE() { this->debugEntity(); };  ///FIXME
     64  void debugEntity() const;
     65
     66
    6267  /* @returns the Count of Faces on this WorldEntity */
    6368  //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; };
Note: See TracChangeset for help on using the changeset viewer.