Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3653 was 3653, checked in by patrick, 19 years ago

orxonox/trunk: now using iterator in world instead of old construct. on my pc, there is now a speedup of about 1 fps! (instead of 1fps i ve now 2fps :)) )

File size: 21.4 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  delete WorldInterface::getInstance();
149
150  delete this->nullParent;
151  delete this->entities;
152  delete this->lightMan;
153  delete this->trackManager;
154}
155
156/**
157   \brief initializes the world.
158
159   set all stuff here that is world generic and does not use to much memory
160   because the real init() function StoryEntity::init() will be called
161   shortly before start of the game. 
162   since all worlds are initiated/referenced before they will be started.
163   NO LEVEL LOADING HERE - NEVER!
164*/
165void World::init(char* name, int worldID)
166{
167  this->setClassName ("World");
168
169  this->worldName = name;
170  this->debugWorldNr = worldID;
171  this->entities = new tList<WorldEntity>();
172}
173
174
175/**
176   \brief this is executed before load
177
178   since the load function sometimes needs data, that has been init before
179   the load and after the proceeding storyentity has finished
180*/
181ErrorMessage World::preLoad()
182{
183  /* init the world interface */
184  WorldInterface* wi = WorldInterface::getInstance();
185  wi->init(this);
186  this->garbageCollector = GarbageCollector::getInstance();
187}
188
189
190/**
191   \brief loads the World by initializing all resources, and set their default values.
192*/
193ErrorMessage World::load()
194{
195  //  BezierCurve* tmpCurve = new BezierCurve();
196  if(this->debugWorldNr != -1)
197    {
198      // initializing Font
199      testFont = new FontSet();
200      testFont->buildFont("../data/pictures/font.tga");
201
202      // initializing the TrackManager
203      trackManager = TrackManager::getInstance();
204      trackManager->addPoint(Vector(0,0,0));
205      trackManager->addPoint(Vector(100, -40, 5));
206      trackManager->addPoint(Vector(200,-40,-8));
207      trackManager->addPoint(Vector(250, -35, -2));
208      trackManager->addPoint(Vector(320,-33,-.55));
209      trackManager->setDuration(3);
210      trackManager->setSavePoint();
211      trackManager->addPoint(Vector(410, 0, 0));
212      trackManager->addPoint(Vector(510, 20, -10));
213      trackManager->addPoint(Vector(550, 20, -10));
214      trackManager->addPoint(Vector(570, 20, -10));
215      trackManager->setDuration(5);
216     
217      int fork11, fork12;
218      trackManager->fork(2, &fork11, &fork12);
219      trackManager->workOn(fork11);
220      trackManager->addPoint(Vector(640, 25, -30));
221      trackManager->addPoint(Vector(700, 40, -120));
222      trackManager->addPoint(Vector(800, 50, -150));
223      trackManager->addPoint(Vector(900, 60, -100));
224      trackManager->addPoint(Vector(900, 60, -70));
225      trackManager->addPoint(Vector(990, 65, -15));
226      trackManager->addPoint(Vector(1050, 65, -10));
227      trackManager->addPoint(Vector(1100, 65, -20));
228      trackManager->setDuration(10);
229
230      trackManager->workOn(fork12);
231      trackManager->addPoint(Vector(640, 25, 20));
232      trackManager->addPoint(Vector(670, 50, 120));
233      trackManager->addPoint(Vector(700, 70, 80));
234      trackManager->addPoint(Vector(800, 70, 65));
235      trackManager->addPoint(Vector(850, 65, 65));
236      trackManager->addPoint(Vector(920, 35, 40));
237      trackManager->addPoint(Vector(945, 40, 40));
238      trackManager->addPoint(Vector(970, 24, 40));
239      trackManager->addPoint(Vector(1000, 40, -7));
240      trackManager->setDuration(10);
241     
242
243      trackManager->join(2, fork11, fork12);
244
245      trackManager->workOn(5);
246      trackManager->addPoint(Vector(1200, 60, -50));
247      trackManager->addPoint(Vector(1300, 50, -50));
248      trackManager->addPoint(Vector(1400, 40, -50));
249      trackManager->addPoint(Vector(1500, 40, -60));
250      trackManager->addPoint(Vector(1600, 35, -55));
251      trackManager->addPoint(Vector(1700, 45, -40));
252      trackManager->addPoint(Vector(1750, 60, -40));
253      trackManager->addPoint(Vector(1770, 80, -40));
254      trackManager->addPoint(Vector(1800, 100, -40));
255      trackManager->setDuration(10);
256
257      trackManager->finalize();
258
259     
260      /*monitor progress*/
261      this->glmis->step();
262
263      // LIGHT initialisation
264      lightMan = LightManager::getInstance();
265      lightMan->setAmbientColor(.1,.1,.1);
266      lightMan->addLight();
267      //      lightMan->setAttenuation(1.0, .01, 0.0);
268      //      lightMan->setDiffuseColor(1,1,1);
269      //  lightMan->addLight(1);
270      //  lightMan->setPosition(20, 10, -20);
271      //  lightMan->setDiffuseColor(0,0,0);
272      lightMan->debug();
273
274      switch(this->debugWorldNr)
275        {
276          /*
277            this loads the hard-coded debug world. this only for simplicity and will be
278            removed by a reald world-loader, which interprets a world-file.
279            if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
280            make whatever you want...
281           */
282        case DEBUG_WORLD_0:
283          {
284            lightMan->setPosition(-5.0, 10.0, -40.0);
285            this->nullParent = NullParent::getInstance ();
286            this->nullParent->setName ("NullParent");
287
288            // !\todo old track-system has to be removed
289
290            //create helper for player
291            //HelperParent* hp = new HelperParent ();
292            /* the player has to be added to this helper */
293
294            // create a player
295            this->localPlayer = new Player ();
296            this->localPlayer->setName ("player");
297            this->spawn (this->localPlayer);
298            /*monitor progress*/
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            Vector* es = new Vector (10, 5, 0);
330            Quaternion* qs = new Quaternion ();
331            WorldEntity* pr = new Primitive(P_CYLINDER);
332            pr->setName("primitive");
333            this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
334           
335
336            /*monitor progress*/
337            this->glmis->step();
338
339            //      trackManager->setBindSlave(env);
340            PNode* tn = trackManager->getTrackNode();
341            tn->addChild(this->localPlayer);
342
343            //localCamera->setParent(TrackNode::getInstance());
344            tn->addChild(this->localCamera);
345            //      localCamera->lookAt(tn);
346            this->localPlayer->setMode(PNODE_ALL);
347            //Vector* cameraOffset = new Vector (0, 5, -10);
348            trackManager->condition(2, LEFTRIGHT, this->localPlayer);
349
350            break;
351          }
352        case DEBUG_WORLD_1:
353          {
354            lightMan->setPosition(.0, .0, .0);
355            lightMan->setAttenuation(1.0, .01, 0.0);
356            lightMan->setSpecularColor(1,0,0);
357            this->nullParent = NullParent::getInstance ();
358            this->nullParent->setName ("NullParent");
359
360            // create a player
361            WorldEntity* myPlayer = new Player();
362            myPlayer->setName ("player");
363            this->spawn(myPlayer);
364            this->localPlayer = myPlayer;           
365           
366            // bind input
367            Orxonox *orx = Orxonox::getInstance();
368            orx->getLocalInput()->bind (myPlayer);
369           
370            // bind camera
371            this->localCamera = new Camera ();
372            this->localCamera->setName ("camera");
373            this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
374            this->localCamera->setParent(this->localPlayer);
375
376            // Create SkySphere
377            skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
378            this->localPlayer->addChild(this->skySphere);
379
380            Vector* es = new Vector (20, 0, 0);
381            Quaternion* qs = new Quaternion ();
382            WorldEntity* pr = new Primitive(P_SPHERE);
383            pr->setName("primitive");
384            this->spawn(pr, this->localPlayer, es, qs, PNODE_ROTATE_AND_MOVE);
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(10);
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  testFont->printText(0, 0, 1, "orxonox_" PACKAGE_VERSION);
592
593  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
594}
595
596
597/**
598   \brief function to put your own debug stuff into it. it can display informations about
599   the current class/procedure
600*/
601void World::debug()
602{
603  PRINTF(2)("debug() - starting debug\n");
604  PNode* p1 = NullParent::getInstance ();
605  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
606  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
607  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
608
609  p1->debug ();
610  p2->debug ();
611  p3->debug ();
612  p4->debug ();
613
614  p1->shiftCoor (new Vector(-1, -1, -1));
615
616  printf("World::debug() - shift\n");
617  p1->debug ();
618  p2->debug ();
619  p3->debug ();
620  p4->debug ();
621 
622  p1->update (0);
623
624  printf ("World::debug() - update\n");
625  p1->debug ();
626  p2->debug ();
627  p3->debug ();
628  p4->debug ();
629
630  p2->shiftCoor (new Vector(-1, -1, -1));
631  p1->update (0);
632
633  p1->debug ();
634  p2->debug ();
635  p3->debug ();
636  p4->debug ();
637
638  p2->setAbsCoor (new Vector(1,2,3));
639
640
641 p1->update (0);
642
643  p1->debug ();
644  p2->debug ();
645  p3->debug ();
646  p4->debug ();
647
648  delete p1;
649 
650 
651  /*
652  WorldEntity* entity;
653  printf("counting all entities\n");
654  printf("World::debug() - enumerate()\n");
655  entity = entities->enumerate(); 
656  while( entity != NULL )
657    {
658      if( entity->bDraw ) printf("got an entity\n");
659      entity = entities->nextElement();
660    }
661  */
662}
663
664
665/**
666  \brief main loop of the world: executing all world relevant function
667
668  in this loop we synchronize (if networked), handle input events, give the heart-beat to
669  all other member-entities of the world (tick to player, enemies etc.), checking for
670  collisions drawing everything to the screen.
671*/
672void World::mainLoop()
673{
674  this->lastFrame = SDL_GetTicks ();
675  PRINTF(3)("World::mainLoop() - Entering main loop\n");
676  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
677    {
678      PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
679      // Network
680      this->synchronize ();
681      // Process input
682      this->handleInput ();
683      if( this->bQuitCurrentGame || this->bQuitOrxonox)
684          break;
685      // Process time
686      this->tick ();
687      // Update the state
688      this->update ();     
689      // Process collision
690      this->collide ();
691      // Draw
692      this->display ();
693
694      //      for( int i = 0; i < 5000000; i++) {}
695      /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/
696    }
697  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
698}
699
700
701/**
702   \brief synchronize local data with remote data
703*/
704void World::synchronize ()
705{
706  // Get remote input
707  // Update synchronizables
708}
709
710
711/**
712   \brief run all input processing
713
714   the command node is the central input event dispatcher. the node uses the even-queue from
715   sdl and has its own event-passing-queue.
716*/
717void World::handleInput ()
718{
719  // localinput
720  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
721  cn->process();
722  // remoteinput
723}
724
725
726/**
727   \brief advance the timeline
728
729   this calculates the time used to process one frame (with all input handling, drawing, etc)
730   the time is mesured in ms and passed to all world-entities and other classes that need
731   a heart-beat.
732*/
733void World::tick ()
734{
735  Uint32 currentFrame = SDL_GetTicks();
736  if(!this->bPause)
737    {
738      this->dt = currentFrame - this->lastFrame;
739     
740      if( this->dt > 0)
741        {
742          float fps = 1000/dt;
743          PRINTF(3)("fps = %f\n", fps);
744        }
745      else
746        {
747          /* the frame-rate is limited to 100 frames per second, all other things are for
748             nothing.
749          */
750          PRINTF(2)("fps = 1000 - frame rate is adjusted\n");
751          SDL_Delay(10);
752          this->dt = 10;
753        }
754      //this->timeSlice (dt);
755     
756      /* function to let all entities tick (iterate through list) */
757      WorldEntity* entity;
758      float seconds = this->dt / 1000.0;     
759      this->gameTime += seconds;
760      entity = entities->enumerate(); 
761      while( entity != NULL) 
762        { 
763          entity->tick (seconds);
764          entity = entities->nextElement();
765        }
766      //skySphere->updatePosition(localCamera->absCoordinate);
767     
768      /* update tick the rest */
769      this->trackManager->tick(this->dt);
770      this->localCamera->tick(this->dt);
771      this->garbageCollector->tick(seconds);
772    }
773  this->lastFrame = currentFrame;
774}
775
776
777/**
778   \brief this function gives the world a consistant state
779
780   after ticking (updating the world state) this will give a constistant
781   state to the whole system.
782*/
783void World::update()
784{
785  this->garbageCollector->update();
786  this->nullParent->update (dt);
787}
788
789
790/**
791   \brief render the current frame
792   
793   clear all buffers and draw the world
794*/
795void World::display ()
796{
797  // clear buffer
798  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
799  // set camera
800  this->localCamera->apply ();
801  // draw world
802  this->draw();
803  // draw HUD
804  /* \todo draw HUD */
805  // flip buffers
806  SDL_GL_SwapBuffers();
807  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
808  //SDL_Flip (screen);
809}
810
811
812/**
813   \brief add and spawn a new entity to this world
814   \param entity to be added
815*/
816void World::spawn(WorldEntity* entity)
817{
818  this->entities->add (entity);
819  entity->postSpawn ();
820}
821
822
823/**
824   \brief add and spawn a new entity to this world
825   \param entity to be added
826   \param absCoor At what coordinates to add this entity.
827   \param absDir In which direction should it look.
828*/
829void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
830{
831  this->entities->add (entity);
832
833  entity->setAbsCoor (absCoor);
834  entity->setAbsDir (absDir);
835
836  entity->postSpawn ();
837}
838
839
840/**
841   \brief add and spawn a new entity to this world
842   \param entity to be added
843   \param entity to be added to (PNode)
844   \param At what relative  coordinates to add this entity.
845   \param In which relative direction should it look.
846*/
847void World::spawn(WorldEntity* entity, PNode* parentNode, 
848                  Vector* relCoor, Quaternion* relDir, 
849                  int parentingMode)
850{
851  this->nullParent = NullParent::getInstance();
852  if( parentNode != NULL)
853    {
854      parentNode->addChild (entity);
855     
856      entity->setRelCoor (relCoor);
857      entity->setRelDir (relDir);
858      entity->setMode(parentingMode);
859     
860      this->entities->add (entity);
861     
862      entity->postSpawn ();
863    }
864}
865
866
867
868/**
869  \brief commands that the world must catch
870  \returns false if not used by the world
871*/
872bool World::command(Command* cmd)
873{
874  if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
875  else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
876  else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
877  else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
878  else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
879  else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);
880 
881  return false;
882}
883
Note: See TracBrowser for help on using the repository browser.