Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cleanup/src/story_entities/game_world.cc @ 10591

Last change on this file since 10591 was 10591, checked in by bensch, 17 years ago

moved the we's to a more senseable location.

File size: 19.3 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"
[10591]29#include "tools/camera.h"
30#include "tools/cameraman.h"
31#include "environments/environment.h"
32#include "environments/terrain.h"
[6404]33#include "playable.h"
[7785]34#include "environments/mapped_water.h"
[6404]35
[6352]36#include "light.h"
[6404]37
[7193]38#include "util/loading/factory.h"
[9869]39#include "util/loading/load_param_xml.h"
40#include "loading/fast_factory.h"
[6404]41#include "shell_command.h"
[6352]42
43#include "graphics_engine.h"
[9869]44#include "weather_effects/atmospheric_engine.h"
[6404]45#include "event_handler.h"
46#include "sound_engine.h"
47#include "cd_engine.h"
48#include "network_manager.h"
[6352]49#include "physics_engine.h"
50
51#include "glmenu_imagescreen.h"
[6404]52#include "shell.h"
[6352]53
54#include "ogg_player.h"
[6404]55#include "shader.h"
[10376]56#include "ai_engine.h"
[6352]57
[7369]58#include "animation_player.h"
59
[7035]60#include "game_rules.h"
[6352]61
[9110]62#include "script_class.h"
[9869]63ObjectListDefinition(GameWorld);
64CREATE_SCRIPTABLE_CLASS(GameWorld,
65                        addMethod("setPlaymode", Executor1<GameWorld, lua_State*,const std::string&>(&GameWorld::setPlaymode))
[10430]66                        ->addMethod("showText", Executor1<GameWorld, lua_State*, const std::string&>(&GameWorld::showText))
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
[8271]194  LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams);
195
[7287]196  delete XMLDoc;
[6386]197  this->releaseLoadScreen();
[8717]198
199  return ErrorMessage();
[6352]200}
201
202
203/**
[6387]204 *  unload the data of this GameWorld
205 */
206ErrorMessage GameWorld::unloadData()
207{
[8271]208
[7287]209  PRINTF(3)("GameWorld::~GameWorld() - unloading the current GameWorld\n");
[8271]210  this->scriptManager.flush();
211
[7370]212  delete this->shell;
[6387]213
[6981]214  this->dataTank->unloadData();
215
[7369]216  this->shell = NULL;
217  delete AnimationPlayer::getInstance();
218  delete PhysicsEngine::getInstance();
[10013]219  delete CoRe::CREngine::getInstance();
[7369]220
[6988]221  State::setCurrentStoryEntity(NULL);
[6845]222  if (this->dataXML)
223    delete this->dataXML;
[8717]224
225  return ErrorMessage();
[6387]226}
227
228
[9235]229void GameWorld::setSoundtrack(const std::string& soundTrack)
230{
231  if (this->dataTank != NULL)
232  {
233    this->dataTank->setSoundTrack(soundTrack);
234    this->dataTank->music->play();
235  }
236}
237
[10428]238void GameWorld::showText(const std::string& text)
239{
[10430]240  if ( this->dataTank->localPlayer != NULL)
[10428]241    this->dataTank->localPlayer->hud().notifyUser(text);
242}
[9235]243
[10428]244
[6387]245/**
[6358]246 *  starts the GameWorld
[6352]247 */
[6387]248bool GameWorld::start()
[6352]249{
[7283]250  this->bPaused = false;
251  this->bRunning = true;
[8408]252  State::setScriptManager(&this->scriptManager); //make sure we have the right script manager
[6387]253  this->run();
[8717]254
255  return true;
[6352]256}
257
[6402]258
[6352]259/**
260 *  stops the world.
[6402]261 */
[6387]262bool GameWorld::stop()
[6352]263{
[6358]264  PRINTF(3)("GameWorld::stop() - got stop signal\n");
[8408]265  State::setScriptManager(NULL);
[8717]266  return (this->bRunning = false);
[6352]267}
268
[6402]269
[6352]270/**
[6402]271 *  pauses the game
272 */
[6387]273bool GameWorld::pause()
[6352]274{
[8717]275  return (this->bPaused = true);
[6352]276}
277
[6402]278
[6352]279/**
280 *  ends the pause Phase
[6409]281 */
[6387]282bool GameWorld::resume()
[6352]283{
[8717]284  return(this->bPaused = false);
[6352]285}
286
287
288/**
[6402]289 *  main loop of the world: executing all world relevant function
290 *
291 * in this loop we synchronize (if networked), handle input events, give the heart-beat to
292 * all other member-entities of the world (tick to player, enemies etc.), checking for
293 * collisions drawing everything to the screen.
294 */
295void GameWorld::run()
[6352]296{
[6402]297  PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n");
[6352]298
[7131]299  // initialize Timing
300  this->cycle = 0;
301  for (unsigned int i = 0; i < TICK_SMOOTH_VALUE; i++)
[7919]302    this->frameTimes[i] = 0.01f;
[7131]303  this->dtS = 0.0f;
[7919]304  this->lastFrame = Timer::getNow();
[7131]305
[7304]306  if (this->dataTank->music != NULL)
307    this->dataTank->music->play();
308
[10319]309  PNode::getNullParent()->updateNode(0.01);
310  PNode::getNullParent()->updateNode(0.01);
311
[10340]312  bool bNoDraw = true;
[10319]313
[7283]314  while( this->bRunning) /* @todo implement pause */
[6402]315  {
316    /* process intput */
317    this->handleInput ();
[7322]318    if( !this->bRunning)
319      break;
[6386]320
[6402]321    /* network synchronisation */
322    this->synchronize ();
[10515]323
324         /* perform ai check*/
325         this->checkAI();
326
327         this->update ();
[6402]328    /* process time */
329    this->tick ();
[8490]330
[8740]331
[8724]332    /* update the state */
[8740]333    //this->update (); /// LESS REDUNDANCY.
[9235]334    //      PNode::getNullParent()->updateNode(this->dtS);
[9061]335    PNode::getNullParent()->updateNode(this->dtS);
[8724]336
[8190]337    /* collision detection */
338    this->collisionDetection ();
339    /* collision reaction */
340    this->collisionReaction ();
[8490]341
[8724]342    /* check the game rules */
343    this->checkGameRules();
[8740]344
[6402]345    /* update the state */
346    this->update ();
347    /* draw everything */
[10340]348    if( bNoDraw)
349      this->display ();
[7306]350
[10340]351    bNoDraw= !bNoDraw;
[6402]352  }
353
[9869]354  PRINTF(4)("GameWorld::mainLoop() - Exiting the main loop\n");
[6352]355}
356
357
[7338]358void GameWorld::setPlaymode(Playable::Playmode playmode)
359{
360  if (this->dataTank->localPlayer &&
361      this->dataTank->localPlayer->getPlayable() &&
[7339]362      this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode))
[7338]363  {
[10368]364    PRINTF(0)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
[7338]365  }
[7339]366  else
367  {
[10368]368    PRINTF(0)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
[7339]369  }
[7338]370}
371
[7339]372void GameWorld::setPlaymode(const std::string& playmode)
373{
374  this->setPlaymode(Playable::stringToPlaymode(playmode));
375}
[7338]376
[6352]377/**
378 *  synchronize local data with remote data
379*/
[6358]380void GameWorld::synchronize ()
[6402]381{}
[6352]382
383
384/**
385 *  run all input processing
386
387   the command node is the central input event dispatcher. the node uses the even-queue from
388   sdl and has its own event-passing-queue.
389*/
[6358]390void GameWorld::handleInput ()
[6352]391{
392  EventHandler::getInstance()->process();
393}
394
[6402]395
396/**
[7370]397 * @brief ticks a WorldEntity list
[6402]398 * @param entityList list of the WorldEntities
399 * @param dt time passed since last frame
400 */
[7370]401void GameWorld::tick(ObjectManager::EntityList entityList, float dt)
[6352]402{
[7370]403  ObjectManager::EntityList::iterator entity, next;
[6710]404  next = entityList.begin();
405  while (next != entityList.end())
406  {
407    entity = next++;
[6352]408    (*entity)->tick(dt);
[6710]409  }
[6352]410}
411
[7131]412
[6352]413/**
414 *  advance the timeline
[6402]415 *
416 * this calculates the time used to process one frame (with all input handling, drawing, etc)
417 * the time is mesured in ms and passed to all world-entities and other classes that need
418 * a heart-beat.
419 */
[6358]420void GameWorld::tick ()
[6352]421{
[7283]422  if( !this->bPaused)
[6402]423  {
[7131]424    // CALCULATE FRAMERATE
425    Uint32 frameTimesIndex;
426    Uint32 i;
[7919]427    double currentFrame = Timer::getNow();
[6402]428
[9494]429    if (currentFrame - this->lastFrame < .01)
430    {
[9869]431      SDL_Delay((int)(1000.0 * (0.01 - (currentFrame - lastFrame))));
[9494]432      currentFrame = Timer::getNow();
433    }
434
435
[7131]436    frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE;
[7919]437    this->frameTimes[frameTimesIndex] = currentFrame - this->lastFrame;
438    this->lastFrame = currentFrame;
[7132]439    ++this->cycle;
[7919]440    this->dtS = 0.0;
[7132]441    for (i = 0; i < TICK_SMOOTH_VALUE; i++)
[7131]442      this->dtS += this->frameTimes[i];
[7919]443    this->dtS = this->dtS / TICK_SMOOTH_VALUE * speed;
[6352]444
[10456]445    // tick camera first
[10473]446    CameraMan* man = State::getCameraman();
447    (man->getCurrentCam())->tick(this->dtS);
[7131]448    // TICK everything
[7370]449    for (i = 0; i < this->dataTank->tickLists.size(); ++i)
[9869]450      this->tick(this->dataTank->objectManager->getEntityList(this->dataTank->tickLists[i]), this->dtS);
[6352]451
[6402]452    /* update tick the rest */
[10456]453
[6402]454    AnimationPlayer::getInstance()->tick(this->dtS);
455    PhysicsEngine::getInstance()->tick(this->dtS);
[6352]456
[6402]457    GraphicsEngine::getInstance()->tick(this->dtS);
[7810]458    AtmosphericEngine::getInstance()->tick(this->dtS);
[7035]459
460    if( likely(this->dataTank->gameRule != NULL))
461      this->dataTank->gameRule->tick(this->dtS);
[8717]462
[6402]463  }
[6352]464}
465
466
467/**
468 *  this function gives the world a consistant state
[6402]469 *
470 * after ticking (updating the world state) this will give a constistant
471 * state to the whole system.
472 */
[6358]473void GameWorld::update()
[6352]474{
475  PNode::getNullParent()->updateNode (this->dtS);
[7460]476  OrxSound::SoundEngine::getInstance()->update();
[8740]477
478  this->applyCameraSettings();
[7871]479  GraphicsEngine::getInstance()->update(this->dtS);
[6352]480}
481
482
[6402]483/**
484 * kicks the CDEngine to detect the collisions between the object groups in the world
485 */
[8190]486void GameWorld::collisionDetection()
[6352]487{
[8490]488  // object-object collision detection
[9869]489  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
490      this->dataTank->objectManager->getEntityList(OM_GROUP_01_PROJ));
491  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
492      this->dataTank->objectManager->getEntityList(OM_GROUP_00_PROJ));
493  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
494      this->dataTank->objectManager->getEntityList(OM_GROUP_00));
[6433]495
[9869]496  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
497      this->dataTank->objectManager->getEntityList(OM_GROUP_02));
498  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_02),
499      this->dataTank->objectManager->getEntityList(OM_GROUP_01_PROJ));
[9235]500
501
[9869]502  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
503      this->dataTank->objectManager->getEntityList(OM_COMMON));
504  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
505      this->dataTank->objectManager->getEntityList(OM_COMMON));
[7083]506
[8490]507  // ground collision detection: BSP Model
[9869]508  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getEntityList(OM_GROUP_00));
509  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getEntityList(OM_GROUP_01));
[6352]510}
511
[7391]512
[8190]513void GameWorld::collisionReaction()
514{
[10013]515  CoRe::CREngine::getInstance()->handleCollisions();
[8190]516}
517
518
[10376]519
520void GameWorld::checkAI()
521{
522  AIEngine::getInstance()->tick(this->dtS);
523  //AIEngine::getInstance()->tick();
524}
525
526
[6352]527/**
[7391]528 *  check the game rules: winning conditions, etc.
529 *
530 */
531void GameWorld::checkGameRules()
532{
533  if( this->gameRules)
534    this->gameRules->tick(this->dtS);
535}
536
537
538/**
[6352]539 *  render the current frame
[6402]540 *
541 * clear all buffers and draw the world
542 */
[6358]543void GameWorld::display ()
[6352]544{
[9406]545
[9494]546  // if this server is a dedicated server the game workd does not need to be drawn
[9406]547  if( !GraphicsEngine::getInstance()->isDedicated())
548  {
[9494]549    // render the reflection texture
550    this->renderPassReflection();
551    // redner the refraction texture
552    this->renderPassRefraction();
[9406]553  }
[7785]554  // render all
555  this->renderPassAll();
556
[6352]557  // flip buffers
558  GraphicsEngine::swapBuffers();
559}
560
561
562/**
[7370]563 * @brief draws all entities in the list drawList
564 * @param drawList the List of entities to draw.
[6352]565 */
[7370]566void GameWorld::drawEntityList(const ObjectManager::EntityList& drawList) const
567{
568  ObjectManager::EntityList::const_iterator entity;
569  for (entity = drawList.begin(); entity != drawList.end(); entity++)
[10314]570  {
[7370]571    if ((*entity)->isVisible())
572      (*entity)->draw();
[10314]573
574    if( unlikely( this->showMPV))
575      (*entity)->debugDrawMountPoints();
576  }
[7370]577}
578
[7785]579
[8740]580void GameWorld::applyCameraSettings()
581{
[10473]582  CameraMan* man = State::getCameraman();
[10523]583  Camera* c = man->getCurrentCam();
584  if( c != NULL)
585  {
586    c->apply ();
587    c->project ();
588  }
[8740]589  GraphicsEngine::storeMatrices();
590}
[7785]591
[8740]592
593
[7370]594/**
[7785]595 * reflection rendering for water surfaces
[7370]596 */
[7785]597void GameWorld::renderPassReflection()
[6352]598{
[9235]599  // clear buffer
[7785]600  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
[9235]601  //  glLoadIdentity();
[7785]602
603  MappedWater* mw;
604
[9869]605  for (ObjectList<MappedWater>::const_iterator it = MappedWater::objectList().begin();
606       it != MappedWater::objectList().end();
607       ++it)
[7785]608  {
[9869]609    mw =  (*it);
[7785]610
[9869]611    //camera and light
612    //this->dataTank->localCamera->apply ();
613    //this->dataTank->localCamera->project ();
[8312]614
[9869]615    LightManager::getInstance()->draw();
[8312]616
617
[9869]618    // prepare for reflection rendering
619    mw->activateReflection();
[8312]620
[9869]621    // draw everything to be included in the reflection
622    this->drawEntityList(State::getObjectManager()->getReflectionList());
623    //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
624    //         this->drawEntityList(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]));
[7785]625
[9869]626    // clean up from reflection rendering
627    mw->deactivateReflection();
[7785]628  }
629
630}
631
632
633/**
634 *  refraction rendering for water surfaces
635 */
636void GameWorld::renderPassRefraction()
[8037]637{
[9235]638  // clear buffer
[8037]639  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
[8740]640  //glLoadIdentity();
[7785]641
[8037]642  MappedWater* mw;
643
[9869]644  for (ObjectList<MappedWater>::const_iterator it = MappedWater::objectList().begin();
645       it != MappedWater::objectList().end();
646       ++it)
[8037]647  {
[9869]648    mw =  dynamic_cast<MappedWater*>(*it);
[8037]649
[9869]650    //camera and light
651    //this->dataTank->localCamera->apply ();
652    //this->dataTank->localCamera->project ();
653    // prepare for reflection rendering
654    mw->activateRefraction();
[8037]655
[8312]656
[9869]657    LightManager::getInstance()->draw();
658    // draw everything to be included in the reflection
659    this->drawEntityList(State::getObjectManager()->getReflectionList());
660    //       for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
661    //         this->drawEntityList(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]));
[8037]662
[9869]663    // clean up from reflection rendering
664    mw->deactivateRefraction();
[8037]665  }
666}
667
668
[7785]669/**
670 *  this render pass renders the whole wolrd
671 */
672void GameWorld::renderPassAll()
673{
674  // clear buffer
675  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
[6352]676  GraphicsEngine* engine = GraphicsEngine::getInstance();
[6402]677
[7919]678
[8740]679  // glEnable(GL_DEPTH_TEST);
680  // glEnable(GL_LIGHTING);
[7919]681
[8740]682  // set Lighting
[7108]683  LightManager::getInstance()->draw();
[6416]684
[9406]685  // only render the world if its not dedicated mode
686  if( !GraphicsEngine::getInstance()->isDedicated())
687  {
688    /* Draw the BackGround */
[9869]689    this->drawEntityList(State::getObjectManager()->getEntityList(OM_BACKGROUND));
[9406]690    engine->drawBackgroundElements();
[7840]691
[9406]692    /* draw all WorldEntiy groups */
693    for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
[9869]694      this->drawEntityList(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]));
[6416]695
[9406]696    AtmosphericEngine::getInstance()->draw();
[8408]697
[9406]698    if( unlikely( this->showBV))
699    {
700      CDEngine* engine = CDEngine::getInstance();
701      for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
[9869]702        engine->drawBV(State::getObjectManager()->getEntityList(this->dataTank->drawLists[i]), this->showBVLevel);
[9406]703    }
704
[10314]705
[9406]706    if( unlikely(this->showPNodes))
707      PNode::getNullParent()->debugDraw(0);
708
709    // draw the game ruls
710    if( likely(this->dataTank->gameRule != NULL))
711      this->dataTank->gameRule->draw();
[6402]712  }
[6416]713
[6780]714  engine->draw();
[6352]715}
716
[7785]717
[6352]718/**
[6402]719 *  shows the loading screen
720 */
721void GameWorld::displayLoadScreen ()
[6387]722{
[6402]723  PRINTF(3)("GameWorld::displayLoadScreen - start\n");
[6407]724  this->dataTank->glmis = new GLMenuImageScreen();
725  this->dataTank->glmis->setMaximum(8);
[6402]726  PRINTF(3)("GameWorld::displayLoadScreen - end\n");
[6387]727}
728
729
[6402]730/**
731 *  removes the loadscreen, and changes over to the game
732 */
[9869]733void GameWorld::releaseLoadScreen()
[6387]734{
[6402]735  PRINTF(3)("GameWorld::releaseLoadScreen - start\n");
[6407]736  this->dataTank->glmis->setValue(this->dataTank->glmis->getMaximum());
[6402]737  PRINTF(3)("GameWorld::releaseLoadScreen - end\n");
[6387]738}
739
[7004]740
741
742/**
743 * @brief toggles the PNode visibility in the world (drawn as boxes)
744 */
745void GameWorld::togglePNodeVisibility()
746{
[7723]747  this->showPNodes = !this->showPNodes;
[7004]748};
749
750
751/**
752 * @brief toggles the bounding volume (BV) visibility
753*/
[7739]754void GameWorld::toggleBVVisibility(int level)
[7004]755{
[7739]756  if( level < 1)
757    this->showBV = false;
758  else
759  {
760    this->showBV = true;
761    this->showBVLevel = level;
762  }
763
[7004]764};
765
Note: See TracBrowser for help on using the repository browser.