Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/textEngine/src/story_entities/world.cc @ 3769

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

orxonox/branches/textEngine: compiling again, many movements… still working

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 "skysphere.h"
32#include "terrain.h"
33#include "light.h"
34#include "text_engine.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 "list.h"
42
43using namespace std;
44
45
46WorldInterface* WorldInterface::singletonRef = 0;
47
48
49/**
50   \brief private constructor because of singleton
51*/
52WorldInterface::WorldInterface()
53{
54  this->worldIsInitialized = false;
55  this->worldReference = NULL;
56}
57
58/**
59   \brief public deconstructor
60*/
61WorldInterface::~WorldInterface()
62{
63  this->singletonRef = NULL;
64  this->worldIsInitialized = false;
65  this->worldReference = NULL;
66}
67
68/**
69   \brief gets the singleton instance
70   \returns singleton instance
71*/
72WorldInterface* WorldInterface::getInstance()
73{
74  if( singletonRef == NULL)
75    singletonRef = new WorldInterface();
76  return singletonRef;
77}
78
79
80/**
81   \brief initializes the interface
82   \param reference to the world
83
84   if the worldinterface is not initilizes, there wont be any
85   useable interface
86*/
87void WorldInterface::init(World* world)
88{
89  this->worldReference = world;
90  if( world != NULL)
91    {
92      this->worldIsInitialized = true;
93      PRINTF(3)("WorldInterface up and running\n");
94    }
95}
96
97
98/**
99   \brief gets the entity list from the world
100   \return entity list
101*/
102tList<WorldEntity>* WorldInterface::getEntityList()
103{
104  if( this->worldIsInitialized)
105    return this->worldReference->getEntities();
106  PRINT(1)("Someone tried to use the WorldInterface before it has been initizlized! this can result in SEGFAULTs!\n");
107  return NULL;
108}
109
110
111
112/**
113    \brief create a new World
114   
115    This creates a new empty world!
116*/
117World::World (char* name)
118{
119  this->init(name, -1);
120  //NullParent* np = NullParent::getInstance();
121}
122
123/**
124   \brief creates a new World...
125   \param worldID with this ID
126*/
127World::World (int worldID)
128{
129  this->init(NULL, worldID);
130}
131
132/**
133    \brief remove the World from memory
134   
135    delete everything explicitly, that isn't contained in the parenting tree!
136    things contained in the tree are deleted automaticaly
137*/
138World::~World ()
139{
140  PRINTF(3)("World::~World() - deleting current world\n");
141  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
142  cn->unbind(this->localPlayer);
143  cn->reset();
144
145  ResourceManager::getInstance()->debug();
146  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
147  ResourceManager::getInstance()->debug();
148
149  delete WorldInterface::getInstance();
150
151  delete this->nullParent;
152  delete this->entities;
153  delete this->lightMan;
154  delete this->trackManager;
155}
156
157/**
158   \brief initializes the 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*/
166void World::init(char* name, int worldID)
167{
168  this->setClassName ("World");
169
170  this->worldName = name;
171  this->debugWorldNr = worldID;
172  this->entities = new tList<WorldEntity>();
173}
174
175
176/**
177   \brief this is executed before load
178
179   since the load function sometimes needs data, that has been init before
180   the load and after the proceeding storyentity has finished
181*/
182ErrorMessage World::preLoad()
183{
184  /* init the world interface */
185  WorldInterface* wi = WorldInterface::getInstance();
186  wi->init(this);
187  this->garbageCollector = GarbageCollector::getInstance();
188}
189
190
191/**
192   \brief loads the World by initializing all resources, and set their default values.
193*/
194ErrorMessage World::load()
195{
196  //  BezierCurve* tmpCurve = new BezierCurve();
197  if(this->debugWorldNr != -1)
198    {
199      // initializing Font
200      this->glmis->step();
201      // initializing the TrackManager
202      trackManager = TrackManager::getInstance();
203      trackManager->addPoint(Vector(0,0,0));
204      trackManager->addPoint(Vector(100, -40, 5));
205      trackManager->addPoint(Vector(200,-40,-8));
206      trackManager->addPoint(Vector(250, -35, -2));
207      trackManager->addPoint(Vector(320,-33,-.55));
208      trackManager->setDuration(3);
209      trackManager->setSavePoint();
210      trackManager->addPoint(Vector(410, 0, 0));
211      trackManager->addPoint(Vector(510, 20, -10));
212      trackManager->addPoint(Vector(550, 20, -10));
213      trackManager->addPoint(Vector(570, 20, -10));
214      trackManager->setDuration(5);
215     
216      int fork11, fork12;
217      trackManager->fork(2, &fork11, &fork12);
218      trackManager->workOn(fork11);
219      trackManager->addPoint(Vector(640, 25, -30));
220      trackManager->addPoint(Vector(700, 40, -120));
221      trackManager->addPoint(Vector(800, 50, -150));
222      trackManager->addPoint(Vector(900, 60, -100));
223      trackManager->addPoint(Vector(900, 60, -70));
224      trackManager->addPoint(Vector(990, 65, -15));
225      trackManager->addPoint(Vector(1050, 65, -10));
226      trackManager->addPoint(Vector(1100, 65, -20));
227      trackManager->setDuration(10);
228
229      trackManager->workOn(fork12);
230      trackManager->addPoint(Vector(640, 25, 20));
231      trackManager->addPoint(Vector(670, 50, 120));
232      trackManager->addPoint(Vector(700, 70, 80));
233      trackManager->addPoint(Vector(800, 70, 65));
234      trackManager->addPoint(Vector(850, 65, 65));
235      trackManager->addPoint(Vector(920, 35, 40));
236      trackManager->addPoint(Vector(945, 40, 40));
237      trackManager->addPoint(Vector(970, 24, 40));
238      trackManager->addPoint(Vector(1000, 40, -7));
239      trackManager->setDuration(10);
240     
241
242      trackManager->join(2, fork11, fork12);
243
244      trackManager->workOn(5);
245      trackManager->addPoint(Vector(1200, 60, -50));
246      trackManager->addPoint(Vector(1300, 50, -50));
247      trackManager->addPoint(Vector(1400, 40, -50));
248      trackManager->addPoint(Vector(1500, 40, -60));
249      trackManager->addPoint(Vector(1600, 35, -55));
250      trackManager->addPoint(Vector(1700, 45, -40));
251      trackManager->addPoint(Vector(1750, 60, -40));
252      trackManager->addPoint(Vector(1770, 80, -40));
253      trackManager->addPoint(Vector(1800, 100, -40));
254      trackManager->setDuration(10);
255
256      trackManager->finalize();
257
258     
259      /*monitor progress*/
260      this->glmis->step();
261
262      // LIGHT initialisation
263      lightMan = LightManager::getInstance();
264      lightMan->setAmbientColor(.1,.1,.1);
265      lightMan->addLight();
266      //      lightMan->setAttenuation(1.0, .01, 0.0);
267      //      lightMan->setDiffuseColor(1,1,1);
268      //  lightMan->addLight(1);
269      //  lightMan->setPosition(20, 10, -20);
270      //  lightMan->setDiffuseColor(0,0,0);
271      lightMan->debug();
272
273      switch(this->debugWorldNr)
274        {
275          /*
276            this loads the hard-coded debug world. this only for simplicity and will be
277            removed by a reald world-loader, which interprets a world-file.
278            if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
279            make whatever you want...
280           */
281        case DEBUG_WORLD_0:
282          {
283            lightMan->setPosition(-5.0, 10.0, -40.0);
284            this->nullParent = NullParent::getInstance ();
285            this->nullParent->setName ("NullParent");
286
287            // !\todo old track-system has to be removed
288
289            //create helper for player
290            //HelperParent* hp = new HelperParent ();
291            /* the player has to be added to this helper */
292
293            // create a player
294            this->localPlayer = new Player ();
295            this->localPlayer->setName ("player");
296            this->spawn (this->localPlayer);
297            /*monitor progress*/
298            //this->glmis->step();
299            this->glmis->step();
300
301            // bind input
302            Orxonox *orx = Orxonox::getInstance ();
303            orx->getLocalInput()->bind (this->localPlayer);
304           
305            // bind camera
306            this->localCamera = new Camera();
307            this->localCamera->setName ("camera");
308            this->localCamera->lookAt(this->localPlayer);
309            this->localCamera->setParent(this->localPlayer);
310           
311            /*monitor progress*/
312            this->glmis->step();
313
314            // Create SkySphere
315            this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
316            this->skySphere->setName("SkySphere");
317            this->localCamera->addChild(this->skySphere);
318            this->skySphere->setMode(PNODE_MOVEMENT);
319
320            /*monitor progress*/
321            this->glmis->step();
322
323           
324            WorldEntity* env = new Environment();
325            env->setName ("env");
326            this->spawn(env);
327
328           
329            /*
330            Vector* es = new Vector (10, 5, 0);
331            Quaternion* qs = new Quaternion ();
332            WorldEntity* pr = new Primitive(P_CYLINDER);
333            pr->setName("primitive");
334            this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
335            */
336
337            /*monitor progress*/
338            this->glmis->step();
339
340            //      trackManager->setBindSlave(env);
341            PNode* tn = trackManager->getTrackNode();
342            tn->addChild(this->localPlayer);
343
344            //localCamera->setParent(TrackNode::getInstance());
345            tn->addChild(this->localCamera);
346            //      localCamera->lookAt(tn);
347            this->localPlayer->setMode(PNODE_ALL);
348            //Vector* cameraOffset = new Vector (0, 5, -10);
349            trackManager->condition(2, LEFTRIGHT, this->localPlayer);
350            this->glmis->step();
351            this->testText = TextEngine::getInstance()->createText("fonts/earth.ttf");
352
353            break;
354          }
355        case DEBUG_WORLD_1:
356          {
357            lightMan->setPosition(.0, .0, .0);
358            lightMan->setAttenuation(1.0, .01, 0.0);
359            lightMan->setSpecularColor(1,0,0);
360            this->nullParent = NullParent::getInstance ();
361            this->nullParent->setName ("NullParent");
362
363            // create a player
364            WorldEntity* myPlayer = new Player();
365            myPlayer->setName ("player");
366            this->spawn(myPlayer);
367            this->localPlayer = myPlayer;           
368           
369            // bind input
370            Orxonox *orx = Orxonox::getInstance();
371            orx->getLocalInput()->bind (myPlayer);
372           
373            // bind camera
374            this->localCamera = new Camera ();
375            this->localCamera->setName ("camera");
376            this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
377            this->localCamera->setParent(this->localPlayer);
378
379            // Create SkySphere
380            skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
381            this->localPlayer->addChild(this->skySphere);
382
383            Vector* es = new Vector (20, 0, 0);
384            Quaternion* qs = new Quaternion ();
385
386            lightMan->getLight(0)->setParent(trackManager->getTrackNode());
387            break;
388          }
389        default:
390          printf("World::load() - no world with ID %i found", this->debugWorldNr );
391        }
392    }
393  else if(this->worldName != NULL)
394    {
395
396    }
397
398  // initialize debug coord system
399  objectList = glGenLists(1);
400  glNewList (objectList, GL_COMPILE);
401 
402  //  trackManager->drawGraph(.01);
403  trackManager->debug(2);
404  glEndList();
405
406  terrain = new Terrain("../data/worlds/newGround.obj");
407  terrain->setRelCoor(new Vector(0,-10,0));
408  this->spawn(terrain);
409
410}
411
412
413/**
414   \brief initializes a new World shortly before start
415
416   this is the function, that will be loaded shortly before the world is
417   started
418*/
419ErrorMessage World::init()
420{
421  this->bPause = false;
422  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
423  cn->addToWorld(this);
424  cn->enable(true);
425}
426
427
428/**
429   \brief starts the World
430*/
431ErrorMessage World::start()
432{
433  PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
434  this->bQuitOrxonox = false;
435  this->bQuitCurrentGame = false;
436  this->mainLoop();
437}
438
439/**
440   \brief stops the world.
441
442   This happens, when the player decides to end the Level.
443*/
444ErrorMessage World::stop()
445{
446  PRINTF(3)("World::stop() - got stop signal\n");
447  this->bQuitCurrentGame = true;
448}
449
450/**
451   \brief pauses the Game
452*/
453ErrorMessage World::pause()
454{
455  this->isPaused = true;
456}
457
458/**
459   \brief ends the pause Phase
460*/
461ErrorMessage World::resume()
462{
463  this->isPaused = false;
464}
465
466/**
467   \brief destroys the World
468*/
469ErrorMessage World::destroy()
470{
471
472}
473
474/**
475   \brief shows the loading screen
476*/
477void World::displayLoadScreen ()
478{
479  PRINTF(3)("World::displayLoadScreen - start\n"); 
480 
481  //GLMenuImageScreen*
482  this->glmis = GLMenuImageScreen::getInstance();
483  this->glmis->init();
484  this->glmis->setMaximum(8);
485  this->glmis->draw();
486 
487  PRINTF(3)("World::displayLoadScreen - end\n"); 
488}
489
490/**
491   \brief removes the loadscreen, and changes over to the game
492
493   \todo take out the delay
494*/
495void World::releaseLoadScreen ()
496{
497  PRINTF(3)("World::releaseLoadScreen - start\n"); 
498  this->glmis->setValue(this->glmis->getMaximum());
499  //SDL_Delay(500);
500  PRINTF(3)("World::releaseLoadScreen - end\n"); 
501}
502
503
504/**
505   \brief gets the list of entities from the world
506   \returns entity list
507*/
508tList<WorldEntity>* World::getEntities()
509{
510  return this->entities;
511}
512
513
514/**
515   \brief this returns the current game time
516   \returns elapsed game time
517*/
518double World::getGameTime()
519{
520  return this->gameTime;
521}
522
523
524/**
525    \brief checks for collisions
526   
527    This method runs through all WorldEntities known to the world and checks for collisions
528    between them. In case of collisions the collide() method of the corresponding entities
529    is called.
530*/
531void World::collide ()
532{
533  /*
534  List *a, *b;
535  WorldEntity *aobj, *bobj;
536   
537  a = entities;
538 
539  while( a != NULL)
540    {
541      aobj = a->nextElement();
542      if( aobj->bCollide && aobj->collisioncluster != NULL)
543        {
544          b = a->nextElement();
545          while( b != NULL )
546            {
547              bobj = b->nextElement();
548              if( bobj->bCollide && bobj->collisioncluster != NULL )
549                {
550                  unsigned long ahitflg, bhitflg;
551                  if( check_collision ( &aobj->place, aobj->collisioncluster,
552                                        &ahitflg, &bobj->place, bobj->collisioncluster,
553                                        &bhitflg) );
554                  {
555                    aobj->collide (bobj, ahitflg, bhitflg);
556                    bobj->collide (aobj, bhitflg, ahitflg);
557                  }
558                }
559              b = b->nextElement();
560            }
561        }
562      a = a->enumerate();
563    }
564  */
565}
566
567/**
568    \brief runs through all entities calling their draw() methods
569*/
570void World::draw ()
571{
572  /* draw entities */
573  WorldEntity* entity;
574  glLoadIdentity();
575
576  //entity = this->entities->enumerate();
577  tIterator<WorldEntity>* iterator = this->entities->getIterator();
578  entity = iterator->nextElement();
579  while( entity != NULL ) 
580    { 
581      if( entity->bDraw ) entity->draw();
582      //entity = this->entities->nextElement();
583      entity = iterator->nextElement();
584    }
585  delete iterator;
586 
587  glCallList (objectList);
588  //! \todo skysphere is a WorldEntity and should be inside of the world-entity-list.
589  skySphere->draw();
590
591  TextEngine::getInstance()->draw();
592  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
593}
594
595
596/**
597   \brief function to put your own debug stuff into it. it can display informations about
598   the current class/procedure
599*/
600void World::debug()
601{
602  PRINTF(2)("debug() - starting debug\n");
603  PNode* p1 = NullParent::getInstance ();
604  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
605  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
606  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
607
608  p1->debug ();
609  p2->debug ();
610  p3->debug ();
611  p4->debug ();
612
613  p1->shiftCoor (new Vector(-1, -1, -1));
614
615  printf("World::debug() - shift\n");
616  p1->debug ();
617  p2->debug ();
618  p3->debug ();
619  p4->debug ();
620 
621  p1->update (0);
622
623  printf ("World::debug() - update\n");
624  p1->debug ();
625  p2->debug ();
626  p3->debug ();
627  p4->debug ();
628
629  p2->shiftCoor (new Vector(-1, -1, -1));
630  p1->update (0);
631
632  p1->debug ();
633  p2->debug ();
634  p3->debug ();
635  p4->debug ();
636
637  p2->setAbsCoor (new Vector(1,2,3));
638
639
640 p1->update (0);
641
642  p1->debug ();
643  p2->debug ();
644  p3->debug ();
645  p4->debug ();
646
647  delete p1;
648 
649 
650  /*
651  WorldEntity* entity;
652  printf("counting all entities\n");
653  printf("World::debug() - enumerate()\n");
654  entity = entities->enumerate(); 
655  while( entity != NULL )
656    {
657      if( entity->bDraw ) printf("got an entity\n");
658      entity = entities->nextElement();
659    }
660  */
661}
662
663
664/**
665  \brief main loop of the world: executing all world relevant function
666
667  in this loop we synchronize (if networked), handle input events, give the heart-beat to
668  all other member-entities of the world (tick to player, enemies etc.), checking for
669  collisions drawing everything to the screen.
670*/
671void World::mainLoop()
672{
673  this->lastFrame = SDL_GetTicks ();
674  PRINTF(3)("World::mainLoop() - Entering main loop\n");
675  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
676    {
677      PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
678      // Network
679      this->synchronize ();
680      // Process input
681      this->handleInput ();
682      if( this->bQuitCurrentGame || this->bQuitOrxonox)
683          break;
684      // Process time
685      this->tick ();
686      // Update the state
687      this->update ();     
688      // Process collision
689      this->collide ();
690      // Draw
691      this->display ();
692
693      //      for( int i = 0; i < 5000000; i++) {}
694      /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/
695    }
696  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
697}
698
699
700/**
701   \brief synchronize local data with remote data
702*/
703void World::synchronize ()
704{
705  // Get remote input
706  // Update synchronizables
707}
708
709
710/**
711   \brief run all input processing
712
713   the command node is the central input event dispatcher. the node uses the even-queue from
714   sdl and has its own event-passing-queue.
715*/
716void World::handleInput ()
717{
718  // localinput
719  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
720  cn->process();
721  // remoteinput
722}
723
724
725/**
726   \brief advance the timeline
727
728   this calculates the time used to process one frame (with all input handling, drawing, etc)
729   the time is mesured in ms and passed to all world-entities and other classes that need
730   a heart-beat.
731*/
732void World::tick ()
733{
734  Uint32 currentFrame = SDL_GetTicks();
735  if(!this->bPause)
736    {
737      this->dt = currentFrame - this->lastFrame;
738     
739      if( this->dt > 0)
740        {
741          float fps = 1000/dt;
742
743          // temporary, only for showing how fast the text-engine is
744          char tmpChar[20];
745          sprintf(tmpChar, "fps: %4.0f", 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.