Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/textEngine: added bind-node ability, so now the text tries to follow a given PNode (currently trackNode)
the work is not finished, so do not expect too much

File size: 21.8 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 "glfont.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()->debug();
149  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
150  ResourceManager::getInstance()->debug();
151
152  delete WorldInterface::getInstance();
153
154  delete this->nullParent;
155  delete this->entities;
156  delete this->lightMan;
157  delete this->trackManager;
158}
159
160/**
161   \brief initializes the world.
162
163   set all stuff here that is world generic and does not use to much memory
164   because the real init() function StoryEntity::init() will be called
165   shortly before start of the game. 
166   since all worlds are initiated/referenced before they will be started.
167   NO LEVEL LOADING HERE - NEVER!
168*/
169void World::init(char* name, int worldID)
170{
171  this->setClassName ("World");
172
173  this->worldName = name;
174  this->debugWorldNr = worldID;
175  this->entities = new tList<WorldEntity>();
176}
177
178
179/**
180   \brief this is executed before load
181
182   since the load function sometimes needs data, that has been init before
183   the load and after the proceeding storyentity has finished
184*/
185ErrorMessage World::preLoad()
186{
187  /* init the world interface */
188  WorldInterface* wi = WorldInterface::getInstance();
189  wi->init(this);
190  this->garbageCollector = GarbageCollector::getInstance();
191}
192
193
194/**
195   \brief loads the World by initializing all resources, and set their default values.
196*/
197ErrorMessage World::load()
198{
199  //  BezierCurve* tmpCurve = new BezierCurve();
200  if(this->debugWorldNr != -1)
201    {
202      // initializing Font
203      testFont = new FontSet();
204      testFont->buildFont("../data/pictures/font.tga");
205      tmpFont = new GLFont("../data/fonts/dark_crystal.ttf");
206      this->glmis->step();
207      // initializing the TrackManager
208      trackManager = TrackManager::getInstance();
209      trackManager->addPoint(Vector(0,0,0));
210      trackManager->addPoint(Vector(100, -40, 5));
211      trackManager->addPoint(Vector(200,-40,-8));
212      trackManager->addPoint(Vector(250, -35, -2));
213      trackManager->addPoint(Vector(320,-33,-.55));
214      trackManager->setDuration(3);
215      trackManager->setSavePoint();
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            tmpFont->setBindNode(tn);
350
351            //localCamera->setParent(TrackNode::getInstance());
352            tn->addChild(this->localCamera);
353            //      localCamera->lookAt(tn);
354            this->localPlayer->setMode(PNODE_ALL);
355            //Vector* cameraOffset = new Vector (0, 5, -10);
356            trackManager->condition(2, LEFTRIGHT, this->localPlayer);
357            this->glmis->step();
358
359            break;
360          }
361        case DEBUG_WORLD_1:
362          {
363            lightMan->setPosition(.0, .0, .0);
364            lightMan->setAttenuation(1.0, .01, 0.0);
365            lightMan->setSpecularColor(1,0,0);
366            this->nullParent = NullParent::getInstance ();
367            this->nullParent->setName ("NullParent");
368
369            // create a player
370            WorldEntity* myPlayer = new Player();
371            myPlayer->setName ("player");
372            this->spawn(myPlayer);
373            this->localPlayer = myPlayer;           
374           
375            // bind input
376            Orxonox *orx = Orxonox::getInstance();
377            orx->getLocalInput()->bind (myPlayer);
378           
379            // bind camera
380            this->localCamera = new Camera ();
381            this->localCamera->setName ("camera");
382            this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
383            this->localCamera->setParent(this->localPlayer);
384
385            // Create SkySphere
386            skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
387            this->localPlayer->addChild(this->skySphere);
388
389            Vector* es = new Vector (20, 0, 0);
390            Quaternion* qs = new Quaternion ();
391
392            lightMan->getLight(0)->setParent(trackManager->getTrackNode());
393            break;
394          }
395        default:
396          printf("World::load() - no world with ID %i found", this->debugWorldNr );
397        }
398    }
399  else if(this->worldName != NULL)
400    {
401
402    }
403
404  // initialize debug coord system
405  objectList = glGenLists(1);
406  glNewList (objectList, GL_COMPILE);
407 
408  trackManager->drawGraph(.01);
409  trackManager->debug(2);
410  glEndList();
411
412  terrain = new Terrain("../data/worlds/newGround.obj");
413  terrain->setRelCoor(new Vector(0,-10,0));
414  this->spawn(terrain);
415
416}
417
418
419/**
420   \brief initializes a new World shortly before start
421
422   this is the function, that will be loaded shortly before the world is
423   started
424*/
425ErrorMessage World::init()
426{
427  this->bPause = false;
428  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
429  cn->addToWorld(this);
430  cn->enable(true);
431}
432
433
434/**
435   \brief starts the World
436*/
437ErrorMessage World::start()
438{
439  PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
440  this->bQuitOrxonox = false;
441  this->bQuitCurrentGame = false;
442  this->mainLoop();
443}
444
445/**
446   \brief stops the world.
447
448   This happens, when the player decides to end the Level.
449*/
450ErrorMessage World::stop()
451{
452  PRINTF(3)("World::stop() - got stop signal\n");
453  this->bQuitCurrentGame = true;
454}
455
456/**
457   \brief pauses the Game
458*/
459ErrorMessage World::pause()
460{
461  this->isPaused = true;
462}
463
464/**
465   \brief ends the pause Phase
466*/
467ErrorMessage World::resume()
468{
469  this->isPaused = false;
470}
471
472/**
473   \brief destroys the World
474*/
475ErrorMessage World::destroy()
476{
477
478}
479
480/**
481   \brief shows the loading screen
482*/
483void World::displayLoadScreen ()
484{
485  PRINTF(3)("World::displayLoadScreen - start\n"); 
486 
487  //GLMenuImageScreen*
488  this->glmis = GLMenuImageScreen::getInstance();
489  this->glmis->init();
490  this->glmis->setMaximum(8);
491  this->glmis->draw();
492 
493  PRINTF(3)("World::displayLoadScreen - end\n"); 
494}
495
496/**
497   \brief removes the loadscreen, and changes over to the game
498
499   \todo take out the delay
500*/
501void World::releaseLoadScreen ()
502{
503  PRINTF(3)("World::releaseLoadScreen - start\n"); 
504  this->glmis->setValue(this->glmis->getMaximum());
505  //SDL_Delay(500);
506  PRINTF(3)("World::releaseLoadScreen - end\n"); 
507}
508
509
510/**
511   \brief gets the list of entities from the world
512   \returns entity list
513*/
514tList<WorldEntity>* World::getEntities()
515{
516  return this->entities;
517}
518
519
520/**
521   \brief this returns the current game time
522   \returns elapsed game time
523*/
524double World::getGameTime()
525{
526  return this->gameTime;
527}
528
529
530/**
531    \brief checks for collisions
532   
533    This method runs through all WorldEntities known to the world and checks for collisions
534    between them. In case of collisions the collide() method of the corresponding entities
535    is called.
536*/
537void World::collide ()
538{
539  /*
540  List *a, *b;
541  WorldEntity *aobj, *bobj;
542   
543  a = entities;
544 
545  while( a != NULL)
546    {
547      aobj = a->nextElement();
548      if( aobj->bCollide && aobj->collisioncluster != NULL)
549        {
550          b = a->nextElement();
551          while( b != NULL )
552            {
553              bobj = b->nextElement();
554              if( bobj->bCollide && bobj->collisioncluster != NULL )
555                {
556                  unsigned long ahitflg, bhitflg;
557                  if( check_collision ( &aobj->place, aobj->collisioncluster,
558                                        &ahitflg, &bobj->place, bobj->collisioncluster,
559                                        &bhitflg) );
560                  {
561                    aobj->collide (bobj, ahitflg, bhitflg);
562                    bobj->collide (aobj, bhitflg, ahitflg);
563                  }
564                }
565              b = b->nextElement();
566            }
567        }
568      a = a->enumerate();
569    }
570  */
571}
572
573/**
574    \brief runs through all entities calling their draw() methods
575*/
576void World::draw ()
577{
578  /* draw entities */
579  WorldEntity* entity;
580  glLoadIdentity();
581
582  //entity = this->entities->enumerate();
583  tIterator<WorldEntity>* iterator = this->entities->getIterator();
584  entity = iterator->nextElement();
585  while( entity != NULL ) 
586    { 
587      if( entity->bDraw ) entity->draw();
588      //entity = this->entities->nextElement();
589      entity = iterator->nextElement();
590    }
591  delete iterator;
592 
593  glCallList (objectList);
594  //! \todo skysphere is a WorldEntity and should be inside of the world-entity-list.
595  skySphere->draw();
596
597  testFont->printText(0, 0, 1, "orxonox_" PACKAGE_VERSION);
598  tmpFont->draw();
599
600  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
601}
602
603
604/**
605   \brief function to put your own debug stuff into it. it can display informations about
606   the current class/procedure
607*/
608void World::debug()
609{
610  PRINTF(2)("debug() - starting debug\n");
611  PNode* p1 = NullParent::getInstance ();
612  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
613  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
614  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
615
616  p1->debug ();
617  p2->debug ();
618  p3->debug ();
619  p4->debug ();
620
621  p1->shiftCoor (new Vector(-1, -1, -1));
622
623  printf("World::debug() - shift\n");
624  p1->debug ();
625  p2->debug ();
626  p3->debug ();
627  p4->debug ();
628 
629  p1->update (0);
630
631  printf ("World::debug() - update\n");
632  p1->debug ();
633  p2->debug ();
634  p3->debug ();
635  p4->debug ();
636
637  p2->shiftCoor (new Vector(-1, -1, -1));
638  p1->update (0);
639
640  p1->debug ();
641  p2->debug ();
642  p3->debug ();
643  p4->debug ();
644
645  p2->setAbsCoor (new Vector(1,2,3));
646
647
648 p1->update (0);
649
650  p1->debug ();
651  p2->debug ();
652  p3->debug ();
653  p4->debug ();
654
655  delete p1;
656 
657 
658  /*
659  WorldEntity* entity;
660  printf("counting all entities\n");
661  printf("World::debug() - enumerate()\n");
662  entity = entities->enumerate(); 
663  while( entity != NULL )
664    {
665      if( entity->bDraw ) printf("got an entity\n");
666      entity = entities->nextElement();
667    }
668  */
669}
670
671
672/**
673  \brief main loop of the world: executing all world relevant function
674
675  in this loop we synchronize (if networked), handle input events, give the heart-beat to
676  all other member-entities of the world (tick to player, enemies etc.), checking for
677  collisions drawing everything to the screen.
678*/
679void World::mainLoop()
680{
681  this->lastFrame = SDL_GetTicks ();
682  PRINTF(3)("World::mainLoop() - Entering main loop\n");
683  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
684    {
685      PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
686      // Network
687      this->synchronize ();
688      // Process input
689      this->handleInput ();
690      if( this->bQuitCurrentGame || this->bQuitOrxonox)
691          break;
692      // Process time
693      this->tick ();
694      // Update the state
695      this->update ();     
696      // Process collision
697      this->collide ();
698      // Draw
699      this->display ();
700
701      //      for( int i = 0; i < 5000000; i++) {}
702      /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/
703    }
704  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
705}
706
707
708/**
709   \brief synchronize local data with remote data
710*/
711void World::synchronize ()
712{
713  // Get remote input
714  // Update synchronizables
715}
716
717
718/**
719   \brief run all input processing
720
721   the command node is the central input event dispatcher. the node uses the even-queue from
722   sdl and has its own event-passing-queue.
723*/
724void World::handleInput ()
725{
726  // localinput
727  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
728  cn->process();
729  // remoteinput
730}
731
732
733/**
734   \brief advance the timeline
735
736   this calculates the time used to process one frame (with all input handling, drawing, etc)
737   the time is mesured in ms and passed to all world-entities and other classes that need
738   a heart-beat.
739*/
740void World::tick ()
741{
742  Uint32 currentFrame = SDL_GetTicks();
743  if(!this->bPause)
744    {
745      this->dt = currentFrame - this->lastFrame;
746     
747      if( this->dt > 0)
748        {
749          float fps = 1000/dt;
750
751          // temporary, only for showing how fast the text-engine is
752          char tmpChar[20];
753          sprintf(tmpChar, "fps: %4.0f", fps);
754          tmpFont->setText(tmpChar);
755          tmpFont->createTexture();
756        }
757      else
758        {
759          /* the frame-rate is limited to 100 frames per second, all other things are for
760             nothing.
761          */
762          PRINTF(2)("fps = 1000 - frame rate is adjusted\n");
763          SDL_Delay(10);
764          this->dt = 10;
765        }
766      //this->timeSlice (dt);
767     
768      /* function to let all entities tick (iterate through list) */
769      float seconds = this->dt / 1000.0;     
770      this->gameTime += seconds;
771      //entity = entities->enumerate();
772      tIterator<WorldEntity>* iterator = this->entities->getIterator();
773      WorldEntity* entity = iterator->nextElement();
774      while( entity != NULL) 
775        { 
776          entity->tick (seconds);
777          entity = iterator->nextElement();
778        }
779      delete iterator;
780      //skySphere->updatePosition(localCamera->absCoordinate);
781     
782      /* update tick the rest */
783      this->trackManager->tick(this->dt);
784      this->localCamera->tick(this->dt);
785      this->garbageCollector->tick(seconds);
786    }
787  this->lastFrame = currentFrame;
788}
789
790
791/**
792   \brief this function gives the world a consistant state
793
794   after ticking (updating the world state) this will give a constistant
795   state to the whole system.
796*/
797void World::update()
798{
799  this->garbageCollector->update();
800  this->nullParent->update (dt);
801}
802
803
804/**
805   \brief render the current frame
806   
807   clear all buffers and draw the world
808*/
809void World::display ()
810{
811  // clear buffer
812  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
813  // set camera
814  this->localCamera->apply ();
815  // draw world
816  this->draw();
817  // draw HUD
818  /* \todo draw HUD */
819  // flip buffers
820  SDL_GL_SwapBuffers();
821  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
822  //SDL_Flip (screen);
823}
824
825
826/**
827   \brief add and spawn a new entity to this world
828   \param entity to be added
829*/
830void World::spawn(WorldEntity* entity)
831{
832  this->entities->add (entity);
833  entity->postSpawn ();
834}
835
836
837/**
838   \brief add and spawn a new entity to this world
839   \param entity to be added
840   \param absCoor At what coordinates to add this entity.
841   \param absDir In which direction should it look.
842*/
843void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
844{
845  this->entities->add (entity);
846
847  entity->setAbsCoor (absCoor);
848  entity->setAbsDir (absDir);
849
850  entity->postSpawn ();
851}
852
853
854/**
855   \brief add and spawn a new entity to this world
856   \param entity to be added
857   \param entity to be added to (PNode)
858   \param At what relative  coordinates to add this entity.
859   \param In which relative direction should it look.
860*/
861void World::spawn(WorldEntity* entity, PNode* parentNode, 
862                  Vector* relCoor, Quaternion* relDir, 
863                  int parentingMode)
864{
865  this->nullParent = NullParent::getInstance();
866  if( parentNode != NULL)
867    {
868      parentNode->addChild (entity);
869     
870      entity->setRelCoor (relCoor);
871      entity->setRelDir (relDir);
872      entity->setMode(parentingMode);
873     
874      this->entities->add (entity);
875     
876      entity->postSpawn ();
877    }
878}
879
880
881
882/**
883  \brief commands that the world must catch
884  \returns false if not used by the world
885*/
886bool World::command(Command* cmd)
887{
888  if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
889  else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
890  else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
891  else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
892  else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
893  else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);
894 
895  return false;
896}
897
Note: See TracBrowser for help on using the repository browser.