Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 18, 2005, 11:52:15 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged trunk back to levelloader
merged with command:
svn merge -r 3499:HEAD trunk branches/levelloader

Conflicts in
C track_manager.h
C world_entities/player.cc
C world_entities/player.h
C world_entities/environment.h
C lib/coord/p_node.cc
C defs/debug.h
C track_manager.cc
C story_entities/campaign.h

solved in merge-favouring. It was quite easy because Chris only worked on the headers, and he didi it quite clean. Thats the spirit :)

Conflits in world.cc are a MESS: fix it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/levelloader/src/story_entities/world.cc

    r3604 r3605  
    1414   co-programmer: Christian Meyer
    1515*/
     16
     17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
    1618
    1719#include "world.h"
     
    2224#include "camera.h"
    2325#include "environment.h"
     26#include "primitive.h"
    2427#include "p_node.h"
    2528#include "null_parent.h"
     
    3134#include "factory.h"
    3235#include "game_loader.h"
     36#include "track_node.h"
     37#include "terrain.h"
    3338
    3439using namespace std;
     
    7984World::World (char* name)
    8085{
    81   this->setClassName ("World");
    82   this->worldName = name;
    83   this->debugWorldNr = -1;
    84   this->entities = new tList<WorldEntity>();
     86  this->init(name, -1);
     87  //NullParent* np = NullParent::getInstance();
    8588}
    8689
     
    9194World::World (int worldID)
    9295{
    93   this->debugWorldNr = worldID;
    94   this->worldName = NULL;
    95   this->entities = new tList<WorldEntity>();
     96  this->init(NULL, worldID);
    9697}
    9798
     
    104105World::~World ()
    105106{
    106   printf("World::~World() - deleting current world\n");
     107  PRINTF(3)("World::~World() - deleting current world\n");
    107108  CommandNode* cn = Orxonox::getInstance()->getLocalInput();
    108109  cn->unbind(this->localPlayer);
    109110  cn->reset();
    110111
    111   this->localCamera->destroy();
    112   this->nullParent->destroy(); 
    113   delete this->skySphere;
     112  delete this->nullParent;
     113  delete this->entities;
     114  delete this->lightMan;
     115  delete this->trackManager;
     116}
    114117  if( this->worldName) delete this->worldName;
    115118  if( this->path) delete this->path;
    116119
    117   //delete this->trackManager;
    118 
    119   /*
    120   WorldEntity* entity = entities->enumerate(); 
    121   while( entity != NULL )
    122     {
    123       entity->destroy();
    124       entity = entities->nextElement();
    125     }
    126   this->entities->destroy();
    127   */
    128 
    129   /* FIX the parent list has to be cleared - not possible if we got the old list also*/
    130 
    131 
    132   //delete this->entities;
    133   //delete this->localCamera;
    134   /* this->localPlayer hasn't to be deleted explicitly, it is
    135      contained in entities*/
     120/**
     121   \brief initializes a new World
     122*/
     123void World::init(char* name, int worldID)
     124{
     125  this->setClassName ("World");
     126
     127  this->worldName = name;
     128  this->debugWorldNr = worldID;
     129  this->entities = new tList<WorldEntity>();
     130
     131  // Enable default GL stuff
     132  glEnable(GL_DEPTH_TEST);
     133
    136134}
    137135
     
    142140ErrorMessage World::load()
    143141{
     142<<<<<<< .working
    144143       
    145144        PRINTF0("> Loading world: '%s'\n", getPath());
     
    156155        // load the campaign document
    157156        if( !XMLDoc->LoadFile())
     157=======
     158  //  BezierCurve* tmpCurve = new BezierCurve();
     159  if(this->debugWorldNr != -1)
     160    {
     161      // initializing Font
     162      testFont = new FontSet();
     163      testFont->buildFont("../data/pictures/font.tga");
     164
     165      // initializing the TrackManager
     166      trackManager = TrackManager::getInstance();
     167      trackManager->addPoint(Vector(0,0,0));
     168      trackManager->addPoint(Vector(100, -40, 5));
     169      trackManager->addPoint(Vector(200,-40,-8));
     170      trackManager->addPoint(Vector(250, -35, -2));
     171      trackManager->addPoint(Vector(320,-33,-.55));
     172      trackManager->setDuration(1);
     173      trackManager->setSavePoint();
     174      trackManager->addPoint(Vector(410, 0, 0));
     175      trackManager->addPoint(Vector(510, 20, -10));
     176      trackManager->addPoint(Vector(550, 20, -10));
     177      trackManager->addPoint(Vector(570, 20, -10));
     178      trackManager->setDuration(1);
     179     
     180      int fork11, fork12;
     181      trackManager->fork(2, &fork11, &fork12);
     182      trackManager->workOn(fork11);
     183      trackManager->addPoint(Vector(640, 25, -30));
     184      trackManager->addPoint(Vector(700, 40, -120));
     185      trackManager->addPoint(Vector(800, 50, -150));
     186      trackManager->addPoint(Vector(900, 60, -100));
     187      trackManager->addPoint(Vector(900, 60, -70));
     188      trackManager->addPoint(Vector(990, 65, -15));
     189      trackManager->addPoint(Vector(1050, 65, -10));
     190      trackManager->addPoint(Vector(1100, 65, -20));
     191      trackManager->setDuration(4);
     192
     193      trackManager->workOn(fork12);
     194      trackManager->addPoint(Vector(640, 25, 20));
     195      trackManager->addPoint(Vector(670, 50, 120));
     196      trackManager->addPoint(Vector(700, 70, 80));
     197      trackManager->addPoint(Vector(800, 70, 65));
     198      trackManager->addPoint(Vector(850, 65, 65));
     199      trackManager->addPoint(Vector(920, 35, 40));
     200      trackManager->addPoint(Vector(945, 40, 40));
     201      trackManager->addPoint(Vector(970, 24, 40));
     202      trackManager->addPoint(Vector(1000, 40, -7));
     203      trackManager->setDuration(4);
     204     
     205
     206      trackManager->join(2, fork11, fork12);
     207
     208      trackManager->workOn(5);
     209      trackManager->addPoint(Vector(1200, 60, -50));
     210      trackManager->addPoint(Vector(1300, 50, -50));
     211      trackManager->addPoint(Vector(1400, 40, -50));
     212      trackManager->addPoint(Vector(1500, 40, -60));
     213      trackManager->addPoint(Vector(1600, 35, -55));
     214      trackManager->addPoint(Vector(1700, 45, -40));
     215      trackManager->addPoint(Vector(1750, 60, -40));
     216      trackManager->addPoint(Vector(1770, 80, -40));
     217      trackManager->addPoint(Vector(1800, 100, -40));
     218      trackManager->setDuration(4);
     219
     220      trackManager->finalize();
     221
     222     
     223      /*monitor progress*/
     224      this->glmis->step();
     225
     226      // LIGHT initialisation
     227      lightMan = LightManager::getInstance();
     228      lightMan->setAmbientColor(.1,.1,.1);
     229      lightMan->addLight();
     230      //      lightMan->setAttenuation(1.0, .01, 0.0);
     231      //      lightMan->setDiffuseColor(1,1,1);
     232      //  lightMan->addLight(1);
     233      //  lightMan->setPosition(20, 10, -20);
     234      //  lightMan->setDiffuseColor(0,0,0);
     235      lightMan->debug();
     236
     237      switch(this->debugWorldNr)
     238>>>>>>> .merge-right.r3604
    158239        {
     240<<<<<<< .working
    159241                // report an error
    160242                PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     
    234316                PRINTF0("Done loading Track\n");
    235317        }
     318=======
     319          /*
     320            this loads the hard-coded debug world. this only for simplicity and will be
     321            removed by a reald world-loader, which interprets a world-file.
     322            if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
     323            make whatever you want...
     324           */
     325        case DEBUG_WORLD_0:
     326          {
     327            lightMan->setPosition(-5.0, 10.0, -40.0);
     328            this->nullParent = NullParent::getInstance ();
     329            this->nullParent->setName ("NullParent");
     330>>>>>>> .merge-right.r3604
    236331
    237332       
     
    265360    this->localPlayer->addChild (this->localCamera);
    266361
     362<<<<<<< .working
    267363       
    268364        // stuff beyond this point remains to be loaded properly
     
    270366      /*monitor progress*/
    271367  //  this->glmis->step();
    272 
     368=======
     369            //create helper for player
     370            //HelperParent* hp = new HelperParent ();
     371            /* the player has to be added to this helper */
     372>>>>>>> .merge-right.r3604
     373
     374<<<<<<< .working
     375=======
     376            // create a player
     377            this->localPlayer = new Player ();
     378            this->localPlayer->setName ("player");
     379            this->spawn (this->localPlayer);
     380            /*monitor progress*/
     381            this->glmis->step();           
     382
     383            // bind input
     384            Orxonox *orx = Orxonox::getInstance ();
     385            orx->getLocalInput()->bind (this->localPlayer);
     386           
     387            // bind camera
     388            this->localCamera = new Camera(this);
     389            this->localCamera->setName ("camera");
     390            this->localCamera->bind (this->localPlayer);
     391            /*monitor progress*/
     392            this->glmis->step();           
     393
     394>>>>>>> .merge-right.r3604
    273395            // Create SkySphere
    274             skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
     396            this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
     397            this->skySphere->setName("SkySphere");
     398            this->localCamera->addChild(this->skySphere);
     399            this->skySphere->setMode(PNODE_MOVEMENT);
    275400
    276401            /*monitor progress*/
     
    279404          //  trackManager->setBindSlave(env);
    280405
     406<<<<<<< .working
     407=======
     408           
     409            WorldEntity* env = new Environment();
     410            env->setName ("env");
     411            this->spawn(env);
     412
     413           
     414            Vector* es = new Vector (10, 5, 0);
     415            Quaternion* qs = new Quaternion ();
     416            WorldEntity* pr = new Primitive(PSPHERE);
     417            pr->setName("primitive");
     418            this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     419           
     420
     421            /*monitor progress*/
     422            this->glmis->step();
     423
     424            //      trackManager->setBindSlave(env);
     425            PNode* tn = trackManager->getTrackNode();
     426            tn->addChild(this->localPlayer);
     427
     428            //localCamera->setParent(TrackNode::getInstance());
     429            tn->addChild (this->localCamera);
     430            this->localPlayer->setMode(PNODE_ROTATE_AND_MOVE);
     431            //Vector* cameraOffset = new Vector (0, 5, -10);
     432            Vector* cameraOffset = new Vector (-10, 5, 0);
     433            this->localCamera->setRelCoor (cameraOffset);
     434            trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     435
     436            break;
     437          }
     438        case DEBUG_WORLD_1:
     439          {
     440            lightMan->setPosition(.0, .0, .0);
     441            lightMan->setAttenuation(1.0, .01, 0.0);
     442            lightMan->setSpecularColor(1,0,0);
     443            this->nullParent = NullParent::getInstance ();
     444            this->nullParent->setName ("NullParent");
     445
     446            // create a player
     447            WorldEntity* myPlayer = new Player();
     448            myPlayer->setName ("player");
     449            this->spawn(myPlayer);
     450            this->localPlayer = myPlayer;           
     451           
     452            // bind input
     453            Orxonox *orx = Orxonox::getInstance();
     454            orx->getLocalInput()->bind (myPlayer);
     455           
     456            // bind camera
     457            this->localCamera = new Camera (this);
     458            this->localCamera->setName ("camera");
     459            this->localCamera->bind (myPlayer);
     460            this->localPlayer->addChild (this->localCamera);
     461
     462            // Create SkySphere
     463            skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
     464            this->localPlayer->addChild(this->skySphere);
     465
     466            Vector* es = new Vector (20, 0, 0);
     467            Quaternion* qs = new Quaternion ();
     468            WorldEntity* pr = new Primitive(PSPHERE);
     469            pr->setName("primitive");
     470            this->spawn(pr, this->localPlayer, es, qs, PNODE_ROTATE_AND_MOVE);
     471
     472            lightMan->getLight(0)->setParent(trackManager->getTrackNode());
     473            break;
     474          }
     475        default:
     476          printf("World::load() - no world with ID %i found", this->debugWorldNr );
     477        }
     478    }
     479  else if(this->worldName != NULL)
     480    {
     481
     482    }
     483
     484>>>>>>> .merge-right.r3604
    281485  // initialize debug coord system
    282486  objectList = glGenLists(1);
    283487  glNewList (objectList, GL_COMPILE);
    284   glLoadIdentity();
    285   glColor3f(1.0,0,0);
    286   glBegin(GL_QUADS);
    287 
    288   int sizeX = 100;
    289   int sizeZ = 80;
    290   float length = 1000;
    291   float width = 200;
    292   float widthX = float (length /sizeX);
    293   float widthZ = float (width /sizeZ);
    294  
    295   float height [sizeX][sizeZ];
    296   Vector normal_vectors[sizeX][sizeZ];
    297  
    298  
    299   for ( int i = 0; i<sizeX-1; i+=1)
    300     for (int j = 0; j<sizeZ-1;j+=1)
    301       //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
    302 #ifdef __WIN32__
    303       height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
    304 #else
    305       height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
    306 #endif
    307 
    308   //Die Huegel ein wenig glaetten
    309   for (int h=1; h<2;h++)
    310     for (int i=1;i<sizeX-2 ;i+=1 )
    311       for(int j=1;j<sizeZ-2;j+=1)
    312         height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
    313  
    314   //Berechnung von normalen Vektoren
    315   for(int i=1;i<sizeX-2;i+=1)
    316     for(int j=1;j<sizeZ-2 ;j+=1)
    317       {
    318         Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
    319         Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
    320         Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
    321         Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
    322         Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
    323        
    324         Vector c1 = v2 - v1;
    325         Vector c2 = v3 - v1;
    326         Vector c3=  v4 - v1;
    327         Vector c4 = v5 - v1;
    328         Vector zero = Vector (0,0,0);
    329         normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
    330         normal_vectors[i][j].normalize();
    331       }
    332 
    333   int snowheight=3;
    334   for ( int i = 0; i<sizeX; i+=1)
    335     for (int j = 0; j<sizeZ;j+=1)
    336       {   
    337         Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
    338         Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
    339         Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
    340         Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
    341         float a[3];
    342         if(height[i][j]<snowheight){
    343           a[0]=0;
    344           a[1]=1.0-height[i][j]/10-.3;
    345           a[2]=0;
    346           glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    347         }
    348         else{
    349             a[0]=1.0;
    350             a[1]=1.0;
    351             a[2]=1.0;
    352             glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    353            
    354         }
    355         glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
    356         glVertex3f(v1.x, v1.y, v1.z);
    357         if(height[i+1][j]<snowheight){
    358           a[0]=0;
    359           a[1] =1.0-height[i+1][j]/10-.3;
    360           a[2]=0;
    361           glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    362         }
    363         else{
    364           a[0]=1.0;
    365           a[1]=1.0;
    366           a[2]=1.0;
    367           glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    368          
    369         }
    370         glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
    371         glVertex3f(v2.x, v2.y, v2.z);
    372         if(height[i+1][j+1]<snowheight){
    373           a[0]=0;
    374           a[1] =1.0-height[i+1][j+1]/10-.3;
    375           a[2]=0;
    376           glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    377         }
    378         else{
    379           a[0]=1.0;
    380           a[1]=1.0;
    381           a[2]=1.0;
    382           glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    383          
    384          
    385         }
    386         glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
    387         glVertex3f(v3.x, v3.y, v3.z);
    388         if(height[i][j+1]<snowheight){
    389           a[0]=0;
    390           a[1] =1.0-height[i+1][j+1]/10-.3;
    391           a[2]=0;
    392           glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    393         }
    394         else{
    395           a[0]=1.0;
    396           a[1]=1.0;
    397           a[2]=1.0;
    398           glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    399         }
    400         glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
    401         glVertex3f(v4.x, v4.y, v4.z);
    402        
    403       }
    404   glEnd();
    405   /* 
    406   glBegin(GL_LINES);
    407   for( float x = -128.0; x < 128.0; x += 25.0)
    408     {
    409       for( float y = -128.0; y < 128.0; y += 25.0)
    410         {
    411           glColor3f(1,0,0);
    412           glVertex3f(x,y,-128.0);
    413           glVertex3f(x,y,0.0);
    414           glColor3f(0.5,0,0);
    415           glVertex3f(x,y,0.0);
    416           glVertex3f(x,y,128.0);
    417         }
    418     }
    419   for( float y = -128.0; y < 128.0; y += 25.0)
    420     {
    421       for( float z = -128.0; z < 128.0; z += 25.0)
    422         {
    423           glColor3f(0,1,0);
    424           glVertex3f(-128.0,y,z);
    425           glVertex3f(0.0,y,z);
    426           glColor3f(0,0.5,0);
    427           glVertex3f(0.0,y,z);
    428           glVertex3f(128.0,y,z);
    429         }
    430     }
    431   for( float x = -128.0; x < 128.0; x += 25.0)
    432     {
    433       for( float z = -128.0; z < 128.0; z += 25.0)
    434         {
    435           glColor3f(0,0,1);
    436           glVertex3f(x,-128.0,z);
    437           glVertex3f(x,0.0,z);
    438           glColor3f(0,0,0.5);
    439           glVertex3f(x,0.0,z);
    440           glVertex3f(x,128.0,z);
    441         }
    442      
    443     }
    444   */ 
    445   /*
    446   glBegin(GL_LINE_STRIP);
    447   glColor3f(1.0, 5.0, 1.0);
    448   for( int i = 0; i <= 30; i++)
    449     {
    450       glEvalCoord1f ((GLfloat) i/30.0);
    451     }
    452   glEnd();
    453   */
    454 
     488 
    455489  trackManager->drawGraph(.01);
    456490  trackManager->debug(2);
    457   /* 
    458   glBegin(GL_LINES);
    459   float i;
    460   for(i = 0.0; i<1; i+=.01)
    461     {
    462       printf("%f, %f, %f\n",tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z);
    463       glVertex3f(tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z);
    464     }
    465   glEnd();
    466   */
    467491  glEndList();
    468   // LIGHT initialisation
    469   light = Light::getInstance();
    470   light->addLight(0);
    471   light->setAttenuation(QUADRATIC, 1.0);
    472   light->setAttenuation(CONSTANT, 2.0);
    473   light->setAttenuation(QUADRATIC, 1.0);
    474   light->setPosition(10.0, 10.0, 50.0);
    475   light->setDiffuseColor(1,1,1);
    476   //  light->addLight(1);
    477   //  light->setPosition(20, 10, -20);
    478   //  light->setDiffuseColor(0,0,0);
    479   light->debug();
    480 
     492
     493  terrain = new Terrain("../data/worlds/newGround.obj");
     494  terrain->setRelCoor(new Vector(0,-10,0));
     495  this->spawn(terrain);
    481496
    482497}
     
    492507  cn->enable(true);
    493508
    494   //glMap1f (GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);
    495   //glEnable (GL_MAP1_VERTEX_3);
    496  
    497   //theNurb = gluNewNurbsRenderer ();
    498   //gluNurbsProperty (theNurb, GLU_NURBS_MODE, GLU_NURBS_TESSELLATOR);
    499   //gluNurbsProperty (theNurb, GLU_NURBS_VERTEX, vertexCallback );
    500        
    501         PRINTF0("> Done Loading world: '%s'\n", getPath());
     509PRINTF0("> Done Loading world: '%s'\n", getPath());
    502510}
    503511
     
    508516ErrorMessage World::start()
    509517{
    510   printf("World::start() - starting current World: nr %i\n", this->debugWorldNr);
     518  PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
    511519  this->bQuitOrxonox = false;
    512520  this->bQuitCurrentGame = false;
     
    521529ErrorMessage World::stop()
    522530{
    523   printf("World::stop() - got stop signal\n");
     531  PRINTF(3)("World::stop() - got stop signal\n");
    524532  this->bQuitCurrentGame = true;
    525533}
     
    546554ErrorMessage World::destroy()
    547555{
    548   delete trackManager;
     556
    549557}
    550558
     
    554562void World::displayLoadScreen ()
    555563{
    556   printf ("World::displayLoadScreen - start\n");
     564  PRINTF(3)("World::displayLoadScreen - start\n");
    557565 
    558566  //GLMenuImageScreen*
     
    562570  this->glmis->draw();
    563571 
    564   printf ("World::displayLoadScreen - end\n");
     572  PRINTF(3)("World::displayLoadScreen - end\n");
    565573}
    566574
     
    572580void World::releaseLoadScreen ()
    573581{
    574   printf ("World::releaseLoadScreen - start\n");
     582  PRINTF(3)("World::releaseLoadScreen - start\n");
    575583  this->glmis->setValue(this->glmis->getMaximum());
    576584  SDL_Delay(500);
    577   printf ("World::releaseLoadScreen - end\n");
     585  PRINTF(3)("World::releaseLoadScreen - end\n");
    578586}
    579587
     
    629637  /* draw entities */
    630638  WorldEntity* entity;
     639  glLoadIdentity();
     640
    631641  entity = this->entities->enumerate();
    632642  while( entity != NULL )
     
    642652  testFont->printText(0, 0, 1, "orxonox_" PACKAGE_VERSION);
    643653
     654  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
    644655}
    645656
     
    651662void World::debug()
    652663{
    653   printf ("World::debug() - starting debug\n");
     664  PRINTF(2)("debug() - starting debug\n");
    654665  PNode* p1 = NullParent::getInstance ();
    655666  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
     
    670681  p4->debug ();
    671682 
    672   p1->update (1);
     683  p1->update ();
    673684
    674685  printf ("World::debug() - update\n");
     
    679690
    680691  p2->shiftCoor (new Vector(-1, -1, -1));
    681   p1->update (2);
     692  p1->update ();
    682693
    683694  p1->debug ();
     
    689700
    690701
    691  p1->update (2);
     702 p1->update ();
    692703
    693704  p1->debug ();
     
    696707  p4->debug ();
    697708
    698   p1->destroy ();
     709  delete p1;
    699710 
    700711 
     
    726737  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
    727738    {
     739      PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
    728740      // Network
    729741      this->synchronize ();
     
    731743      this->handleInput ();
    732744      if( this->bQuitCurrentGame || this->bQuitOrxonox)
    733         {
    734           printf("World::mainLoop() - leaving loop earlier...\n");
    735745          break;
    736         }
    737746      // Process time
    738      this->timeSlice ();
     747      this->tick ();
     748      // Update the state
     749      this->update ();     
    739750      // Process collision
    740751     this->collide ();
    741752      // Draw
    742753     this->display ();
    743  
    744       for( int i = 0; i < 5000000; i++) {}
     754
     755      //      for( int i = 0; i < 5000000; i++) {}
    745756      /* \todo this is to slow down the program for openGl Software emulator computers, reimplement*/
    746757    }
    747   printf("World::mainLoop() - Exiting the main loop\n");
     758  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
    748759}
    749760
     
    781792   a heart-beat.
    782793*/
    783 void World::timeSlice ()
     794void World::tick ()
    784795{
    785796  Uint32 currentFrame = SDL_GetTicks();
     
    791802        {
    792803          float fps = 1000/dt;
    793           printf("fps = %f\n", fps);
     804          PRINTF(3)("fps = %f\n", fps);
    794805        }
    795806      else
     
    798809             nothing.
    799810          */
    800           printf("fps = 1000 - frame rate is adjusted\n");
     811          PRINTF(2)("fps = 1000 - frame rate is adjusted\n");
    801812          SDL_Delay(10);
    802813          dt = 10;
     
    808819      float seconds = dt / 1000.0; 
    809820      assert( this->nullParent != NULL);
    810       this->nullParent->update (seconds);
    811821      entity = entities->enumerate();
    812822      while( entity != NULL)
     
    815825          entity = entities->nextElement();
    816826        }
    817       //assert( skySphere != NULL);
    818       //skySphere->updatePosition(localCamera->absCoordinate);
    819      
    820827      /* update tick the rest */
    821828      assert( this->localCamera != NULL);
    822829      assert( this->trackManager != NULL);
    823       this->localCamera->timeSlice(dt);
     830      this->localCamera->tick(dt);
     831
    824832      this->trackManager->tick(dt);
    825833    }
    826834  this->lastFrame = currentFrame;
     835}
     836
     837
     838/**
     839   \brief this function gives the world a consistant state
     840
     841   after ticking (updating the world state) this will give a constistant
     842   state to the whole system.
     843*/
     844void World::update()
     845{
     846  this->nullParent->update ();
    827847}
    828848
     
    856876void World::spawn(WorldEntity* entity)
    857877{
    858   if( this->nullParent != NULL && entity->parent == NULL)
    859     this->nullParent->addChild (entity);
    860 
    861878  this->entities->add (entity);
    862 
    863879  entity->postSpawn ();
    864880}
     
    873889void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    874890{
     891  this->entities->add (entity);
     892
    875893  entity->setAbsCoor (absCoor);
    876894  entity->setAbsDir (absDir);
    877  
    878   if( this->nullParent != NULL && entity->parent == NULL)
    879     this->nullParent->addChild (entity);
    880 
    881   this->entities->add (entity);
    882895
    883896  entity->postSpawn ();
     897}
     898
     899
     900/**
     901   \brief add and spawn a new entity to this world
     902   \param entity to be added
     903   \param entity to be added to (PNode)
     904   \param At what relative  coordinates to add this entity.
     905   \param In which relative direction should it look.
     906*/
     907void World::spawn(WorldEntity* entity, PNode* parentNode,
     908                  Vector* relCoor, Quaternion* relDir,
     909                  int parentingMode)
     910{
     911  this->nullParent = NullParent::getInstance();
     912  if( parentNode != NULL)
     913    {
     914      parentNode->addChild (entity);
     915     
     916      entity->setRelCoor (relCoor);
     917      entity->setRelDir (relDir);
     918      entity->setMode(parentingMode);
     919     
     920      this->entities->add (entity);
     921     
     922      entity->postSpawn ();
     923    }
    884924}
    885925
Note: See TracChangeset for help on using the changeset viewer.