Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: added testbullet class. some changes in the weapon class to make it look much better and also more performant

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