Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6150 in orxonox.OLD


Ignore:
Timestamp:
Dec 17, 2005, 5:56:25 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: cleanup of the world begin

Location:
trunk/src
Files:
4 edited
2 copied

Legend:

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

    r6142 r6150  
    2020
    2121#include "shell_command.h"
    22 
     22#include "resource_manager.h"
    2323#include "state.h"
    2424
    2525#include "p_node.h"
    26 #include "pilot_node.h"
    2726#include "world_entity.h"
    2827#include "player.h"
    2928#include "camera.h"
    3029#include "environment.h"
    31 #include "skysphere.h"
    32 #include "skybox.h"
    33 #include "satellite.h"
     30
    3431#include "test_entity.h"
    3532#include "terrain.h"
     
    9188
    9289/**
    93   *  create a new World
    94 
    95     This creates a new empty world!
    96 */
    97 World::World (const char* name)
    98 {
    99   this->path = NULL;
    100   this->constuctorInit(name, -1);
    101 }
    102 
    103 /**
    104  *  creates a new World...
    105  * @param worldID with this ID
    106 */
    107 World::World (int worldID)
    108 {
    109   this->path = NULL;
    110   this->constuctorInit(NULL, worldID);
    111 }
    112 
    113 /**
    11490 *  remove the World from memory
    115 
    116     delete everything explicitly, that isn't contained in the parenting tree!
    117     things contained in the tree are deleted automaticaly
     91 *
     92 *  delete everything explicitly, that isn't contained in the parenting tree!
     93 *  things contained in the tree are deleted automaticaly
    11894 */
    11995World::~World ()
     
    150126  // unload the resources !!
    151127  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
    152 
    153   delete[] this->path;
    154128}
    155129
     
    170144
    171145  this->setName(name);
    172   this->debugWorldNr = worldID;
    173146  this->gameTime = 0.0f;
    174147  this->setSpeed(1.0);
     
    232205/**
    233206 *  loads the World by initializing all resources, and set their default values.
    234 */
     207 */
    235208ErrorMessage World::load()
    236209{
     
    242215    {
    243216      PRINTF(1)("World has no path specified for loading");
    244       this->loadDebugWorld(this->getStoryID());
    245217      return (ErrorMessage){213,"Path not specified","World::load()"};
    246218    }
     
    330302          //todo do this more elegant
    331303          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
    332             sky = dynamic_cast<SkyBox*>(created);
     304            this->sky = dynamic_cast<WorldEntity*>(created);
    333305          if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    334306          {
     
    382354  }
    383355
    384   // initialize debug coord system
    385   objectList = glGenLists(1);
    386   glNewList (objectList, GL_COMPILE);
    387 
    388   glEndList();
    389 
    390356  SoundEngine::getInstance()->setListener(this->localCamera);
    391357
     
    418384
    419385
    420 
    421 /**
    422  * creates a debug world: only for experimental stuff
    423 */
    424 void World::loadDebugWorld(int worldID)
    425 {
    426   /*monitor progress*/
    427   this->glmis->step();
    428   // stuff beyond this point remains to be loaded properly
    429 
    430   // LIGHT initialisation
    431   LightManager::getInstance()->setAmbientColor(.1,.1,.1);
    432 //  LightManager::getInstance()->addLight();
    433   LightManager::getInstance()->debug();
    434 
    435   switch(this->debugWorldNr)
    436     {
    437       /*
    438         this loads the hard-coded debug world. this only for simplicity and will be
    439         removed by a reald world-loader, which interprets a world-file.
    440         if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
    441         make whatever you want...
    442       */
    443     case DEBUG_WORLD_0:
    444       {
    445         LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0);
    446         /*monitor progress*/
    447         this->glmis->step();
    448 
    449         // bind camera
    450         this->localCamera = new Camera();
    451         this->localCamera->setName ("camera");
    452         /*monitor progress*/
    453         this->glmis->step();
    454 
    455 
    456         // Create SkySphere
    457         this->sky = new Skysphere("pictures/sky-replace.jpg");
    458         this->sky->setName("SkySphere");
    459         this->spawn(this->sky);
    460         this->localCamera->addChild(this->sky);
    461         this->sky->setParentMode(PNODE_MOVEMENT);
    462         /*monitor progress*/
    463         this->glmis->step();
    464 
    465 
    466         terrain = new Terrain("worlds/newGround.obj");
    467         terrain->setRelCoor(Vector(0,-10,0));
    468         this->spawn(terrain);
    469         /*monitor progress*/
    470         this->glmis->step();
    471 
    472         this->glmis->step();
    473         break;
    474       }
    475     case DEBUG_WORLD_1:
    476       {
    477 
    478         break;
    479       }
    480     case DEBUG_WORLD_2:
    481       {
    482 
    483         break;
    484       }
    485     default:
    486       break;
    487     }
    488 }
    489 
    490386/**
    491387 *  initializes a new World shortly before start
     
    501397  PNode::getNullParent()->updateNode (0.001f);
    502398  PNode::getNullParent()->updateNode (0.001f);
    503 
    504399}
    505400
     
    507402/**
    508403 *  starts the World
    509 */
     404 */
    510405ErrorMessage World::start()
    511406{
    512   PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
    513407  this->bQuitOrxonox = false;
    514408  this->bQuitCurrentGame = false;
     
    566460
    567461/**
    568  * removes the loadscreen, and changes over to the game
    569 
    570    @todo take out the delay
     462 * @brief removes the loadscreen, and changes over to the game
     463 *
     464 * @todo take out the delay
    571465*/
    572466void World::releaseLoadScreen ()
     
    588482}
    589483
    590 /**
    591   \brief main loop of the world: executing all world relevant function
    592 
    593   in this loop we synchronize (if networked), handle input events, give the heart-beat to
    594   all other member-entities of the world (tick to player, enemies etc.), checking for
    595   collisions drawing everything to the screen.
    596 */
    597 void World::mainLoop()
    598 {
    599   this->lastFrame = SDL_GetTicks ();
    600   PRINTF(3)("World::mainLoop() - Entering main loop\n");
    601 
    602   while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */
    603     {
    604       ++this->cycle;
    605       // Network
    606       this->synchronize ();
    607       // Process input
    608       this->handleInput ();
    609       if( this->bQuitCurrentGame || this->bQuitOrxonox)
    610           break;
    611       // Process time
    612       this->tick ();
    613       // Process collision
    614       this->collide ();
    615       // Update the state
    616       this->update ();
    617       // Draw
    618       this->display ();
    619     }
    620 
    621   PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
    622 }
    623484
    624485
     
    786647//   }
    787648
    788   glCallList (objectList);
    789 
    790649  ParticleEngine::getInstance()->draw();
    791650
     
    797656}
    798657
     658
     659/**
     660 * \brief main loop of the world: executing all world relevant function
     661 *
     662 * in this loop we synchronize (if networked), handle input events, give the heart-beat to
     663 * all other member-entities of the world (tick to player, enemies etc.), checking for
     664 * collisions drawing everything to the screen.
     665 */
     666void World::mainLoop()
     667{
     668  this->lastFrame = SDL_GetTicks ();
     669  PRINTF(3)("World::mainLoop() - Entering main loop\n");
     670
     671  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */
     672  {
     673    ++this->cycle;
     674      // Network
     675    this->synchronize ();
     676      // Process input
     677    this->handleInput ();
     678    if( this->bQuitCurrentGame || this->bQuitOrxonox)
     679      break;
     680      // Process time
     681    this->tick ();
     682      // Process collision
     683    this->collide ();
     684      // Update the state
     685    this->update ();
     686      // Draw
     687    this->display ();
     688  }
     689
     690  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
     691}
     692
     693
     694
    799695/**
    800696 *  add and spawn a new entity to this world
     
    805701//   this->entities->add (entity);
    806702  entity->postSpawn ();
    807 }
    808 
    809 
    810 /**
    811  *  add and spawn a new entity to this world
    812  * @param entity to be added
    813  * @param absCoor At what coordinates to add this entity.
    814  * @param absDir In which direction should it look.
    815 */
    816 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    817 {
    818 //   this->entities->add (entity);
    819 
    820   entity->setAbsCoor (*absCoor);
    821   entity->setAbsDir (*absDir);
    822 
    823   entity->postSpawn ();
    824 }
    825 
    826 
    827 /**
    828  *  add and spawn a new entity to this world
    829  * @param entity to be added
    830  * @param entity to be added to (PNode)
    831  * @param At what relative  coordinates to add this entity.
    832  * @param In which relative direction should it look.
    833 */
    834 void World::spawn(WorldEntity* entity, PNode* parentNode,
    835                   Vector* relCoor, Quaternion* relDir)
    836 {
    837   if( parentNode != NULL)
    838     {
    839       parentNode->addChild (entity);
    840 
    841       entity->setRelCoor (*relCoor);
    842       entity->setRelDir (*relDir);
    843 
    844 //       this->entities->add (entity);
    845 
    846       entity->postSpawn ();
    847     }
    848703}
    849704
  • trunk/src/story_entities/world.h

    r6142 r6150  
    3232
    3333 public:
    34   World (const char* name);
    35   World (int worldID);
    3634  World (const TiXmlElement* root = NULL);
    3735  virtual ~World ();
     
    5149  virtual ErrorMessage destroy ();
    5250
    53   void loadDebugWorld(int worldID);
    54 
    5551  virtual void displayLoadScreen();
    5652  virtual void releaseLoadScreen();
     
    6157  /* interface to world */
    6258  void spawn (WorldEntity* entity);
    63   void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir);
    64   void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir);
    6559
    6660  /** @param speed sets the speed of the Game */
     
    6862  const char* getPath();
    6963  void setPath( const char* name);
    70 
    71   inline Camera* getLocalCamera() { return this->localCamera; };
    7264
    7365  void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; };
     
    7769  void constuctorInit(const char* name, int worldID);
    7870  /* function for main-loop */
    79   void mainLoop ();
    8071  void synchronize ();
    8172  void handleInput ();
     
    8576  void collide ();
    8677  void draw ();
     78  void mainLoop ();
     79
    8780  void display ();
    8881  void debug ();
    8982
    9083  private:
     84    char* path;                         //!< The file from which this world is loaded
     85
    9186    bool   showPNodes;                  //!< if the PNodes should be visible.
    9287    bool   showBV;                      //!< if the Bounding Volumes should be visible.
     88
    9389    Uint32 lastFrame;                   //!< last time of frame
    9490    Uint32 cycle;                       //!< The cycle we are in (starts with 0 and rises with every frame)
     
    105101    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    106102
    107     int debugWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
    108     char* path;                         //!< The file from which this world is loaded
    109 
    110103    Shell*     shell;
    111104    OggPlayer* music;
     
    116109    Terrain* terrain;                   //!< The Terrain of the World.
    117110
    118     GLuint objectList;                  //!< temporary: @todo this will be ereased soon
    119 
    120111    Player* localPlayer;                //!< The Player, you fly through the level.
    121112};
  • trunk/src/util/loading/game_loader.cc

    r6139 r6150  
    151151    case DEBUG_CAMPAIGN_0:
    152152      {
    153         Campaign* debugCampaign = new Campaign();
     153        // FIXME
     154/*        Campaign* debugCampaign = new Campaign();
    154155
    155156        World* world0 = new World(DEBUG_WORLD_0);
     
    166167
    167168        this->currentCampaign = debugCampaign;
    168         break;
     169        break;*/
    169170      }
    170171    }
  • trunk/src/world_entities/power_ups/power_up.cc

    r6148 r6150  
    3333  this->sphereMaterial->setTransparency(.1);
    3434  this->sphereMaterial->setDiffuse(r, g, b);
     35
     36  this->toList(OM_COMMON);
    3537}
    3638
Note: See TracChangeset for help on using the changeset viewer.