Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/parenting/src/world.cc @ 3335

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

orxonox/branches/parenting: added TrackManager to world.cc. (just the constructor), and moved some functions.

File size: 19.3 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#include "world.h"
18#include "world_entity.h"
19#include "collision.h"
20#include "track_manager.h"
21#include "track.h"
22#include "player.h"
23#include "command_node.h"
24#include "camera.h"
25#include "environment.h"
26#include "p_node.h"
27#include "null_parent.h"
28#include "helper_parent.h"
29
30using namespace std;
31
32
33/**
34    \brief create a new World
35   
36    This creates a new empty world!
37*/
38World::World (char* name)
39{
40  this->setClassName ("World");
41  this->worldName = name;
42  this->debugWorldNr = -1;
43  this->entities = new tList<WorldEntity>();
44}
45
46World::World (int worldID)
47{
48  this->debugWorldNr = worldID;
49  this->worldName = NULL;
50  this->entities = new tList<WorldEntity>();
51}
52
53/**
54    \brief remove the World from memory
55   
56    delete everything explicitly, that isn't contained in the parenting tree!
57    things contained in the tree are deleted automaticaly
58*/
59World::~World ()
60{
61  printf("World::~World() - deleting current world\n");
62  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
63  cn->unbind(this->localPlayer);
64  cn->reset();
65  this->localCamera->destroy();
66
67  this->nullParent->destroy ();
68
69  /*
70  WorldEntity* entity = entities->enumerate(); 
71  while( entity != NULL )
72    {
73      entity->destroy();
74      entity = entities->nextElement();
75    }
76  this->entities->destroy();
77  */
78
79  /* FIX the parent list has to be cleared - not possible if we got the old list also*/
80
81
82  //delete this->entities;
83  //delete this->localCamera;
84  /* this->localPlayer hasn't to be deleted explicitly, it is
85     contained in entities*/
86}
87
88GLfloat ctrlpoints[4][3] = {
89  {20.0, 10.0, 5.0}, {40.0, -10.0, 0.0},
90  {60.0, -10.0, 5.0}, {80.0, 10.0, 5.0}};
91
92
93ErrorMessage World::init()
94{
95  this->bPause = false;
96  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
97  cn->addToWorld(this);
98  cn->enable(true);
99
100  glMap1f (GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);
101  glEnable (GL_MAP1_VERTEX_3);
102 
103  //theNurb = gluNewNurbsRenderer ();
104  //gluNurbsProperty (theNurb, GLU_NURBS_MODE, GLU_NURBS_TESSELLATOR);
105  //gluNurbsProperty (theNurb, GLU_NURBS_VERTEX, vertexCallback );
106}
107
108
109
110ErrorMessage World::start()
111{
112  printf("World::start() - starting current World: nr %i\n", this->debugWorldNr);
113  this->bQuitOrxonox = false;
114  this->bQuitCurrentGame = false;
115  this->mainLoop();
116}
117
118ErrorMessage World::stop()
119{
120  printf("World::stop() - got stop signal\n");
121  this->bQuitCurrentGame = true;
122}
123
124ErrorMessage World::pause()
125{
126  this->isPaused = true;
127}
128
129ErrorMessage World::resume()
130{
131  this->isPaused = false;
132}
133
134void World::destroy()
135{
136
137}
138
139
140
141
142void World::load()
143{
144  if(this->debugWorldNr != -1)
145    {
146      trackManager = TrackManager::getInstance();
147      switch(this->debugWorldNr)
148        {
149          /*
150            this loads the hard-coded debug world. this only for simplicity and will be
151            removed by a reald world-loader, which interprets a world-file.
152            if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
153            make whatever you want...
154           */
155        case DEBUG_WORLD_0:
156          {
157            this->nullParent = NullParent::getInstance ();
158            this->nullParent->setName ("NullParent");
159
160            // create some path nodes
161            this->pathnodes = new Vector[6];
162            this->pathnodes[0] = Vector(0, 0, 0);
163            this->pathnodes[1] = Vector(1000, 0, 0);
164            //      this->pathnodes[2] = Vector(-100, 140, 0);
165            //      this->pathnodes[3] = Vector(0, 180, 0);
166            //      this->pathnodes[4] = Vector(100, 140, 0);
167            //      this->pathnodes[5] = Vector(100, 40, 0);
168           
169            // create the tracks
170            this->tracklen = 2;
171            this->track = new Track[2];
172            for( int i = 0; i < this->tracklen; i++)
173              {
174                this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
175              }
176            // !\todo old track-system has to be removed
177
178            //create helper for player
179            HelperParent* hp = new HelperParent ();
180            /* the player has to be added to this helper */
181
182            // create a player
183            WorldEntity* myPlayer = new Player ();
184            myPlayer->setName ("player");
185            this->spawn (myPlayer);
186            this->localPlayer = myPlayer;           
187
188            // bind input
189            Orxonox *orx = Orxonox::getInstance ();
190            orx->getLocalInput()->bind (myPlayer);
191           
192            // bind camera
193            this->localCamera = new Camera(this);
194            this->localCamera->setName ("camera");
195            this->getCamera()->bind (myPlayer);
196            this->localPlayer->addChild (this->localCamera);
197           
198
199            Vector* es = new Vector (50, 0, 5);
200            Quaternion* qs = new Quaternion ();
201            WorldEntity* env = new Environment();
202            env->setName ("env");
203            this->spawn(env, es, qs);
204
205
206            break;
207          }
208        case DEBUG_WORLD_1:
209          {
210            this->nullParent = NullParent::getInstance ();
211            this->nullParent->setName ("NullParent");
212
213            // create some path nodes
214            this->pathnodes = new Vector[6];
215            this->pathnodes[0] = Vector(0, 0, 0);
216            this->pathnodes[1] = Vector(20, 10, 10);
217            this->pathnodes[2] = Vector(40, 0, 10);
218            this->pathnodes[3] = Vector(60, 10, 0);
219            this->pathnodes[4] = Vector(80, 20, 10);
220            this->pathnodes[5] = Vector(30, 50, 0);
221           
222
223
224
225            // create the tracks
226            this->tracklen = 6;
227            this->track = new Track[6];
228            for( int i = 0; i < this->tracklen; i++)
229              {
230                this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
231              }
232
233            // create a player
234            WorldEntity* myPlayer = new Player();
235            myPlayer->setName ("player");
236            this->spawn(myPlayer);
237            this->localPlayer = myPlayer;           
238           
239            // bind input
240            Orxonox *orx = Orxonox::getInstance();
241            orx->getLocalInput()->bind (myPlayer);
242           
243            // bind camera
244            this->localCamera = new Camera (this);
245            this->localCamera->setName ("camera");
246            this->getCamera()->bind (myPlayer); 
247            this->localPlayer->addChild (this->localCamera);
248            break;
249          }
250        default:
251          printf("World::load() - no world with ID %i found", this->debugWorldNr );
252        }
253    }
254  else if(this->worldName != NULL)
255    {
256
257    }
258
259  // initialize debug coord system
260  objectList = glGenLists(1);
261  glNewList (objectList, GL_COMPILE);
262  glLoadIdentity();
263  glColor3f(1.0,0,0);
264  glBegin(GL_QUADS);
265
266  int sizeX = 100;
267  int sizeZ = 80;
268  float length = 1000;
269  float width = 200;
270  float widthX = float (length /sizeX);
271  float widthZ = float (width /sizeZ);
272 
273  float height [sizeX][sizeZ];
274  Vector normal_vectors[sizeX][sizeZ];
275 
276 
277  for ( int i = 0; i<sizeX-1; i+=1)
278    for (int j = 0; j<sizeZ-1;j+=1)
279      //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
280#ifdef __WIN32__
281      height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
282#else
283      height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
284#endif
285
286  //Die Huegel ein wenig glaetten
287  for (int h=1; h<2;h++)
288    for (int i=1;i<sizeX-2 ;i+=1 )
289      for(int j=1;j<sizeZ-2;j+=1)
290        height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
291 
292  //Berechnung von normalen Vektoren
293  for(int i=1;i<sizeX-2;i+=1)
294    for(int j=1;j<sizeZ-2 ;j+=1)
295      {
296        Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
297        Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
298        Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
299        Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
300        Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
301       
302        Vector c1 = v2 - v1;
303        Vector c2 = v3 - v1;
304        Vector c3=  v4 - v1;
305        Vector c4 = v5 - v1;
306        Vector zero = Vector (0,0,0);
307        normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
308        normal_vectors[i][j].normalize();
309      }
310
311  int snowheight=3;
312  for ( int i = 0; i<sizeX; i+=1)
313    for (int j = 0; j<sizeZ;j+=1)
314      {   
315        Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
316        Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
317        Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
318        Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
319        float a[3];
320        if(height[i][j]<snowheight){
321          a[0]=0;
322          a[1]=1.0-height[i][j]/10-.3;
323          a[2]=0;
324          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
325        }
326        else{
327            a[0]=1.0;
328            a[1]=1.0;
329            a[2]=1.0;
330            glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
331           
332        }
333        glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
334        glVertex3f(v1.x, v1.y, v1.z);
335        if(height[i+1][j]<snowheight){
336          a[0]=0;
337          a[1] =1.0-height[i+1][j]/10-.3;
338          a[2]=0;
339          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
340        }
341        else{
342          a[0]=1.0;
343          a[1]=1.0;
344          a[2]=1.0;
345          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
346         
347        }
348        glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
349        glVertex3f(v2.x, v2.y, v2.z);
350        if(height[i+1][j+1]<snowheight){
351          a[0]=0;
352          a[1] =1.0-height[i+1][j+1]/10-.3;
353          a[2]=0;
354          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
355        }
356        else{
357          a[0]=1.0;
358          a[1]=1.0;
359          a[2]=1.0;
360          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
361         
362         
363        }
364        glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
365        glVertex3f(v3.x, v3.y, v3.z);
366        if(height[i][j+1]<snowheight){
367          a[0]=0;
368          a[1] =1.0-height[i+1][j+1]/10-.3;
369          a[2]=0;
370          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
371        }
372        else{
373          a[0]=1.0;
374          a[1]=1.0;
375          a[2]=1.0;
376          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
377        }
378        glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
379        glVertex3f(v4.x, v4.y, v4.z);
380       
381      }
382  glEnd();
383  /* 
384  glBegin(GL_LINES);
385  for( float x = -128.0; x < 128.0; x += 25.0)
386    {
387      for( float y = -128.0; y < 128.0; y += 25.0)
388        {
389          glColor3f(1,0,0);
390          glVertex3f(x,y,-128.0);
391          glVertex3f(x,y,0.0);
392          glColor3f(0.5,0,0);
393          glVertex3f(x,y,0.0);
394          glVertex3f(x,y,128.0);
395        }
396    }
397  for( float y = -128.0; y < 128.0; y += 25.0)
398    {
399      for( float z = -128.0; z < 128.0; z += 25.0)
400        {
401          glColor3f(0,1,0);
402          glVertex3f(-128.0,y,z);
403          glVertex3f(0.0,y,z);
404          glColor3f(0,0.5,0);
405          glVertex3f(0.0,y,z);
406          glVertex3f(128.0,y,z);
407        }
408    }
409  for( float x = -128.0; x < 128.0; x += 25.0)
410    {
411      for( float z = -128.0; z < 128.0; z += 25.0)
412        {
413          glColor3f(0,0,1);
414          glVertex3f(x,-128.0,z);
415          glVertex3f(x,0.0,z);
416          glColor3f(0,0,0.5);
417          glVertex3f(x,0.0,z);
418          glVertex3f(x,128.0,z);
419        }
420     
421    }
422  */ 
423  //draw track
424  glBegin(GL_LINES);
425  glColor3f(0.0, 1.0, 1.0);
426  for( int i = 0; i < tracklen; i++)
427    {
428      glVertex3f(pathnodes[i].x,pathnodes[i].y,pathnodes[i].z);
429      glVertex3f(pathnodes[(i+1)%tracklen].x,pathnodes[(i+1)%tracklen].y,pathnodes[(i+1)%tracklen].z);
430    }
431  glEnd();
432
433  glBegin(GL_LINE_STRIP);
434  glColor3f(1.0, 5.0, 1.0);
435  for( int i = 0; i <= 30; i++)
436    {
437      glEvalCoord1f ((GLfloat) i/30.0);
438    }
439  glEnd();
440  glEndList();
441}
442
443
444/**
445    \brief checks for collisions
446   
447    This method runs through all WorldEntities known to the world and checks for collisions
448    between them. In case of collisions the collide() method of the corresponding entities
449    is called.
450*/
451void World::collide ()
452{
453  /*
454  List *a, *b;
455  WorldEntity *aobj, *bobj;
456   
457  a = entities;
458 
459  while( a != NULL)
460    {
461      aobj = a->nextElement();
462      if( aobj->bCollide && aobj->collisioncluster != NULL)
463        {
464          b = a->nextElement();
465          while( b != NULL )
466            {
467              bobj = b->nextElement();
468              if( bobj->bCollide && bobj->collisioncluster != NULL )
469                {
470                  unsigned long ahitflg, bhitflg;
471                  if( check_collision ( &aobj->place, aobj->collisioncluster,
472                                        &ahitflg, &bobj->place, bobj->collisioncluster,
473                                        &bhitflg) );
474                  {
475                    aobj->collide (bobj, ahitflg, bhitflg);
476                    bobj->collide (aobj, bhitflg, ahitflg);
477                  }
478                }
479              b = b->nextElement();
480            }
481        }
482      a = a->enumerate();
483    }
484  */
485}
486
487/**
488    \brief runs through all entities calling their draw() methods
489*/
490void World::draw ()
491{
492  // draw entities
493  WorldEntity* entity;
494  entity = this->entities->enumerate();
495  while( entity != NULL ) 
496    { 
497      if( entity->bDraw ) entity->draw();
498      entity = this->entities->nextElement();
499    } 
500 
501  // draw debug coord system
502  glCallList (objectList);
503
504}
505
506/**
507    \brief updates Placements and notifies entities when they left the
508    world
509   
510    This runs trough all WorldEntities and maps Locations to Placements
511    if they are bound, checks whether they left the level boundaries
512    and calls appropriate functions.
513*/
514void World::update ()
515{
516  /*
517  //List<WorldEntity> *l;
518  WorldEntity* entity;
519  Location* loc;
520  Placement* plc;
521  Uint32 t;
522 
523  //  l = entities->enumerate();
524  entity = this->entities->enumerate();
525  while( entity != NULL )
526    {
527
528     
529      if( !entity->isFree() )
530        {
531          loc = entity->getLocation();
532          plc = entity->getPlacement();
533          t = loc->part;
534         
535          if( t >= tracklen )
536            {
537              printf("An entity is out of the game area\n");
538              entity->leftWorld ();
539            }
540          else
541            {
542              while( track[t].mapCoords( loc, plc) )
543                {
544                  track[t].postLeave (entity);
545                  if( loc->part >= tracklen )
546                    {
547                      printf("An entity has left the game area\n");
548                      entity->leftWorld ();
549                      break;
550                    }
551                  track[loc->part].postEnter (entity);
552                }
553            }
554        }
555      else
556        {
557        }
558     
559      entity = entities->nextElement();
560    }
561  */ 
562}
563
564/**
565    \brief relays the passed time since the last frame to entities and Track parts
566    \param deltaT: the time passed since the last frame in milliseconds
567*/
568void World::timeSlice (Uint32 deltaT)
569{
570  //List<WorldEntity> *l;
571  WorldEntity* entity;
572  float seconds = deltaT / 1000.0;
573 
574  this->nullParent->update (seconds);
575  //this->nullParent->processTick (seconds);
576
577  entity = entities->enumerate(); 
578  while( entity != NULL) 
579    { 
580      entity->tick (seconds);
581      entity = entities->nextElement();
582    }
583
584  //for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
585}
586
587/**
588   \brief removes level data from memory
589*/
590void World::unload()
591{
592  if( pathnodes) delete []pathnodes;
593  if( track) delete []pathnodes;
594}
595
596
597
598/**
599   \brief calls the correct mapping function to convert a given "look at"-Location to a
600   Camera Placement
601*/
602void World::calcCameraPos (Location* loc, Placement* plc)
603{
604  track[loc->part].mapCamera (loc, plc);
605}
606
607
608void World::setTrackLen(Uint32 len)
609{
610  this->tracklen = len;
611}
612
613int World::getTrackLen()
614{
615  return this->tracklen;
616}
617
618
619
620/**
621   \brief function to put your own debug stuff into it. it can display informations about
622   the current class/procedure
623*/
624void World::debug()
625{
626  printf ("World::debug() - starting debug\n");
627  PNode* p1 = NullParent::getInstance ();
628  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
629  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
630  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
631
632  p1->debug ();
633  p2->debug ();
634  p3->debug ();
635  p4->debug ();
636
637  p1->shiftCoor (new Vector(-1, -1, -1));
638
639  printf("World::debug() - shift\n");
640  p1->debug ();
641  p2->debug ();
642  p3->debug ();
643  p4->debug ();
644 
645  p1->update (1);
646
647  printf ("World::debug() - update\n");
648  p1->debug ();
649  p2->debug ();
650  p3->debug ();
651  p4->debug ();
652
653  p2->shiftCoor (new Vector(-1, -1, -1));
654  p1->update (2);
655
656  p1->debug ();
657  p2->debug ();
658  p3->debug ();
659  p4->debug ();
660
661  p2->setAbsCoor (new Vector(1,2,3));
662
663
664 p1->update (2);
665
666  p1->debug ();
667  p2->debug ();
668  p3->debug ();
669  p4->debug ();
670
671  p1->destroy ();
672 
673 
674  /*
675  WorldEntity* entity;
676  printf("counting all entities\n");
677  printf("World::debug() - enumerate()\n");
678  entity = entities->enumerate(); 
679  while( entity != NULL )
680    {
681      if( entity->bDraw ) printf("got an entity\n");
682      entity = entities->nextElement();
683    }
684  */
685}
686
687
688/*
689  \brief main loop of the world: executing all world relevant function
690
691  in this loop we synchronize (if networked), handle input events, give the heart-beat to
692  all other member-entities of the world (tick to player, enemies etc.), checking for
693  collisions drawing everything to the screen.
694*/
695void World::mainLoop()
696{
697  this->lastFrame = SDL_GetTicks ();
698  printf("World::mainLoop() - Entering main loop\n");
699  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
700    {
701      // Network
702      this->synchronize ();
703      // Process input
704      this->handleInput ();
705      if( this->bQuitCurrentGame || this->bQuitOrxonox)
706        {
707          printf("World::mainLoop() - leaving loop earlier...\n");
708          break;
709        }
710      // Process time
711      this->timeSlice ();
712      // Process collision
713      this->collision ();
714      // Draw
715      this->display ();
716 
717      for( int i = 0; i < 10000000; i++) {}
718    }
719  printf("World::mainLoop() - Exiting the main loop\n");
720}
721
722/**
723   \brief synchronize local data with remote data
724*/
725void World::synchronize ()
726{
727  // Get remote input
728  // Update synchronizables
729}
730
731/**
732   \brief run all input processing
733
734   the command node is the central input event dispatcher. the node uses the even-queue from
735   sdl and has its own event-passing-queue.
736*/
737void World::handleInput ()
738{
739  // localinput
740  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
741  cn->process();
742  // remoteinput
743}
744
745/**
746   \brief advance the timeline
747
748   this calculates the time used to process one frame (with all input handling, drawing, etc)
749   the time is mesured in ms and passed to all world-entities and other classes that need
750   a heart-beat.
751*/
752void World::timeSlice ()
753{
754  Uint32 currentFrame = SDL_GetTicks();
755  if(!this->bPause)
756    {
757      Uint32 dt = currentFrame - this->lastFrame;
758     
759      if(dt > 0)
760        {
761          float fps = 1000/dt;
762          printf("fps = %f\n", fps);
763        }
764      else
765        {
766          /* the frame-rate is limited to 100 frames per second, all other things are for
767             nothing.
768          */
769          printf("fps = 1000 - frame rate is adjusted\n");
770          SDL_Delay(10);
771          dt = 10;
772        }
773      this->timeSlice (dt);
774      this->update ();
775      this->localCamera->timeSlice(dt);
776    }
777  this->lastFrame = currentFrame;
778}
779
780
781/**
782   \brief compute collision detection
783*/
784void World::collision ()
785{
786  this->collide ();
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  // flip buffers
805  SDL_GL_SwapBuffers();
806}
807
808/**
809   \brief give back active camera
810   
811   this passes back the actualy active camera
812   \todo ability to define more than one camera or camera-places
813*/
814Camera* World::getCamera()
815{
816  return this->localCamera;
817}
818
819
820/**
821   \brief add and spawn a new entity to this world
822   \param entity to be added
823*/
824void World::spawn(WorldEntity* entity)
825{
826  if( this->nullParent != NULL && entity->parent == NULL)
827    this->nullParent->addChild (entity);
828
829  this->entities->add (entity);
830
831  entity->postSpawn ();
832}
833
834
835/**
836   \brief add and spawn a new entity to this world
837   \param entity to be added
838   \param location where to add
839*/
840void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
841{
842  entity->setAbsCoor (absCoor);
843  entity->setAbsDir (absDir);
844 
845  if( this->nullParent != NULL && entity->parent == NULL)
846    this->nullParent->addChild (entity);
847
848  this->entities->add (entity);
849
850  entity->postSpawn ();
851}
852
853
854
855/*
856  \brief commands that the world must catch
857  \returns false if not used by the world
858*/
859bool World::command(Command* cmd)
860{
861  return false;
862}
863
Note: See TracBrowser for help on using the repository browser.