Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/textEngine: textEngine rendering again

File size: 21.7 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            testText->setText("test");
353            testText->setBindNode(tn);
354
355            break;
356          }
357        case DEBUG_WORLD_1:
358          {
359            lightMan->setPosition(.0, .0, .0);
360            lightMan->setAttenuation(1.0, .01, 0.0);
361            lightMan->setSpecularColor(1,0,0);
362            this->nullParent = NullParent::getInstance ();
363            this->nullParent->setName ("NullParent");
364
365            // create a player
366            WorldEntity* myPlayer = new Player();
367            myPlayer->setName ("player");
368            this->spawn(myPlayer);
369            this->localPlayer = myPlayer;           
370           
371            // bind input
372            Orxonox *orx = Orxonox::getInstance();
373            orx->getLocalInput()->bind (myPlayer);
374           
375            // bind camera
376            this->localCamera = new Camera ();
377            this->localCamera->setName ("camera");
378            this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
379            this->localCamera->setParent(this->localPlayer);
380
381            // Create SkySphere
382            skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
383            this->localPlayer->addChild(this->skySphere);
384
385            Vector* es = new Vector (20, 0, 0);
386            Quaternion* qs = new Quaternion ();
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(8);
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  TextEngine::getInstance()->draw();
594  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
595}
596
597
598/**
599   \brief function to put your own debug stuff into it. it can display informations about
600   the current class/procedure
601*/
602void World::debug()
603{
604  PRINTF(2)("debug() - starting debug\n");
605  PNode* p1 = NullParent::getInstance ();
606  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
607  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
608  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
609
610  p1->debug ();
611  p2->debug ();
612  p3->debug ();
613  p4->debug ();
614
615  p1->shiftCoor (new Vector(-1, -1, -1));
616
617  printf("World::debug() - shift\n");
618  p1->debug ();
619  p2->debug ();
620  p3->debug ();
621  p4->debug ();
622 
623  p1->update (0);
624
625  printf ("World::debug() - update\n");
626  p1->debug ();
627  p2->debug ();
628  p3->debug ();
629  p4->debug ();
630
631  p2->shiftCoor (new Vector(-1, -1, -1));
632  p1->update (0);
633
634  p1->debug ();
635  p2->debug ();
636  p3->debug ();
637  p4->debug ();
638
639  p2->setAbsCoor (new Vector(1,2,3));
640
641
642 p1->update (0);
643
644  p1->debug ();
645  p2->debug ();
646  p3->debug ();
647  p4->debug ();
648
649  delete p1;
650 
651 
652  /*
653  WorldEntity* entity;
654  printf("counting all entities\n");
655  printf("World::debug() - enumerate()\n");
656  entity = entities->enumerate(); 
657  while( entity != NULL )
658    {
659      if( entity->bDraw ) printf("got an entity\n");
660      entity = entities->nextElement();
661    }
662  */
663}
664
665
666/**
667  \brief main loop of the world: executing all world relevant function
668
669  in this loop we synchronize (if networked), handle input events, give the heart-beat to
670  all other member-entities of the world (tick to player, enemies etc.), checking for
671  collisions drawing everything to the screen.
672*/
673void World::mainLoop()
674{
675  this->lastFrame = SDL_GetTicks ();
676  PRINTF(3)("World::mainLoop() - Entering main loop\n");
677  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
678    {
679      PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
680      // Network
681      this->synchronize ();
682      // Process input
683      this->handleInput ();
684      if( this->bQuitCurrentGame || this->bQuitOrxonox)
685          break;
686      // Process time
687      this->tick ();
688      // Update the state
689      this->update ();     
690      // Process collision
691      this->collide ();
692      // Draw
693      this->display ();
694
695      //      for( int i = 0; i < 5000000; i++) {}
696      /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/
697    }
698  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
699}
700
701
702/**
703   \brief synchronize local data with remote data
704*/
705void World::synchronize ()
706{
707  // Get remote input
708  // Update synchronizables
709}
710
711
712/**
713   \brief run all input processing
714
715   the command node is the central input event dispatcher. the node uses the even-queue from
716   sdl and has its own event-passing-queue.
717*/
718void World::handleInput ()
719{
720  // localinput
721  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
722  cn->process();
723  // remoteinput
724}
725
726
727/**
728   \brief advance the timeline
729
730   this calculates the time used to process one frame (with all input handling, drawing, etc)
731   the time is mesured in ms and passed to all world-entities and other classes that need
732   a heart-beat.
733*/
734void World::tick ()
735{
736  Uint32 currentFrame = SDL_GetTicks();
737  if(!this->bPause)
738    {
739      this->dt = currentFrame - this->lastFrame;
740     
741      if( this->dt > 0)
742        {
743          float fps = 1000/dt;
744
745          // temporary, only for showing how fast the text-engine is
746          char tmpChar[20];
747          sprintf(tmpChar, "fps: %4.0f", fps);
748        }
749      else
750        {
751          /* the frame-rate is limited to 100 frames per second, all other things are for
752             nothing.
753          */
754          PRINTF(2)("fps = 1000 - frame rate is adjusted\n");
755          SDL_Delay(10);
756          this->dt = 10;
757        }
758      //this->timeSlice (dt);
759     
760      /* function to let all entities tick (iterate through list) */
761      float seconds = this->dt / 1000.0;     
762      this->gameTime += seconds;
763      //entity = entities->enumerate();
764      tIterator<WorldEntity>* iterator = this->entities->getIterator();
765      WorldEntity* entity = iterator->nextElement();
766      while( entity != NULL) 
767        { 
768          entity->tick (seconds);
769          entity = iterator->nextElement();
770        }
771      delete iterator;
772      //skySphere->updatePosition(localCamera->absCoordinate);
773     
774      /* update tick the rest */
775      this->trackManager->tick(this->dt);
776      this->localCamera->tick(this->dt);
777      this->garbageCollector->tick(seconds);
778    }
779  this->lastFrame = currentFrame;
780}
781
782
783/**
784   \brief this function gives the world a consistant state
785
786   after ticking (updating the world state) this will give a constistant
787   state to the whole system.
788*/
789void World::update()
790{
791  this->garbageCollector->update();
792  this->nullParent->update (dt);
793}
794
795
796/**
797   \brief render the current frame
798   
799   clear all buffers and draw the world
800*/
801void World::display ()
802{
803  // clear buffer
804  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
805  // set camera
806  this->localCamera->apply ();
807  // draw world
808  this->draw();
809  // draw HUD
810  /* \todo draw HUD */
811  // flip buffers
812  SDL_GL_SwapBuffers();
813  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
814  //SDL_Flip (screen);
815}
816
817
818/**
819   \brief add and spawn a new entity to this world
820   \param entity to be added
821*/
822void World::spawn(WorldEntity* entity)
823{
824  this->entities->add (entity);
825  entity->postSpawn ();
826}
827
828
829/**
830   \brief add and spawn a new entity to this world
831   \param entity to be added
832   \param absCoor At what coordinates to add this entity.
833   \param absDir In which direction should it look.
834*/
835void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
836{
837  this->entities->add (entity);
838
839  entity->setAbsCoor (absCoor);
840  entity->setAbsDir (absDir);
841
842  entity->postSpawn ();
843}
844
845
846/**
847   \brief add and spawn a new entity to this world
848   \param entity to be added
849   \param entity to be added to (PNode)
850   \param At what relative  coordinates to add this entity.
851   \param In which relative direction should it look.
852*/
853void World::spawn(WorldEntity* entity, PNode* parentNode, 
854                  Vector* relCoor, Quaternion* relDir, 
855                  int parentingMode)
856{
857  this->nullParent = NullParent::getInstance();
858  if( parentNode != NULL)
859    {
860      parentNode->addChild (entity);
861     
862      entity->setRelCoor (relCoor);
863      entity->setRelDir (relDir);
864      entity->setMode(parentingMode);
865     
866      this->entities->add (entity);
867     
868      entity->postSpawn ();
869    }
870}
871
872
873
874/**
875  \brief commands that the world must catch
876  \returns false if not used by the world
877*/
878bool World::command(Command* cmd)
879{
880  if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
881  else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
882  else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
883  else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
884  else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
885  else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);
886 
887  return false;
888}
889
Note: See TracBrowser for help on using the repository browser.