Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/game_world.cc @ 10376

Last change on this file since 10376 was 10376, checked in by patrick, 17 years ago

merged branche ai to trunk

File size: 19.1 KB
RevLine 
[6352]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
[10314]13   main-programmer: Benjamin Grauer
[6352]14   co-programmer: Christian Meyer
[10314]15
[6352]16*/
17
18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
19
[6358]20#include "game_world.h"
[6402]21#include "game_world_data.h"
[6352]22
23#include "state.h"
24
[7193]25#include "util/loading/game_loader.h"
[7919]26#include "util/timer.h"
[6404]27
[6352]28#include "player.h"
29#include "camera.h"
30#include "environment.h"
31#include "terrain.h"
[7287]32#include "test_entity.h"
33#include "terrain.h"
[6404]34#include "playable.h"
[7785]35#include "environments/mapped_water.h"
[6404]36
[6352]37#include "light.h"
[6404]38
[7193]39#include "util/loading/factory.h"
[9869]40#include "util/loading/load_param_xml.h"
41#include "loading/fast_factory.h"
[6404]42#include "shell_command.h"
[6352]43
44#include "graphics_engine.h"
[9869]45#include "weather_effects/atmospheric_engine.h"
[6404]46#include "event_handler.h"
47#include "sound_engine.h"
48#include "cd_engine.h"
49#include "network_manager.h"
[6352]50#include "physics_engine.h"
51
52#include "glmenu_imagescreen.h"
[6404]53#include "shell.h"
[6352]54
55#include "ogg_player.h"
[6404]56#include "shader.h"
[10376]57#include "ai_engine.h"
[6352]58
[7369]59#include "animation_player.h"
60
[7035]61#include "game_rules.h"
[6352]62
[9110]63#include "script_class.h"
[9869]64ObjectListDefinition(GameWorld);
65CREATE_SCRIPTABLE_CLASS(GameWorld,
66                        addMethod("setPlaymode", Executor1<GameWorld, lua_State*,const std::string&>(&GameWorld::setPlaymode))
67                        ->addMethod("setSoundtrack", Executor1<GameWorld, lua_State*, const std::string&>(&GameWorld::setSoundtrack))
[10319]68                        ->addMethod("getStoryID", Executor0ret<StoryEntity, lua_State*, int>(&StoryEntity::getStoryID))
69                        ->addMethod("setNextStoryName", Executor1ret<StoryEntity, lua_State*, bool, const std::string&>(&StoryEntity::setNextStoryName))
70                        ->addMethod("stop", Executor0ret<GameWorld, lua_State*, bool>(&GameWorld::stop))
[9110]71                       );
[6352]72
[7412]73SHELL_COMMAND(speed, GameWorld, setSpeed) ->describe("set the Speed of the Level");
74SHELL_COMMAND(playmode, GameWorld, setPlaymode)
[7723]75->describe("Set the Playmode of the current Level")
76->completionPlugin(0, OrxShell::CompletorStringArray(Playable::playmodeNames, Playable::PlaymodeCount));
[7412]77
[7739]78SHELL_COMMAND(togglePNodeVisibility, GameWorld, togglePNodeVisibility);
79SHELL_COMMAND(showBVLevel, GameWorld, toggleBVVisibility);
[10314]80SHELL_COMMAND(showMountPoints, GameWorld, toggleMPVisibility);
[6352]81
82
[6989]83GameWorld::GameWorld()
[6402]84    : StoryEntity()
[6352]85{
[9869]86  this->registerObject(this, GameWorld::_objectList);
[6368]87  this->setName("Preloaded World - no name yet");
88
89  this->gameTime = 0.0f;
[6370]90  this->setSpeed(1.0f);
[6368]91  this->shell = NULL;
92
93  this->showPNodes = false;
94  this->showBV = false;
[7739]95  this->showBVLevel = 3;
[10314]96  this->showMPV = false;
[6368]97
[6845]98  this->dataXML = NULL;
[7391]99  this->gameRules = NULL;
[6352]100}
101
102/**
[6358]103 *  remove the GameWorld from memory
[6352]104 *
105 *  delete everything explicitly, that isn't contained in the parenting tree!
106 *  things contained in the tree are deleted automaticaly
107 */
[6358]108GameWorld::~GameWorld ()
[6352]109{
[6408]110  PRINTF(4)("Deleted GameWorld\n");
[7283]111
[6352]112}
113
114
115
116/**
[6358]117 * loads the parameters of a GameWorld from an XML-element
[6352]118 * @param root the XML-element to load from
119 */
[6358]120void GameWorld::loadParams(const TiXmlElement* root)
[6352]121{
[6512]122  StoryEntity::loadParams(root);
[6352]123
[6376]124  PRINTF(4)("Loaded GameWorld specific stuff\n");
[6352]125}
126
[6368]127
[6352]128/**
129 * this is executed just before load
130 *
131 * since the load function sometimes needs data, that has been initialized
132 * before the load and after the proceeding storyentity has finished
133*/
[6370]134ErrorMessage GameWorld::init()
[6352]135{
136  /* init the world interface */
[7374]137  this->shell = new OrxShell::Shell();
[6352]138
[6498]139  State::setCurrentStoryEntity(dynamic_cast<StoryEntity*>(this));
[6407]140  this->dataTank->init();
[7369]141
142  /* initialize some engines and graphical elements */
143  AnimationPlayer::getInstance();
144  PhysicsEngine::getInstance();
[10013]145  CoRe::CREngine::getInstance();
[8408]146
147  State::setScriptManager(&this->scriptManager);
148
[8717]149  return ErrorMessage();
[6352]150}
151
152/**
[6358]153 *  loads the GameWorld by initializing all resources, and set their default values.
[6352]154 */
[6372]155ErrorMessage GameWorld::loadData()
[6352]156{
[8408]157  this->displayLoadScreen();  State::setScriptManager(&this->scriptManager);
[6370]158
[8408]159
[9869]160  PRINTF(4)("Loading the GameWorld\n");
[6407]161
[7677]162  PRINTF(3)("> Loading world: '%s'\n", getLoadFile().c_str());
[9235]163  //  TiXmlElement* element;
164  //  GameLoader* loader = GameLoader::getInstance();
[6352]165
[7221]166  if( getLoadFile().empty())
[6402]167  {
[6634]168    PRINTF(1)("GameWorld has no path specified for loading\n");
[8717]169    return (ErrorMessage(213,"Path not specified","GameWorld::load()"));
[6402]170  }
[6352]171
[7287]172  TiXmlDocument* XMLDoc = new TiXmlDocument( getLoadFile());
[6402]173  // load the xml world file for further loading
[7287]174  if( !XMLDoc->LoadFile())
[6352]175  {
[7287]176    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile().c_str(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
177    delete XMLDoc;
[8717]178    return ErrorMessage(213,"XML File parsing error","GameWorld::load()");
[6352]179  }
180  // check basic validity
[7287]181  TiXmlElement* root = XMLDoc->RootElement();
[6352]182  assert( root != NULL);
183  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
184  {
[6402]185    // report an error
186    PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
[7287]187    delete XMLDoc;
[8717]188    return ErrorMessage(213,"Path not a WorldDataFile","GameWorld::load()");
[6352]189  }
[6402]190  /* the whole loading process for the GameWorld */
[6407]191  this->dataTank->loadData(root);
[6845]192  this->dataXML = (TiXmlElement*)root->Clone();
[6352]193
[8408]194  //remove this after finished testing !!!!
[8711]195  //Object* obj= new Object();
196  //obj->setName("Obj");
197  //Account* a = new Account();
198  //a->setName("a");
199  //Account *b = new Account(30);
200  //b->setName("b");
[8717]201
[8740]202
[8271]203  LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams);
204
[7287]205  delete XMLDoc;
[6386]206  this->releaseLoadScreen();
[8717]207
208  return ErrorMessage();
[6352]209}
210
211
212/**
[6387]213 *  unload the data of this GameWorld
214 */
215ErrorMessage GameWorld::unloadData()
216{
[8271]217
[7287]218  PRINTF(3)("GameWorld::~GameWorld() - unloading the current GameWorld\n");
[8271]219  this->scriptManager.flush();
220
[7370]221  delete this->shell;
[6387]222
[6981]223  this->dataTank->unloadData();
224
[7369]225  this->shell = NULL;
226  delete AnimationPlayer::getInstance();
227  delete PhysicsEngine::getInstance();
[10013]228  delete CoRe::CREngine::getInstance();
[7369]229
[6988]230  State::setCurrentStoryEntity(NULL);
[6845]231  if (this->dataXML)
232    delete this->dataXML;
[8717]233
234  return ErrorMessage();
[6387]235}
236
237
[9235]238void GameWorld::setSoundtrack(const std::string& soundTrack)
239{
240  if (this->dataTank != NULL)
241  {
242    this->dataTank->setSoundTrack(soundTrack);
243    this->dataTank->music->play();
244  }
245}
246
247
[6387]248/**
[6358]249 *  starts the GameWorld
[6352]250 */
[6387]251bool GameWorld::start()
[6352]252{
[7283]253  this->bPaused = false;
254  this->bRunning = true;
[8408]255  State::setScriptManager(&this->scriptManager); //make sure we have the right script manager
[6387]256  this->run();
[8717]257
258  return true;
[6352]259}
260
[6402]261
[6352]262/**
263 *  stops the world.
[6402]264 */
[6387]265bool GameWorld::stop()
[6352]266{
[6358]267  PRINTF(3)("GameWorld::stop() - got stop signal\n");
[8408]268  State::setScriptManager(NULL);
[8717]269  return (this->bRunning = false);
[6352]270}
271
[6402]272
[6352]273/**
[6402]274 *  pauses the game
275 */
[6387]276bool GameWorld::pause()
[6352]277{
[8717]278  return (this->bPaused = true);
[6352]279}
280
[6402]281
[6352]282/**
283 *  ends the pause Phase
[6409]284 */
[6387]285bool GameWorld::resume()
[6352]286{
[8717]287  return(this->bPaused = false);
[6352]288}
289
290
291/**
[6402]292 *  main loop of the world: executing all world relevant function
293 *
294 * in this loop we synchronize (if networked), handle input events, give the heart-beat to
295 * all other member-entities of the world (tick to player, enemies etc.), checking for
296 * collisions drawing everything to the screen.
297 */
298void GameWorld::run()
[6352]299{
[6402]300  PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n");
[6352]301
[7131]302  // initialize Timing
303  this->cycle = 0;
304  for (unsigned int i = 0; i < TICK_SMOOTH_VALUE; i++)
[7919]305    this->frameTimes[i] = 0.01f;
[7131]306  this->dtS = 0.0f;
[7919]307  this->lastFrame = Timer::getNow();
[7131]308
[7304]309  if (this->dataTank->music != NULL)
310    this->dataTank->music->play();
311
[10319]312  PNode::getNullParent()->updateNode(0.01);
313  PNode::getNullParent()->updateNode(0.01);
314
[10340]315  bool bNoDraw = true;
[10319]316
[7283]317  while( this->bRunning) /* @todo implement pause */
[6402]318  {
319    /* process intput */
320    this->handleInput ();
[7322]321    if( !this->bRunning)
322      break;
[6386]323
[6402]324    /* network synchronisation */
325    this->synchronize ();
326    /* process time */
327    this->tick ();
[8490]328
[8740]329
[8724]330    /* update the state */
[8740]331    //this->update (); /// LESS REDUNDANCY.
[9235]332    //      PNode::getNullParent()->updateNode(this->dtS);
[9061]333    PNode::getNullParent()->updateNode(this->dtS);
[8724]334
[8190]335    /* collision detection */
336    this->collisionDetection ();
337    /* collision reaction */
338    this->collisionReaction ();
[8490]339
[10376]340    /* perform ai check*/
341    this->checkAI();
342
[8724]343    /* check the game rules */
344    this->checkGameRules();
[8740]345
[6402]346    /* update the state */
347    this->update ();
348    /* draw everything */
[10340]349    if( bNoDraw)
350      this->display ();
[7306]351
[10340]352    bNoDraw= !bNoDraw;
[6402]353  }
354
[9869]355  PRINTF(4)("GameWorld::mainLoop() - Exiting the main loop\n");
[6352]356}
357
358
[7338]359void GameWorld::setPlaymode(Playable::Playmode playmode)
360{
361  if (this->dataTank->localPlayer &&
362      this->dataTank->localPlayer->getPlayable() &&
[7339]363      this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode))
[7338]364  {
[10368]365    PRINTF(0)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
[7338]366  }
[7339]367  else
368  {
[10368]369    PRINTF(0)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
[7339]370  }
[7338]371}
372
[7339]373void GameWorld::setPlaymode(const std::string& playmode)
374{
375  this->setPlaymode(Playable::stringToPlaymode(playmode));
376}
[7338]377
[6352]378/**
379 *  synchronize local data with remote data
380*/
[6358]381void GameWorld::synchronize ()
[6402]382{}
[6352]383
384
385/**
386 *  run all input processing
387
388   the command node is the central input event dispatcher. the node uses the even-queue from
389   sdl and has its own event-passing-queue.
390*/
[6358]391void GameWorld::handleInput ()
[6352]392{
393  EventHandler::getInstance()->process();
394}
395
[6402]396
397/**
[7370]398 * @brief ticks a WorldEntity list
[6402]399 * @param entityList list of the WorldEntities
400 * @param dt time passed since last frame
401 */
[7370]402void GameWorld::tick(ObjectManager::EntityList entityList, float dt)
[6352]403{
[7370]404  ObjectManager::EntityList::iterator entity, next;
[6710]405  next = entityList.begin();
406  while (next != entityList.end())
407  {
408    entity = next++;
[6352]409    (*entity)->tick(dt);
[6710]410  }
[6352]411}
412
[7131]413
[6352]414/**
415 *  advance the timeline
[6402]416 *
417 * this calculates the time used to process one frame (with all input handling, drawing, etc)
418 * the time is mesured in ms and passed to all world-entities and other classes that need
419 * a heart-beat.
420 */
[6358]421void GameWorld::tick ()
[6352]422{
[7283]423  if( !this->bPaused)
[6402]424  {
[7131]425    // CALCULATE FRAMERATE
426    Uint32 frameTimesIndex;
427    Uint32 i;
[7919]428    double currentFrame = Timer::getNow();
[6402]429
[9494]430    if (currentFrame - this->lastFrame < .01)
431    {
[9869]432      SDL_Delay((int)(1000.0 * (0.01 - (currentFrame - lastFrame))));
[9494]433      currentFrame = Timer::getNow();
434    }
435
436
[7131]437    frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE;
[7919]438    this->frameTimes[frameTimesIndex] = currentFrame - this->lastFrame;
439    this->lastFrame = currentFrame;
[7132]440    ++this->cycle;
[7919]441    this->dtS = 0.0;
[7132]442    for (i = 0; i < TICK_SMOOTH_VALUE; i++)
[7131]443      this->dtS += this->frameTimes[i];
[7919]444    this->dtS = this->dtS / TICK_SMOOTH_VALUE * speed;
[6352]445
[7131]446    // TICK everything
[7370]447    for (i = 0; i < this->dataTank->tickLists.size(); ++i)
[9869]448      this->tick(this->dataTank->objectManager->getEntityList(this->dataTank->tickLists[i]), this->dtS);
[6352]449
[6402]450    /* update tick the rest */
[6407]451    this->dataTank->localCamera->tick(this->dtS);
[6402]452    AnimationPlayer::getInstance()->tick(this->dtS);
453    PhysicsEngine::getInstance()->tick(this->dtS);
[6352]454
[6402]455    GraphicsEngine::getInstance()->tick(this->dtS);
[7810]456    AtmosphericEngine::getInstance()->tick(this->dtS);
[7035]457
458    if( likely(this->dataTank->gameRule != NULL))
459      this->dataTank->gameRule->tick(this->dtS);
[8717]460
[6402]461  }
[6352]462}
463
464
465/**
466 *  this function gives the world a consistant state
[6402]467 *
468 * after ticking (updating the world state) this will give a constistant
469 * state to the whole system.
470 */
[6358]471void GameWorld::update()
[6352]472{
473  PNode::getNullParent()->updateNode (this->dtS);
[7460]474  OrxSound::SoundEngine::getInstance()->update();
[8740]475
476  this->applyCameraSettings();
[7871]477  GraphicsEngine::getInstance()->update(this->dtS);
[6352]478}
479
480
[6402]481/**
482 * kicks the CDEngine to detect the collisions between the object groups in the world
483 */
[8190]484void GameWorld::collisionDetection()
[6352]485{
[8490]486  // object-object collision detection
[9869]487  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
488      this->dataTank->objectManager->getEntityList(OM_GROUP_01_PROJ));
489  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
490      this->dataTank->objectManager->getEntityList(OM_GROUP_00_PROJ));
491  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
492      this->dataTank->objectManager->getEntityList(OM_GROUP_00));
[6433]493
[9869]494  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
495      this->dataTank->objectManager->getEntityList(OM_GROUP_02));
496  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_02),
497      this->dataTank->objectManager->getEntityList(OM_GROUP_01_PROJ));
[9235]498
499
[9869]500  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
501      this->dataTank->objectManager->getEntityList(OM_COMMON));
502  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
503      this->dataTank->objectManager->getEntityList(OM_COMMON));
[7083]504
[8490]505  // ground collision detection: BSP Model
[9869]506  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getEntityList(OM_GROUP_00));
507  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getEntityList(OM_GROUP_01));
[6352]508}
509
[7391]510
[8190]511void GameWorld::collisionReaction()
512{
[10013]513  CoRe::CREngine::getInstance()->handleCollisions();
[8190]514}
515
516
[10376]517
518void GameWorld::checkAI()
519{
520  AIEngine::getInstance()->tick(this->dtS);
521  //AIEngine::getInstance()->tick();
522}
523
524
[6352]525/**
[7391]526 *  check the game rules: winning conditions, etc.
527 *
528 */
529void GameWorld::checkGameRules()
530{
531  if( this->gameRules)
532    this->gameRules->tick(this->dtS);
533}
534
535
536/**
[6352]537 *  render the current frame
[6402]538 *
539 * clear all buffers and draw the world
540 */
[6358]541void GameWorld::display ()
[6352]542{
[9406]543
[9494]544  // if this server is a dedicated server the game workd does not need to be drawn
[9406]545  if( !GraphicsEngine::getInstance()->isDedicated())
546  {
[9494]547    // render the reflection texture
548    this->renderPassReflection();
549    // redner the refraction texture
550    this->renderPassRefraction();
[9406]551  }
[7785]552  // render all
553  this->renderPassAll();
554
[6352]555  // flip buffers
556  GraphicsEngine::swapBuffers();
557}
558
559
560/**
[7370]561 * @brief draws all entities in the list drawList
562 * @param drawList the List of entities to draw.
[6352]563 */
[7370]564void GameWorld::drawEntityList(const ObjectManager::EntityList& drawList) const
565{
566  ObjectManager::EntityList::const_iterator entity;
567  for (entity = drawList.begin(); entity != drawList.end(); entity++)
[10314]568  {
[7370]569    if ((*entity)->isVisible())
570      (*entity)->draw();
[10314]571
572    if( unlikely( this->showMPV))
573      (*entity)->debugDrawMountPoints();
574  }
[7370]575}
576
[7785]577
[8740]578void GameWorld::applyCameraSettings()
579{
580  this->dataTank->localCamera->apply ();
581  this->dataTank->localCamera->project ();
582  GraphicsEngine::storeMatrices();
583}
[7785]584
[8740]585
586
[7370]587/**
[7785]588 * reflection rendering for water surfaces
[7370]589 */
[7785]590void GameWorld::renderPassReflection()
[6352]591{
[9235]592  // clear buffer
[7785]593  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
[9235]594  //  glLoadIdentity();
[7785]595
596  MappedWater* mw;
597
[9869]598  for (ObjectList<MappedWater>::const_iterator it = MappedWater::objectList().begin();
599       it != MappedWater::objectList().end();
600       ++it)
[7785]601  {
[9869]602    mw =  (*it);
[7785]603
[9869]604    //camera and light
605    //this->dataTank->localCamera->apply ();
606    //this->dataTank->localCamera->project ();
[8312]607
[9869]608    LightManager::getInstance()->draw();
[8312]609
610
[9869]611    // prepare for reflection rendering
612    mw->activateReflection();
[8312]613
[9869]614    // draw everything to be included in the reflection
615    this->drawEntityList(State::getObjectManager()->getReflectionList());
616    //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
617    //         this->drawEntityList(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]));
[7785]618
[9869]619    // clean up from reflection rendering
620    mw->deactivateReflection();
[7785]621  }
622
623}
624
625
626/**
627 *  refraction rendering for water surfaces
628 */
629void GameWorld::renderPassRefraction()
[8037]630{
[9235]631  // clear buffer
[8037]632  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
[8740]633  //glLoadIdentity();
[7785]634
[8037]635  MappedWater* mw;
636
[9869]637  for (ObjectList<MappedWater>::const_iterator it = MappedWater::objectList().begin();
638       it != MappedWater::objectList().end();
639       ++it)
[8037]640  {
[9869]641    mw =  dynamic_cast<MappedWater*>(*it);
[8037]642
[9869]643    //camera and light
644    //this->dataTank->localCamera->apply ();
645    //this->dataTank->localCamera->project ();
646    // prepare for reflection rendering
647    mw->activateRefraction();
[8037]648
[8312]649
[9869]650    LightManager::getInstance()->draw();
651    // draw everything to be included in the reflection
652    this->drawEntityList(State::getObjectManager()->getReflectionList());
653    //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
654    //         this->drawEntityList(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]));
[8037]655
[9869]656    // clean up from reflection rendering
657    mw->deactivateRefraction();
[8037]658  }
659}
660
661
[7785]662/**
663 *  this render pass renders the whole wolrd
664 */
665void GameWorld::renderPassAll()
666{
667  // clear buffer
668  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
[6352]669  GraphicsEngine* engine = GraphicsEngine::getInstance();
[6402]670
[7919]671
[8740]672  // glEnable(GL_DEPTH_TEST);
673  // glEnable(GL_LIGHTING);
[7919]674
[8740]675  // set Lighting
[7108]676  LightManager::getInstance()->draw();
[6416]677
[9406]678  // only render the world if its not dedicated mode
679  if( !GraphicsEngine::getInstance()->isDedicated())
680  {
681    /* Draw the BackGround */
[9869]682    this->drawEntityList(State::getObjectManager()->getEntityList(OM_BACKGROUND));
[9406]683    engine->drawBackgroundElements();
[7840]684
[9406]685    /* draw all WorldEntiy groups */
686    for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
[9869]687      this->drawEntityList(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]));
[6416]688
[9406]689    AtmosphericEngine::getInstance()->draw();
[8408]690
[9406]691    if( unlikely( this->showBV))
692    {
693      CDEngine* engine = CDEngine::getInstance();
694      for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
[9869]695        engine->drawBV(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]), this->showBVLevel);
[9406]696    }
697
[10314]698
[9406]699    if( unlikely(this->showPNodes))
700      PNode::getNullParent()->debugDraw(0);
701
702    // draw the game ruls
703    if( likely(this->dataTank->gameRule != NULL))
704      this->dataTank->gameRule->draw();
[6402]705  }
[6416]706
[6780]707  engine->draw();
[6352]708}
709
[7785]710
[6352]711/**
[6402]712 *  shows the loading screen
713 */
714void GameWorld::displayLoadScreen ()
[6387]715{
[6402]716  PRINTF(3)("GameWorld::displayLoadScreen - start\n");
[6407]717  this->dataTank->glmis = new GLMenuImageScreen();
718  this->dataTank->glmis->setMaximum(8);
[6402]719  PRINTF(3)("GameWorld::displayLoadScreen - end\n");
[6387]720}
721
722
[6402]723/**
724 *  removes the loadscreen, and changes over to the game
725 */
[9869]726void GameWorld::releaseLoadScreen()
[6387]727{
[6402]728  PRINTF(3)("GameWorld::releaseLoadScreen - start\n");
[6407]729  this->dataTank->glmis->setValue(this->dataTank->glmis->getMaximum());
[6402]730  PRINTF(3)("GameWorld::releaseLoadScreen - end\n");
[6387]731}
732
[7004]733
734
735/**
736 * @brief toggles the PNode visibility in the world (drawn as boxes)
737 */
738void GameWorld::togglePNodeVisibility()
739{
[7723]740  this->showPNodes = !this->showPNodes;
[7004]741};
742
743
744/**
745 * @brief toggles the bounding volume (BV) visibility
746*/
[7739]747void GameWorld::toggleBVVisibility(int level)
[7004]748{
[7739]749  if( level < 1)
750    this->showBV = false;
751  else
752  {
753    this->showBV = true;
754    this->showBVLevel = level;
755  }
756
[7004]757};
758
Note: See TracBrowser for help on using the repository browser.