Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: ResourceManager not totally static anymore, list-iterators, and so on

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::getInstance()->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            /*
332            Vector* es = new Vector (10, 5, 0);
333            Quaternion* qs = new Quaternion ();
334            WorldEntity* pr = new Primitive(P_CYLINDER);
335            pr->setName("primitive");
336            this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
337            */
338
339            /*monitor progress*/
340            this->glmis->step();
341
342            //      trackManager->setBindSlave(env);
343            PNode* tn = trackManager->getTrackNode();
344            tn->addChild(this->localPlayer);
345
346            //localCamera->setParent(TrackNode::getInstance());
347            tn->addChild(this->localCamera);
348            //      localCamera->lookAt(tn);
349            this->localPlayer->setMode(PNODE_ALL);
350            //Vector* cameraOffset = new Vector (0, 5, -10);
351            trackManager->condition(2, LEFTRIGHT, this->localPlayer);
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            WorldEntity* pr = new Primitive(P_SPHERE);
386            pr->setName("primitive");
387            this->spawn(pr, this->localPlayer, es, qs, PNODE_ROTATE_AND_MOVE);
388
389            lightMan->getLight(0)->setParent(trackManager->getTrackNode());
390            break;
391          }
392        default:
393          printf("World::load() - no world with ID %i found", this->debugWorldNr );
394        }
395    }
396  else if(this->worldName != NULL)
397    {
398
399    }
400
401  // initialize debug coord system
402  objectList = glGenLists(1);
403  glNewList (objectList, GL_COMPILE);
404 
405  trackManager->drawGraph(.01);
406  trackManager->debug(2);
407  glEndList();
408
409  terrain = new Terrain("../data/worlds/newGround.obj");
410  terrain->setRelCoor(new Vector(0,-10,0));
411  this->spawn(terrain);
412
413}
414
415
416/**
417   \brief initializes a new World shortly before start
418
419   this is the function, that will be loaded shortly before the world is
420   started
421*/
422ErrorMessage World::init()
423{
424  this->bPause = false;
425  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
426  cn->addToWorld(this);
427  cn->enable(true);
428}
429
430
431/**
432   \brief starts the World
433*/
434ErrorMessage World::start()
435{
436  PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
437  this->bQuitOrxonox = false;
438  this->bQuitCurrentGame = false;
439  this->mainLoop();
440}
441
442/**
443   \brief stops the world.
444
445   This happens, when the player decides to end the Level.
446*/
447ErrorMessage World::stop()
448{
449  PRINTF(3)("World::stop() - got stop signal\n");
450  this->bQuitCurrentGame = true;
451}
452
453/**
454   \brief pauses the Game
455*/
456ErrorMessage World::pause()
457{
458  this->isPaused = true;
459}
460
461/**
462   \brief ends the pause Phase
463*/
464ErrorMessage World::resume()
465{
466  this->isPaused = false;
467}
468
469/**
470   \brief destroys the World
471*/
472ErrorMessage World::destroy()
473{
474
475}
476
477/**
478   \brief shows the loading screen
479*/
480void World::displayLoadScreen ()
481{
482  PRINTF(3)("World::displayLoadScreen - start\n"); 
483 
484  //GLMenuImageScreen*
485  this->glmis = GLMenuImageScreen::getInstance();
486  this->glmis->init();
487  this->glmis->setMaximum(10);
488  this->glmis->draw();
489 
490  PRINTF(3)("World::displayLoadScreen - end\n"); 
491}
492
493/**
494   \brief removes the loadscreen, and changes over to the game
495
496   \todo take out the delay
497*/
498void World::releaseLoadScreen ()
499{
500  PRINTF(3)("World::releaseLoadScreen - start\n"); 
501  this->glmis->setValue(this->glmis->getMaximum());
502  SDL_Delay(500);
503  PRINTF(3)("World::releaseLoadScreen - end\n"); 
504}
505
506
507/**
508   \brief gets the list of entities from the world
509   \returns entity list
510*/
511tList<WorldEntity>* World::getEntities()
512{
513  return this->entities;
514}
515
516
517/**
518   \brief this returns the current game time
519   \returns elapsed game time
520*/
521double World::getGameTime()
522{
523  return this->gameTime;
524}
525
526
527/**
528    \brief checks for collisions
529   
530    This method runs through all WorldEntities known to the world and checks for collisions
531    between them. In case of collisions the collide() method of the corresponding entities
532    is called.
533*/
534void World::collide ()
535{
536  /*
537  List *a, *b;
538  WorldEntity *aobj, *bobj;
539   
540  a = entities;
541 
542  while( a != NULL)
543    {
544      aobj = a->nextElement();
545      if( aobj->bCollide && aobj->collisioncluster != NULL)
546        {
547          b = a->nextElement();
548          while( b != NULL )
549            {
550              bobj = b->nextElement();
551              if( bobj->bCollide && bobj->collisioncluster != NULL )
552                {
553                  unsigned long ahitflg, bhitflg;
554                  if( check_collision ( &aobj->place, aobj->collisioncluster,
555                                        &ahitflg, &bobj->place, bobj->collisioncluster,
556                                        &bhitflg) );
557                  {
558                    aobj->collide (bobj, ahitflg, bhitflg);
559                    bobj->collide (aobj, bhitflg, ahitflg);
560                  }
561                }
562              b = b->nextElement();
563            }
564        }
565      a = a->enumerate();
566    }
567  */
568}
569
570/**
571    \brief runs through all entities calling their draw() methods
572*/
573void World::draw ()
574{
575  /* draw entities */
576  WorldEntity* entity;
577  glLoadIdentity();
578
579  //entity = this->entities->enumerate();
580  tIterator<WorldEntity>* iterator = this->entities->getIterator();
581  entity = iterator->nextElement();
582  while( entity != NULL ) 
583    { 
584      if( entity->bDraw ) entity->draw();
585      //entity = this->entities->nextElement();
586      entity = iterator->nextElement();
587    }
588  delete iterator;
589 
590  glCallList (objectList);
591  //! \todo skysphere is a WorldEntity and should be inside of the world-entity-list.
592  skySphere->draw();
593
594  testFont->printText(0, 0, 1, "orxonox_" PACKAGE_VERSION);
595
596  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
597}
598
599
600/**
601   \brief function to put your own debug stuff into it. it can display informations about
602   the current class/procedure
603*/
604void World::debug()
605{
606  PRINTF(2)("debug() - starting debug\n");
607  PNode* p1 = NullParent::getInstance ();
608  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
609  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
610  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
611
612  p1->debug ();
613  p2->debug ();
614  p3->debug ();
615  p4->debug ();
616
617  p1->shiftCoor (new Vector(-1, -1, -1));
618
619  printf("World::debug() - shift\n");
620  p1->debug ();
621  p2->debug ();
622  p3->debug ();
623  p4->debug ();
624 
625  p1->update (0);
626
627  printf ("World::debug() - update\n");
628  p1->debug ();
629  p2->debug ();
630  p3->debug ();
631  p4->debug ();
632
633  p2->shiftCoor (new Vector(-1, -1, -1));
634  p1->update (0);
635
636  p1->debug ();
637  p2->debug ();
638  p3->debug ();
639  p4->debug ();
640
641  p2->setAbsCoor (new Vector(1,2,3));
642
643
644 p1->update (0);
645
646  p1->debug ();
647  p2->debug ();
648  p3->debug ();
649  p4->debug ();
650
651  delete p1;
652 
653 
654  /*
655  WorldEntity* entity;
656  printf("counting all entities\n");
657  printf("World::debug() - enumerate()\n");
658  entity = entities->enumerate(); 
659  while( entity != NULL )
660    {
661      if( entity->bDraw ) printf("got an entity\n");
662      entity = entities->nextElement();
663    }
664  */
665}
666
667
668/**
669  \brief main loop of the world: executing all world relevant function
670
671  in this loop we synchronize (if networked), handle input events, give the heart-beat to
672  all other member-entities of the world (tick to player, enemies etc.), checking for
673  collisions drawing everything to the screen.
674*/
675void World::mainLoop()
676{
677  this->lastFrame = SDL_GetTicks ();
678  PRINTF(3)("World::mainLoop() - Entering main loop\n");
679  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
680    {
681      PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
682      // Network
683      this->synchronize ();
684      // Process input
685      this->handleInput ();
686      if( this->bQuitCurrentGame || this->bQuitOrxonox)
687          break;
688      // Process time
689      this->tick ();
690      // Update the state
691      this->update ();     
692      // Process collision
693      this->collide ();
694      // Draw
695      this->display ();
696
697      //      for( int i = 0; i < 5000000; i++) {}
698      /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/
699    }
700  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
701}
702
703
704/**
705   \brief synchronize local data with remote data
706*/
707void World::synchronize ()
708{
709  // Get remote input
710  // Update synchronizables
711}
712
713
714/**
715   \brief run all input processing
716
717   the command node is the central input event dispatcher. the node uses the even-queue from
718   sdl and has its own event-passing-queue.
719*/
720void World::handleInput ()
721{
722  // localinput
723  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
724  cn->process();
725  // remoteinput
726}
727
728
729/**
730   \brief advance the timeline
731
732   this calculates the time used to process one frame (with all input handling, drawing, etc)
733   the time is mesured in ms and passed to all world-entities and other classes that need
734   a heart-beat.
735*/
736void World::tick ()
737{
738  Uint32 currentFrame = SDL_GetTicks();
739  if(!this->bPause)
740    {
741      this->dt = currentFrame - this->lastFrame;
742     
743      if( this->dt > 0)
744        {
745          float fps = 1000/dt;
746          PRINTF(3)("fps = %f\n", fps);
747        }
748      else
749        {
750          /* the frame-rate is limited to 100 frames per second, all other things are for
751             nothing.
752          */
753          PRINTF(2)("fps = 1000 - frame rate is adjusted\n");
754          SDL_Delay(10);
755          this->dt = 10;
756        }
757      //this->timeSlice (dt);
758     
759      /* function to let all entities tick (iterate through list) */
760      float seconds = this->dt / 1000.0;     
761      this->gameTime += seconds;
762      //entity = entities->enumerate();
763      tIterator<WorldEntity>* iterator = this->entities->getIterator();
764      WorldEntity* entity = iterator->nextElement();
765      while( entity != NULL) 
766        { 
767          entity->tick (seconds);
768          entity = iterator->nextElement();
769        }
770      delete iterator;
771      //skySphere->updatePosition(localCamera->absCoordinate);
772     
773      /* update tick the rest */
774      this->trackManager->tick(this->dt);
775      this->localCamera->tick(this->dt);
776      this->garbageCollector->tick(seconds);
777    }
778  this->lastFrame = currentFrame;
779}
780
781
782/**
783   \brief this function gives the world a consistant state
784
785   after ticking (updating the world state) this will give a constistant
786   state to the whole system.
787*/
788void World::update()
789{
790  this->garbageCollector->update();
791  this->nullParent->update (dt);
792}
793
794
795/**
796   \brief render the current frame
797   
798   clear all buffers and draw the world
799*/
800void World::display ()
801{
802  // clear buffer
803  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
804  // set camera
805  this->localCamera->apply ();
806  // draw world
807  this->draw();
808  // draw HUD
809  /* \todo draw HUD */
810  // flip buffers
811  SDL_GL_SwapBuffers();
812  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
813  //SDL_Flip (screen);
814}
815
816
817/**
818   \brief add and spawn a new entity to this world
819   \param entity to be added
820*/
821void World::spawn(WorldEntity* entity)
822{
823  this->entities->add (entity);
824  entity->postSpawn ();
825}
826
827
828/**
829   \brief add and spawn a new entity to this world
830   \param entity to be added
831   \param absCoor At what coordinates to add this entity.
832   \param absDir In which direction should it look.
833*/
834void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
835{
836  this->entities->add (entity);
837
838  entity->setAbsCoor (absCoor);
839  entity->setAbsDir (absDir);
840
841  entity->postSpawn ();
842}
843
844
845/**
846   \brief add and spawn a new entity to this world
847   \param entity to be added
848   \param entity to be added to (PNode)
849   \param At what relative  coordinates to add this entity.
850   \param In which relative direction should it look.
851*/
852void World::spawn(WorldEntity* entity, PNode* parentNode, 
853                  Vector* relCoor, Quaternion* relDir, 
854                  int parentingMode)
855{
856  this->nullParent = NullParent::getInstance();
857  if( parentNode != NULL)
858    {
859      parentNode->addChild (entity);
860     
861      entity->setRelCoor (relCoor);
862      entity->setRelDir (relDir);
863      entity->setMode(parentingMode);
864     
865      this->entities->add (entity);
866     
867      entity->postSpawn ();
868    }
869}
870
871
872
873/**
874  \brief commands that the world must catch
875  \returns false if not used by the world
876*/
877bool World::command(Command* cmd)
878{
879  if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
880  else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
881  else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
882  else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
883  else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
884  else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);
885 
886  return false;
887}
888
Note: See TracBrowser for help on using the repository browser.