Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/story_entities/world.cc @ 3660

Last change on this file since 3660 was 3660, checked in by bensch, 19 years ago

orxonox/trunk: now ResourceManager has the ability to unload resources by priority

File size: 21.6 KB
Line 
1
2/*
3   orxonox - the future of 3D-vertical-scrollers
4
5   Copyright (C) 2004 orx
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2, or (at your option)
10   any later version.
11
12   ### File Specific:
13   main-programmer: Patrick Boenzli
14   co-programmer: Christian Meyer
15*/
16
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
18
19#include "world.h"
20
21#include "orxonox.h"
22
23#include "p_node.h"
24#include "null_parent.h"
25#include "helper_parent.h"
26#include "track_node.h"
27#include "world_entity.h"
28#include "player.h"
29#include "camera.h"
30#include "environment.h"
31#include "primitive.h"
32#include "skysphere.h"
33#include "terrain.h"
34#include "light.h"
35
36#include "track_manager.h"
37#include "garbage_collector.h"
38
39#include "command_node.h"
40#include "glmenu_imagescreen.h"
41#include "fontset.h"
42#include "list.h"
43
44
45
46using namespace std;
47
48
49WorldInterface* WorldInterface::singletonRef = 0;
50
51
52/**
53   \brief private constructor because of singleton
54*/
55WorldInterface::WorldInterface()
56{
57  this->worldIsInitialized = false;
58  this->worldReference = NULL;
59}
60
61/**
62   \brief public deconstructor
63*/
64WorldInterface::~WorldInterface()
65{
66  this->singletonRef = NULL;
67  this->worldIsInitialized = false;
68  this->worldReference = NULL;
69}
70
71/**
72   \brief gets the singleton instance
73   \returns singleton instance
74*/
75WorldInterface* WorldInterface::getInstance()
76{
77  if( singletonRef == NULL)
78    singletonRef = new WorldInterface();
79  return singletonRef;
80}
81
82
83/**
84   \brief initializes the interface
85   \param reference to the world
86
87   if the worldinterface is not initilizes, there wont be any
88   useable interface
89*/
90void WorldInterface::init(World* world)
91{
92  this->worldReference = world;
93  if( world != NULL)
94    {
95      this->worldIsInitialized = true;
96      PRINTF(3)("WorldInterface up and running\n");
97    }
98}
99
100
101/**
102   \brief gets the entity list from the world
103   \return entity list
104*/
105tList<WorldEntity>* WorldInterface::getEntityList()
106{
107  if( this->worldIsInitialized)
108    return this->worldReference->getEntities();
109  PRINT(1)("Someone tried to use the WorldInterface before it has been initizlized! this can result in SEGFAULTs!\n");
110  return NULL;
111}
112
113
114
115/**
116    \brief create a new World
117   
118    This creates a new empty world!
119*/
120World::World (char* name)
121{
122  this->init(name, -1);
123  //NullParent* np = NullParent::getInstance();
124}
125
126/**
127   \brief creates a new World...
128   \param worldID with this ID
129*/
130World::World (int worldID)
131{
132  this->init(NULL, worldID);
133}
134
135/**
136    \brief remove the World from memory
137   
138    delete everything explicitly, that isn't contained in the parenting tree!
139    things contained in the tree are deleted automaticaly
140*/
141World::~World ()
142{
143  PRINTF(3)("World::~World() - deleting current world\n");
144  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
145  cn->unbind(this->localPlayer);
146  cn->reset();
147
148  ResourceManager::unloadAllByPriority(RP_LEVEL);
149
150  delete WorldInterface::getInstance();
151
152  delete this->nullParent;
153  delete this->entities;
154  delete this->lightMan;
155  delete this->trackManager;
156}
157
158/**
159   \brief initializes the world.
160
161   set all stuff here that is world generic and does not use to much memory
162   because the real init() function StoryEntity::init() will be called
163   shortly before start of the game. 
164   since all worlds are initiated/referenced before they will be started.
165   NO LEVEL LOADING HERE - NEVER!
166*/
167void World::init(char* name, int worldID)
168{
169  this->setClassName ("World");
170
171  this->worldName = name;
172  this->debugWorldNr = worldID;
173  this->entities = new tList<WorldEntity>();
174}
175
176
177/**
178   \brief this is executed before load
179
180   since the load function sometimes needs data, that has been init before
181   the load and after the proceeding storyentity has finished
182*/
183ErrorMessage World::preLoad()
184{
185  /* init the world interface */
186  WorldInterface* wi = WorldInterface::getInstance();
187  wi->init(this);
188  this->garbageCollector = GarbageCollector::getInstance();
189}
190
191
192/**
193   \brief loads the World by initializing all resources, and set their default values.
194*/
195ErrorMessage World::load()
196{
197  //  BezierCurve* tmpCurve = new BezierCurve();
198  if(this->debugWorldNr != -1)
199    {
200      // initializing Font
201      testFont = new FontSet();
202      testFont->buildFont("../data/pictures/font.tga");
203
204      // initializing the TrackManager
205      trackManager = TrackManager::getInstance();
206      trackManager->addPoint(Vector(0,0,0));
207      trackManager->addPoint(Vector(100, -40, 5));
208      trackManager->addPoint(Vector(200,-40,-8));
209      trackManager->addPoint(Vector(250, -35, -2));
210      trackManager->addPoint(Vector(320,-33,-.55));
211      trackManager->setDuration(3);
212      trackManager->setSavePoint();
213      trackManager->addPoint(Vector(410, 0, 0));
214      trackManager->addPoint(Vector(510, 20, -10));
215      trackManager->addPoint(Vector(550, 20, -10));
216      trackManager->addPoint(Vector(570, 20, -10));
217      trackManager->setDuration(5);
218     
219      int fork11, fork12;
220      trackManager->fork(2, &fork11, &fork12);
221      trackManager->workOn(fork11);
222      trackManager->addPoint(Vector(640, 25, -30));
223      trackManager->addPoint(Vector(700, 40, -120));
224      trackManager->addPoint(Vector(800, 50, -150));
225      trackManager->addPoint(Vector(900, 60, -100));
226      trackManager->addPoint(Vector(900, 60, -70));
227      trackManager->addPoint(Vector(990, 65, -15));
228      trackManager->addPoint(Vector(1050, 65, -10));
229      trackManager->addPoint(Vector(1100, 65, -20));
230      trackManager->setDuration(10);
231
232      trackManager->workOn(fork12);
233      trackManager->addPoint(Vector(640, 25, 20));
234      trackManager->addPoint(Vector(670, 50, 120));
235      trackManager->addPoint(Vector(700, 70, 80));
236      trackManager->addPoint(Vector(800, 70, 65));
237      trackManager->addPoint(Vector(850, 65, 65));
238      trackManager->addPoint(Vector(920, 35, 40));
239      trackManager->addPoint(Vector(945, 40, 40));
240      trackManager->addPoint(Vector(970, 24, 40));
241      trackManager->addPoint(Vector(1000, 40, -7));
242      trackManager->setDuration(10);
243     
244
245      trackManager->join(2, fork11, fork12);
246
247      trackManager->workOn(5);
248      trackManager->addPoint(Vector(1200, 60, -50));
249      trackManager->addPoint(Vector(1300, 50, -50));
250      trackManager->addPoint(Vector(1400, 40, -50));
251      trackManager->addPoint(Vector(1500, 40, -60));
252      trackManager->addPoint(Vector(1600, 35, -55));
253      trackManager->addPoint(Vector(1700, 45, -40));
254      trackManager->addPoint(Vector(1750, 60, -40));
255      trackManager->addPoint(Vector(1770, 80, -40));
256      trackManager->addPoint(Vector(1800, 100, -40));
257      trackManager->setDuration(10);
258
259      trackManager->finalize();
260
261     
262      /*monitor progress*/
263      this->glmis->step();
264
265      // LIGHT initialisation
266      lightMan = LightManager::getInstance();
267      lightMan->setAmbientColor(.1,.1,.1);
268      lightMan->addLight();
269      //      lightMan->setAttenuation(1.0, .01, 0.0);
270      //      lightMan->setDiffuseColor(1,1,1);
271      //  lightMan->addLight(1);
272      //  lightMan->setPosition(20, 10, -20);
273      //  lightMan->setDiffuseColor(0,0,0);
274      lightMan->debug();
275
276      switch(this->debugWorldNr)
277        {
278          /*
279            this loads the hard-coded debug world. this only for simplicity and will be
280            removed by a reald world-loader, which interprets a world-file.
281            if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
282            make whatever you want...
283           */
284        case DEBUG_WORLD_0:
285          {
286            lightMan->setPosition(-5.0, 10.0, -40.0);
287            this->nullParent = NullParent::getInstance ();
288            this->nullParent->setName ("NullParent");
289
290            // !\todo old track-system has to be removed
291
292            //create helper for player
293            //HelperParent* hp = new HelperParent ();
294            /* the player has to be added to this helper */
295
296            // create a player
297            this->localPlayer = new Player ();
298            this->localPlayer->setName ("player");
299            this->spawn (this->localPlayer);
300            /*monitor progress*/
301            this->glmis->step();           
302
303            // bind input
304            Orxonox *orx = Orxonox::getInstance ();
305            orx->getLocalInput()->bind (this->localPlayer);
306           
307            // bind camera
308            this->localCamera = new Camera();
309            this->localCamera->setName ("camera");
310            this->localCamera->lookAt(this->localPlayer);
311            this->localCamera->setParent(this->localPlayer);
312           
313            /*monitor progress*/
314            this->glmis->step();           
315
316            // Create SkySphere
317            this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
318            this->skySphere->setName("SkySphere");
319            this->localCamera->addChild(this->skySphere);
320            this->skySphere->setMode(PNODE_MOVEMENT);
321
322            /*monitor progress*/
323            this->glmis->step();
324
325           
326            WorldEntity* env = new Environment();
327            env->setName ("env");
328            this->spawn(env);
329
330           
331            Vector* es = new Vector (10, 5, 0);
332            Quaternion* qs = new Quaternion ();
333            WorldEntity* pr = new Primitive(P_CYLINDER);
334            pr->setName("primitive");
335            this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
336           
337
338            /*monitor progress*/
339            this->glmis->step();
340
341            //      trackManager->setBindSlave(env);
342            PNode* tn = trackManager->getTrackNode();
343            tn->addChild(this->localPlayer);
344
345            //localCamera->setParent(TrackNode::getInstance());
346            tn->addChild(this->localCamera);
347            //      localCamera->lookAt(tn);
348            this->localPlayer->setMode(PNODE_ALL);
349            //Vector* cameraOffset = new Vector (0, 5, -10);
350            trackManager->condition(2, LEFTRIGHT, this->localPlayer);
351
352            break;
353          }
354        case DEBUG_WORLD_1:
355          {
356            lightMan->setPosition(.0, .0, .0);
357            lightMan->setAttenuation(1.0, .01, 0.0);
358            lightMan->setSpecularColor(1,0,0);
359            this->nullParent = NullParent::getInstance ();
360            this->nullParent->setName ("NullParent");
361
362            // create a player
363            WorldEntity* myPlayer = new Player();
364            myPlayer->setName ("player");
365            this->spawn(myPlayer);
366            this->localPlayer = myPlayer;           
367           
368            // bind input
369            Orxonox *orx = Orxonox::getInstance();
370            orx->getLocalInput()->bind (myPlayer);
371           
372            // bind camera
373            this->localCamera = new Camera ();
374            this->localCamera->setName ("camera");
375            this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
376            this->localCamera->setParent(this->localPlayer);
377
378            // Create SkySphere
379            skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
380            this->localPlayer->addChild(this->skySphere);
381
382            Vector* es = new Vector (20, 0, 0);
383            Quaternion* qs = new Quaternion ();
384            WorldEntity* pr = new Primitive(P_SPHERE);
385            pr->setName("primitive");
386            this->spawn(pr, this->localPlayer, es, qs, PNODE_ROTATE_AND_MOVE);
387
388            lightMan->getLight(0)->setParent(trackManager->getTrackNode());
389            break;
390          }
391        default:
392          printf("World::load() - no world with ID %i found", this->debugWorldNr );
393        }
394    }
395  else if(this->worldName != NULL)
396    {
397
398    }
399
400  // initialize debug coord system
401  objectList = glGenLists(1);
402  glNewList (objectList, GL_COMPILE);
403 
404  trackManager->drawGraph(.01);
405  trackManager->debug(2);
406  glEndList();
407
408  terrain = new Terrain("../data/worlds/newGround.obj");
409  terrain->setRelCoor(new Vector(0,-10,0));
410  this->spawn(terrain);
411
412}
413
414
415/**
416   \brief initializes a new World shortly before start
417
418   this is the function, that will be loaded shortly before the world is
419   started
420*/
421ErrorMessage World::init()
422{
423  this->bPause = false;
424  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
425  cn->addToWorld(this);
426  cn->enable(true);
427}
428
429
430/**
431   \brief starts the World
432*/
433ErrorMessage World::start()
434{
435  PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
436  this->bQuitOrxonox = false;
437  this->bQuitCurrentGame = false;
438  this->mainLoop();
439}
440
441/**
442   \brief stops the world.
443
444   This happens, when the player decides to end the Level.
445*/
446ErrorMessage World::stop()
447{
448  PRINTF(3)("World::stop() - got stop signal\n");
449  this->bQuitCurrentGame = true;
450}
451
452/**
453   \brief pauses the Game
454*/
455ErrorMessage World::pause()
456{
457  this->isPaused = true;
458}
459
460/**
461   \brief ends the pause Phase
462*/
463ErrorMessage World::resume()
464{
465  this->isPaused = false;
466}
467
468/**
469   \brief destroys the World
470*/
471ErrorMessage World::destroy()
472{
473
474}
475
476/**
477   \brief shows the loading screen
478*/
479void World::displayLoadScreen ()
480{
481  PRINTF(3)("World::displayLoadScreen - start\n"); 
482 
483  //GLMenuImageScreen*
484  this->glmis = GLMenuImageScreen::getInstance();
485  this->glmis->init();
486  this->glmis->setMaximum(10);
487  this->glmis->draw();
488 
489  PRINTF(3)("World::displayLoadScreen - end\n"); 
490}
491
492/**
493   \brief removes the loadscreen, and changes over to the game
494
495   \todo take out the delay
496*/
497void World::releaseLoadScreen ()
498{
499  PRINTF(3)("World::releaseLoadScreen - start\n"); 
500  this->glmis->setValue(this->glmis->getMaximum());
501  SDL_Delay(500);
502  PRINTF(3)("World::releaseLoadScreen - end\n"); 
503}
504
505
506/**
507   \brief gets the list of entities from the world
508   \returns entity list
509*/
510tList<WorldEntity>* World::getEntities()
511{
512  return this->entities;
513}
514
515
516/**
517   \brief this returns the current game time
518   \returns elapsed game time
519*/
520double World::getGameTime()
521{
522  return this->gameTime;
523}
524
525
526/**
527    \brief checks for collisions
528   
529    This method runs through all WorldEntities known to the world and checks for collisions
530    between them. In case of collisions the collide() method of the corresponding entities
531    is called.
532*/
533void World::collide ()
534{
535  /*
536  List *a, *b;
537  WorldEntity *aobj, *bobj;
538   
539  a = entities;
540 
541  while( a != NULL)
542    {
543      aobj = a->nextElement();
544      if( aobj->bCollide && aobj->collisioncluster != NULL)
545        {
546          b = a->nextElement();
547          while( b != NULL )
548            {
549              bobj = b->nextElement();
550              if( bobj->bCollide && bobj->collisioncluster != NULL )
551                {
552                  unsigned long ahitflg, bhitflg;
553                  if( check_collision ( &aobj->place, aobj->collisioncluster,
554                                        &ahitflg, &bobj->place, bobj->collisioncluster,
555                                        &bhitflg) );
556                  {
557                    aobj->collide (bobj, ahitflg, bhitflg);
558                    bobj->collide (aobj, bhitflg, ahitflg);
559                  }
560                }
561              b = b->nextElement();
562            }
563        }
564      a = a->enumerate();
565    }
566  */
567}
568
569/**
570    \brief runs through all entities calling their draw() methods
571*/
572void World::draw ()
573{
574  /* draw entities */
575  WorldEntity* entity;
576  glLoadIdentity();
577
578  //entity = this->entities->enumerate();
579  tIterator<WorldEntity>* iterator = this->entities->getIterator();
580  entity = iterator->nextElement();
581  while( entity != NULL ) 
582    { 
583      if( entity->bDraw ) entity->draw();
584      //entity = this->entities->nextElement();
585      entity = iterator->nextElement();
586    }
587  delete iterator;
588 
589  glCallList (objectList);
590  //! \todo skysphere is a WorldEntity and should be inside of the world-entity-list.
591  skySphere->draw();
592
593  testFont->printText(0, 0, 1, "orxonox_" PACKAGE_VERSION);
594
595  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
596}
597
598
599/**
600   \brief function to put your own debug stuff into it. it can display informations about
601   the current class/procedure
602*/
603void World::debug()
604{
605  PRINTF(2)("debug() - starting debug\n");
606  PNode* p1 = NullParent::getInstance ();
607  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
608  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
609  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
610
611  p1->debug ();
612  p2->debug ();
613  p3->debug ();
614  p4->debug ();
615
616  p1->shiftCoor (new Vector(-1, -1, -1));
617
618  printf("World::debug() - shift\n");
619  p1->debug ();
620  p2->debug ();
621  p3->debug ();
622  p4->debug ();
623 
624  p1->update (0);
625
626  printf ("World::debug() - update\n");
627  p1->debug ();
628  p2->debug ();
629  p3->debug ();
630  p4->debug ();
631
632  p2->shiftCoor (new Vector(-1, -1, -1));
633  p1->update (0);
634
635  p1->debug ();
636  p2->debug ();
637  p3->debug ();
638  p4->debug ();
639
640  p2->setAbsCoor (new Vector(1,2,3));
641
642
643 p1->update (0);
644
645  p1->debug ();
646  p2->debug ();
647  p3->debug ();
648  p4->debug ();
649
650  delete p1;
651 
652 
653  /*
654  WorldEntity* entity;
655  printf("counting all entities\n");
656  printf("World::debug() - enumerate()\n");
657  entity = entities->enumerate(); 
658  while( entity != NULL )
659    {
660      if( entity->bDraw ) printf("got an entity\n");
661      entity = entities->nextElement();
662    }
663  */
664}
665
666
667/**
668  \brief main loop of the world: executing all world relevant function
669
670  in this loop we synchronize (if networked), handle input events, give the heart-beat to
671  all other member-entities of the world (tick to player, enemies etc.), checking for
672  collisions drawing everything to the screen.
673*/
674void World::mainLoop()
675{
676  this->lastFrame = SDL_GetTicks ();
677  PRINTF(3)("World::mainLoop() - Entering main loop\n");
678  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
679    {
680      PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
681      // Network
682      this->synchronize ();
683      // Process input
684      this->handleInput ();
685      if( this->bQuitCurrentGame || this->bQuitOrxonox)
686          break;
687      // Process time
688      this->tick ();
689      // Update the state
690      this->update ();     
691      // Process collision
692      this->collide ();
693      // Draw
694      this->display ();
695
696      //      for( int i = 0; i < 5000000; i++) {}
697      /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/
698    }
699  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
700}
701
702
703/**
704   \brief synchronize local data with remote data
705*/
706void World::synchronize ()
707{
708  // Get remote input
709  // Update synchronizables
710}
711
712
713/**
714   \brief run all input processing
715
716   the command node is the central input event dispatcher. the node uses the even-queue from
717   sdl and has its own event-passing-queue.
718*/
719void World::handleInput ()
720{
721  // localinput
722  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
723  cn->process();
724  // remoteinput
725}
726
727
728/**
729   \brief advance the timeline
730
731   this calculates the time used to process one frame (with all input handling, drawing, etc)
732   the time is mesured in ms and passed to all world-entities and other classes that need
733   a heart-beat.
734*/
735void World::tick ()
736{
737  Uint32 currentFrame = SDL_GetTicks();
738  if(!this->bPause)
739    {
740      this->dt = currentFrame - this->lastFrame;
741     
742      if( this->dt > 0)
743        {
744          float fps = 1000/dt;
745          PRINTF(3)("fps = %f\n", fps);
746        }
747      else
748        {
749          /* the frame-rate is limited to 100 frames per second, all other things are for
750             nothing.
751          */
752          PRINTF(2)("fps = 1000 - frame rate is adjusted\n");
753          SDL_Delay(10);
754          this->dt = 10;
755        }
756      //this->timeSlice (dt);
757     
758      /* function to let all entities tick (iterate through list) */
759      float seconds = this->dt / 1000.0;     
760      this->gameTime += seconds;
761      //entity = entities->enumerate();
762      tIterator<WorldEntity>* iterator = this->entities->getIterator();
763      WorldEntity* entity = iterator->nextElement();
764      while( entity != NULL) 
765        { 
766          entity->tick (seconds);
767          entity = iterator->nextElement();
768        }
769      delete iterator;
770      //skySphere->updatePosition(localCamera->absCoordinate);
771     
772      /* update tick the rest */
773      this->trackManager->tick(this->dt);
774      this->localCamera->tick(this->dt);
775      this->garbageCollector->tick(seconds);
776    }
777  this->lastFrame = currentFrame;
778}
779
780
781/**
782   \brief this function gives the world a consistant state
783
784   after ticking (updating the world state) this will give a constistant
785   state to the whole system.
786*/
787void World::update()
788{
789  this->garbageCollector->update();
790  this->nullParent->update (dt);
791}
792
793
794/**
795   \brief render the current frame
796   
797   clear all buffers and draw the world
798*/
799void World::display ()
800{
801  // clear buffer
802  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
803  // set camera
804  this->localCamera->apply ();
805  // draw world
806  this->draw();
807  // draw HUD
808  /* \todo draw HUD */
809  // flip buffers
810  SDL_GL_SwapBuffers();
811  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
812  //SDL_Flip (screen);
813}
814
815
816/**
817   \brief add and spawn a new entity to this world
818   \param entity to be added
819*/
820void World::spawn(WorldEntity* entity)
821{
822  this->entities->add (entity);
823  entity->postSpawn ();
824}
825
826
827/**
828   \brief add and spawn a new entity to this world
829   \param entity to be added
830   \param absCoor At what coordinates to add this entity.
831   \param absDir In which direction should it look.
832*/
833void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
834{
835  this->entities->add (entity);
836
837  entity->setAbsCoor (absCoor);
838  entity->setAbsDir (absDir);
839
840  entity->postSpawn ();
841}
842
843
844/**
845   \brief add and spawn a new entity to this world
846   \param entity to be added
847   \param entity to be added to (PNode)
848   \param At what relative  coordinates to add this entity.
849   \param In which relative direction should it look.
850*/
851void World::spawn(WorldEntity* entity, PNode* parentNode, 
852                  Vector* relCoor, Quaternion* relDir, 
853                  int parentingMode)
854{
855  this->nullParent = NullParent::getInstance();
856  if( parentNode != NULL)
857    {
858      parentNode->addChild (entity);
859     
860      entity->setRelCoor (relCoor);
861      entity->setRelDir (relDir);
862      entity->setMode(parentingMode);
863     
864      this->entities->add (entity);
865     
866      entity->postSpawn ();
867    }
868}
869
870
871
872/**
873  \brief commands that the world must catch
874  \returns false if not used by the world
875*/
876bool World::command(Command* cmd)
877{
878  if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
879  else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
880  else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
881  else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
882  else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
883  else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);
884 
885  return false;
886}
887
Note: See TracBrowser for help on using the repository browser.