Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4010 in orxonox.OLD for orxonox/trunk/src/story_entities/world.cc


Ignore:
Timestamp:
May 2, 2005, 3:14:57 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the levelloader from lltrunktemp to the trunk. Big thanks to fuzzy to make this so easy for us, and for implementing it in the first place.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/story_entities/world.cc

    r3993 r4010  
     1
    12
    23/*
     
    4344#include "glmenu_imagescreen.h"
    4445#include "list.h"
     46#include "game_loader.h"
    4547
    4648#include "animation3d.h"
    4749
     50#include "substring.h"
    4851
    4952using namespace std;
    50 
    5153
    5254WorldInterface* WorldInterface::singletonRef = 0;
     
    114116}
    115117
    116 
     118CREATE_FACTORY(World);
     119
     120World::World( TiXmlElement* root)
     121{
     122  this->constuctorInit("", -1);
     123
     124  const char *string;
     125  char *name;
     126  int id;
     127 
     128  PRINTF0("Creating a World\n");
     129 
     130  // identifier
     131  string = grabParameter( root, "identifier");
     132  if( string == NULL || sscanf(string, "%d", &id) != 1)
     133    {
     134      PRINTF0("World is missing a proper 'identifier'\n");
     135      this->setStoryID( -1);
     136    }
     137  else setStoryID( id);
     138
     139  // next id
     140  string = grabParameter( root, "nextid");
     141  if( string == NULL || sscanf(string, "%d", &id) != 1)
     142    {
     143      PRINTF0("World is missing a proper 'nextid'\n");
     144      this->setStoryID( -1);
     145    }
     146  else setNextStoryID( id);
     147 
     148
     149  // path
     150  string = grabParameter( root, "path");
     151  if( string == NULL)
     152    {
     153      PRINTF0("World is missing a proper 'path'\n");
     154      this->setPath( NULL);
     155    }
     156  else
     157    {
     158      name = new char[strlen(string + 2)];
     159      strcpy( name, string);
     160      this->setPath( name);
     161    }
     162}
    117163
    118164/**
     
    123169World::World (char* name)
    124170{
    125   this->init(name, -1);
     171  this->constuctorInit(name, -1);
    126172  //NullParent* np = NullParent::getInstance();
    127173}
     
    133179World::World (int worldID)
    134180{
    135   this->init(NULL, worldID);
     181  this->constuctorInit(NULL, worldID);
    136182}
    137183
     
    178224   NO LEVEL LOADING HERE - NEVER!
    179225*/
    180 void World::init(char* name, int worldID)
     226void World::constuctorInit(char* name, int worldID)
    181227{
    182228  this->setClassName ("World");
    183229
    184   this->worldName = name;
     230  //this->worldName = name;
     231  //this->worldName = new char[strlen(name)+1];
     232  //strcpy(this->worldName, name);
    185233  this->debugWorldNr = worldID;
    186234  this->entities = new tList<WorldEntity>();
    187   AnimationPlayer::getInstance(); // initializes the animationPlayer
    188235}
    189236
     
    201248  wi->init(this);
    202249  this->garbageCollector = GarbageCollector::getInstance();
     250
    203251  this->trackManager = TrackManager::getInstance();
    204252  this->lightMan = LightManager::getInstance();
     
    206254  this->nullParent->setName ("NullParent");
    207255
     256  AnimationPlayer::getInstance(); // initializes the animationPlayer
     257
    208258}
    209259
     
    213263*/
    214264ErrorMessage World::load()
    215 {
    216   //  BezierCurve* tmpCurve = new BezierCurve();
    217   if(this->debugWorldNr != -1)
    218     {
    219       // initializing Font
    220       this->glmis->step();
     265{       
     266  PRINTF0("> Loading world: '%s'\n", getPath());
     267 
     268  GameLoader* loader = GameLoader::getInstance();
     269 
     270  if( getPath() == NULL)
     271    {
     272      PRINTF0("World has no path specified for loading");
     273      return (ErrorMessage){213,"Path not specified","World::load()"};
     274    }
     275 
     276  TiXmlDocument* XMLDoc = new TiXmlDocument( path);
     277  // load the campaign document
     278  if( !XMLDoc->LoadFile())
     279    //this->glmis->step();
     280 
     281  {
     282    // report an error
     283    PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     284    delete XMLDoc;
     285    return (ErrorMessage){213,"XML File parsing error","World::load()"};
     286  }
     287 
     288  // check basic validity
     289  TiXmlElement* root = XMLDoc->RootElement();
     290  assert( root != NULL);
     291 
     292  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
     293    {
     294      // report an error
     295      PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
     296      delete XMLDoc;
     297      return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
     298    }
     299 
     300  // load the parameters
     301  // name
     302  char* temp;
     303  const char* string = grabParameter( root, "name");
     304  if( string == NULL)
     305    {
     306      PRINTF0("World is missing a proper 'name'\n");
     307      string = "Unknown";
     308      temp = new char[strlen(string + 2)];
     309      strcpy( temp, string);
     310      this->worldName = temp;
     311    }
     312  else
     313    {
     314      temp = new char[strlen(string + 2)];
     315      strcpy( temp, string);
     316      this->worldName = temp;
     317    }
     318 
     319 
     320  // find WorldEntities
     321  TiXmlElement* element = root->FirstChildElement( "WorldEntities");
     322 
     323  if( element == NULL)
     324    {
     325      PRINTF0("World is missing 'WorldEntities'\n");
     326    }
     327  else
     328    {
     329      element = element->FirstChildElement();
     330      // load Players/Objects/Whatever
     331      PRINTF0("Loading WorldEntities\n");
     332      while( element != NULL)
     333        {
     334          WorldEntity* created = (WorldEntity*) loader->fabricate( element);
     335          if( created != NULL) this->spawn( created);
     336          // if we load a 'Player' we use it as localPlayer
     337          //todo do this more elegant
     338          if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
     339          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) skyBox = (SkyBox*) created;
     340          element = element->NextSiblingElement();
     341        }
     342      PRINTF0("Done loading WorldEntities\n");
     343    }
     344 
     345  // find Track
     346  /*element = root->FirstChildElement( "Track");
     347  if( element == NULL)
     348    {
     349      PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n");
     350    }
     351  else
     352    {   
     353      //load track
     354      PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n");
     355
     356      trackManager->loadTrack( element);
     357      trackManager->finalize();
     358      PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n");
     359    }*/
     360 
     361  // free the XML data
     362  delete XMLDoc;
     363 
     364  // finalize world
     365  // initialize Font
     366//  testFont = new FontSet();
     367//  testFont->buildFont("../data/pictures/font.tga");
     368 
     369  // create null parent
     370  this->nullParent = NullParent::getInstance ();
     371  this->nullParent->setName ("NullParent");
     372 
     373  // finalize myPlayer
     374  if( localPlayer == NULL)
     375    {
     376      PRINTF0("No Player specified in World '%s'\n", this->worldName);
     377      return (ErrorMessage){213,"No Player defined","World::load()"};
     378    }
     379 
     380  // bind input
     381  Orxonox *orx = Orxonox::getInstance ();
     382  orx->getLocalInput()->bind (localPlayer);
     383 
     384  // bind camera
     385  this->localCamera = new Camera();
     386  this->localCamera->setName ("camera");
     387  //this->localCamera->bind (localPlayer);
     388  this->localPlayer->addChild (this->localCamera);
     389 
     390 
     391  // stuff beyond this point remains to be loaded properly
     392 
    221393      // initializing the TrackManager
    222 
     394  this->trackManager = TrackManager::getInstance();
    223395      //trackManager->addPoint(Vector(0,0,0));
    224396      trackManager->addPoint(Vector(150, -35, 5));
     
    278450
    279451     
    280       /*monitor progress*/
    281       this->glmis->step();
    282 
    283       // LIGHT initialisation
    284 
    285       lightMan->setAmbientColor(.1,.1,.1);
    286       lightMan->addLight();
    287       //      lightMan->setAttenuation(1.0, .01, 0.0);
    288       //      lightMan->setDiffuseColor(1,1,1);
    289       //  lightMan->addLight(1);
    290       //  lightMan->setPosition(20, 10, -20);
    291       //  lightMan->setDiffuseColor(0,0,0);
    292       lightMan->debug();
    293 
    294       switch(this->debugWorldNr)
    295         {
    296           /*
    297             this loads the hard-coded debug world. this only for simplicity and will be
    298             removed by a reald world-loader, which interprets a world-file.
    299             if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
    300             make whatever you want...
    301            */
    302         case DEBUG_WORLD_0:
    303           {
    304             lightMan->setPosition(-5.0, 10.0, -40.0);
    305 
    306             // !\todo old track-system has to be removed
    307 
    308             //create helper for player
    309             //HelperParent* hp = new HelperParent ();
    310             /* the player has to be added to this helper */
    311 
    312             // create a player
    313             this->localPlayer = new Player ();
    314             this->localPlayer->setName ("player");
    315             this->spawn (this->localPlayer);
    316             /*monitor progress*/
    317             //this->glmis->step();
    318             this->glmis->step();
    319 
    320             // bind input
    321             Orxonox *orx = Orxonox::getInstance ();
    322             orx->getLocalInput()->bind (this->localPlayer);
     452  // LIGHT initialisation
     453  lightMan = LightManager::getInstance();
     454  lightMan->setAmbientColor(.1,.1,.1);
     455  lightMan->addLight();
     456  //      lightMan->setAttenuation(1.0, .01, 0.0);
     457  //      lightMan->setDiffuseColor(1,1,1);
     458  //  lightMan->addLight(1);
     459  //  lightMan->setPosition(20, 10, -20);
     460  //  lightMan->setDiffuseColor(0,0,0);
     461  lightMan->debug();
     462  lightMan->setPosition(-5.0, 10.0, -40.0);
     463 
     464  //        trackManager->setBindSlave(env);
     465  PNode* tn = trackManager->getTrackNode();
     466  tn->addChild(this->localPlayer);
     467 
     468  //localCamera->setParent(TrackNode::getInstance());
     469  tn->addChild(this->localCamera);
     470  localCamera->lookAt(tn);
     471  this->localPlayer->setMode(PNODE_ALL);
     472  Vector* cameraOffset = new Vector (0, 5, -10);
     473  trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     474 
     475
     476  // initialize debug coord system
     477  objectList = glGenLists(1);
     478  glNewList (objectList, GL_COMPILE);
     479 
     480  //  trackManager->drawGraph(.01);
     481  trackManager->debug(2);
     482  glEndList();
     483
     484  terrain = new Terrain("../data/worlds/newGround.obj");
     485  terrain->setRelCoor(Vector(0,-10,0));
     486  this->spawn(terrain);
     487
     488}
     489
     490void World::loadDebugWorld(int worldID)
     491{
     492  /*monitor progress*/
     493  this->glmis->step();
     494
     495  // LIGHT initialisation
     496
     497  lightMan->setAmbientColor(.1,.1,.1);
     498  lightMan->addLight();
     499  //      lightMan->setAttenuation(1.0, .01, 0.0);
     500  //      lightMan->setDiffuseColor(1,1,1);
     501  //  lightMan->addLight(1);
     502  //  lightMan->setPosition(20, 10, -20);
     503  //  lightMan->setDiffuseColor(0,0,0);
     504  lightMan->debug();
     505
     506  switch(this->debugWorldNr)
     507    {
     508      /*
     509        this loads the hard-coded debug world. this only for simplicity and will be
     510        removed by a reald world-loader, which interprets a world-file.
     511        if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
     512        make whatever you want...
     513      */
     514    case DEBUG_WORLD_0:
     515      {
     516        lightMan->setPosition(-5.0, 10.0, -40.0);
     517
     518        // !\todo old track-system has to be removed
     519
     520        //create helper for player
     521        //HelperParent* hp = new HelperParent ();
     522        /* the player has to be added to this helper */
     523
     524        // create a player
     525        this->localPlayer = new Player ();
     526        this->localPlayer->setName ("player");
     527        this->spawn (this->localPlayer);
     528        /*monitor progress*/
     529        //this->glmis->step();
     530        this->glmis->step();
     531
     532        // bind input
     533        Orxonox *orx = Orxonox::getInstance ();
     534        orx->getLocalInput()->bind (this->localPlayer);
    323535           
    324             // bind camera
    325             this->localCamera = new Camera();
    326             this->localCamera->setName ("camera");
     536        // bind camera
     537        this->localCamera = new Camera();
     538        this->localCamera->setName ("camera");
    327539           
    328             /*monitor progress*/
    329             this->glmis->step();
    330 
    331             // Create SkySphere
    332             //      this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    333             //      this->skySphere->setName("SkySphere");
    334             //      this->localCamera->addChild(this->skySphere);
    335             //      this->spawn(this->skySphere);
    336             skyBox = new SkyBox();
    337             skyBox->setTexture("pictures/sky/skybox", "jpg");
    338             skyBox->setParent(localCamera);
    339             this->spawn(skyBox);
    340 
    341             /*monitor progress*/
    342             this->glmis->step();
     540        /*monitor progress*/
     541        this->glmis->step();
     542
     543        // Create SkySphere
     544        //          this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
     545        //          this->skySphere->setName("SkySphere");
     546        //          this->localCamera->addChild(this->skySphere);
     547        //          this->spawn(this->skySphere);
     548        skyBox = new SkyBox();
     549        skyBox->setTexture("pictures/sky/skybox", "jpg");
     550        skyBox->setParent(localCamera);
     551        this->spawn(skyBox);
     552
     553        /*monitor progress*/
     554        this->glmis->step();
    343555
    344556           
    345             WorldEntity* env = new Environment();
    346             env->setName ("env");
    347             this->spawn(env);
     557        WorldEntity* env = new Environment();
     558        env->setName ("env");
     559        this->spawn(env);
    348560
    349561           
    350             /*
    351             Vector* es = new Vector (10, 5, 0);
    352             Quaternion* qs = new Quaternion ();
    353             WorldEntity* pr = new Primitive(P_CYLINDER);
    354             pr->setName("primitive");
    355             this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
    356             */
    357 
    358             /*monitor progress*/
    359             this->glmis->step();
    360 
    361             //      trackManager->setBindSlave(env);
    362             PNode* tn = trackManager->getTrackNode();
    363             tn->addChild(this->localPlayer);
    364             this->localCamera->lookAt(tn);
    365 
    366             //localCamera->setParent(TrackNode::getInstance());
    367             tn->addChild(this->localCamera);
    368             //      localCamera->lookAt(tn);
    369             this->localPlayer->setMode(PNODE_ALL);
    370             //Vector* cameraOffset = new Vector (0, 5, -10);
    371             trackManager->condition(2, LEFTRIGHT, this->localPlayer);
    372             this->glmis->step();
    373             break;
    374           }
    375         case DEBUG_WORLD_1:
    376           {
    377             lightMan->setPosition(.0, .0, .0);
    378             lightMan->setAttenuation(1.0, .01, 0.0);
    379             lightMan->setSpecularColor(1,0,0);
    380             this->nullParent = NullParent::getInstance ();
    381             this->nullParent->setName ("NullParent");
    382 
    383             // create a player
    384             WorldEntity* myPlayer = new Player();
    385             myPlayer->setName ("player");
    386             this->spawn(myPlayer);
    387             this->localPlayer = myPlayer;           
     562        /*
     563          Vector* es = new Vector (10, 5, 0);
     564          Quaternion* qs = new Quaternion ();
     565          WorldEntity* pr = new Primitive(P_CYLINDER);
     566          pr->setName("primitive");
     567          this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     568        */
     569
     570        /*monitor progress*/
     571        this->glmis->step();
     572
     573        //          trackManager->setBindSlave(env);
     574        PNode* tn = trackManager->getTrackNode();
     575        tn->addChild(this->localPlayer);
     576        this->localCamera->lookAt(tn);
     577
     578        //localCamera->setParent(TrackNode::getInstance());
     579        tn->addChild(this->localCamera);
     580        //          localCamera->lookAt(tn);
     581        this->localPlayer->setMode(PNODE_ALL);
     582        //Vector* cameraOffset = new Vector (0, 5, -10);
     583        trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     584        this->glmis->step();
     585        break;
     586      }
     587    case DEBUG_WORLD_1:
     588      {
     589        lightMan->setPosition(.0, .0, .0);
     590        lightMan->setAttenuation(1.0, .01, 0.0);
     591        lightMan->setSpecularColor(1,0,0);
     592        this->nullParent = NullParent::getInstance ();
     593        this->nullParent->setName ("NullParent");
     594
     595        // create a player
     596        WorldEntity* myPlayer = new Player();
     597        myPlayer->setName ("player");
     598        this->spawn(myPlayer);
     599        this->localPlayer = myPlayer;       
    388600           
    389             // bind input
    390             Orxonox *orx = Orxonox::getInstance();
    391             orx->getLocalInput()->bind (myPlayer);
     601        // bind input
     602        Orxonox *orx = Orxonox::getInstance();
     603        orx->getLocalInput()->bind (myPlayer);
    392604           
    393             // bind camera
    394             this->localCamera = new Camera ();
    395             this->localCamera->setName ("camera");
    396             this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
    397             this->localCamera->setParent(this->localPlayer);
    398 
    399             // Create SkySphere
    400             skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    401             this->localPlayer->addChild(this->skySphere);
    402             this->spawn(this->skySphere);
    403             Vector* es = new Vector (20, 0, 0);
    404             Quaternion* qs = new Quaternion ();
    405 
    406             lightMan->getLight(0)->setParent(trackManager->getTrackNode());
    407             break;
    408           }
    409         case DEBUG_WORLD_2:
    410           {
    411             lightMan->setAmbientColor(.1,.1,.1);
    412             lightMan->addLight();
    413             lightMan->setPosition(-5.0, 10.0, -40.0);
    414             this->nullParent = NullParent::getInstance ();
    415             this->nullParent->setName ("NullParent");
    416 
    417             // !\todo old track-system has to be removed
    418 
    419             //create helper for player
    420             //HelperParent* hp = new HelperParent ();
    421             /* the player has to be added to this helper */
    422 
    423             // create a player
    424             this->localPlayer = new Player ();
    425             this->localPlayer->setName ("player");
    426             this->spawn (this->localPlayer);
    427             /*monitor progress*/
    428             //this->glmis->step();         
    429             this->glmis->step();
    430 
    431             // bind input
    432             Orxonox *orx = Orxonox::getInstance ();
    433             orx->getLocalInput()->bind (this->localPlayer);
     605        // bind camera
     606        this->localCamera = new Camera ();
     607        this->localCamera->setName ("camera");
     608        this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
     609        this->localCamera->setParent(this->localPlayer);
     610
     611        // Create SkySphere
     612        skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
     613        this->localPlayer->addChild(this->skySphere);
     614        this->spawn(this->skySphere);
     615        Vector* es = new Vector (20, 0, 0);
     616        Quaternion* qs = new Quaternion ();
     617
     618        lightMan->getLight(0)->setParent(trackManager->getTrackNode());
     619        break;
     620      }
     621    case DEBUG_WORLD_2:
     622      {
     623        lightMan->setAmbientColor(.1,.1,.1);
     624        lightMan->addLight();
     625        lightMan->setPosition(-5.0, 10.0, -40.0);
     626        this->nullParent = NullParent::getInstance ();
     627        this->nullParent->setName ("NullParent");
     628
     629        // !\todo old track-system has to be removed
     630
     631        //create helper for player
     632        //HelperParent* hp = new HelperParent ();
     633        /* the player has to be added to this helper */
     634
     635        // create a player
     636        this->localPlayer = new Player ();
     637        this->localPlayer->setName ("player");
     638        this->spawn (this->localPlayer);
     639        /*monitor progress*/
     640        //this->glmis->step();     
     641        this->glmis->step();
     642
     643        // bind input
     644        Orxonox *orx = Orxonox::getInstance ();
     645        orx->getLocalInput()->bind (this->localPlayer);
    434646           
    435             // bind camera
    436             this->localCamera = new Camera();
    437             this->localCamera->setName ("camera");
    438             this->localCamera->lookAt(this->localPlayer);
    439             this->localCamera->setParent(this->localPlayer);
     647        // bind camera
     648        this->localCamera = new Camera();
     649        this->localCamera->setName ("camera");
     650        this->localCamera->lookAt(this->localPlayer);
     651        this->localCamera->setParent(this->localPlayer);
    440652           
    441             /*monitor progress*/
    442             this->glmis->step();
    443 
    444             // Create SkySphere
    445             this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    446             this->skySphere->setName("SkySphere");
    447             this->spawn(this->skySphere);
    448             this->localCamera->addChild(this->skySphere);
    449             this->skySphere->setMode(PNODE_MOVEMENT);
    450             /*monitor progress*/
    451             this->glmis->step();
    452 
    453 
    454             WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2);
    455             this->localPlayer->addChild(baseNode);
    456             baseNode->setRelCoor(Vector(10.0, 2.0, 1.0));
    457             this->spawn(baseNode);
    458 
    459             WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
    460             baseNode->addChild(secondNode);
    461             secondNode->setRelCoor(Vector(0.0, 0.0, 3.0));
    462             this->spawn(secondNode);
    463 
    464 
    465             WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
    466             secondNode->addChild(thirdNode);
    467             thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0));
    468             this->spawn(thirdNode);
     653        /*monitor progress*/
     654        this->glmis->step();
     655
     656        // Create SkySphere
     657        this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
     658        this->skySphere->setName("SkySphere");
     659        this->spawn(this->skySphere);
     660        this->localCamera->addChild(this->skySphere);
     661        this->skySphere->setMode(PNODE_MOVEMENT);
     662        /*monitor progress*/
     663        this->glmis->step();
     664
     665
     666        WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2);
     667        this->localPlayer->addChild(baseNode);
     668        baseNode->setRelCoor(Vector(10.0, 2.0, 1.0));
     669        this->spawn(baseNode);
     670
     671        WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
     672        baseNode->addChild(secondNode);
     673        secondNode->setRelCoor(Vector(0.0, 0.0, 3.0));
     674        this->spawn(secondNode);
     675
     676
     677        WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
     678        secondNode->addChild(thirdNode);
     679        thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0));
     680        this->spawn(thirdNode);
    469681
    470682           
    471683   
    472             WorldEntity* c = new Environment();
    473             this->localPlayer->addChild(c);
    474             c->setRelCoor(Vector(10.0, 2.0, -1.0));
    475             this->spawn(c);
     684        WorldEntity* c = new Environment();
     685        this->localPlayer->addChild(c);
     686        c->setRelCoor(Vector(10.0, 2.0, -1.0));
     687        this->spawn(c);
    476688
    477689
    478690           
    479             Animation3D* animation = new Animation3D(c);
    480             animation->setInfinity(ANIM_INF_REPLAY);
    481 
    482 
    483             animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
    484             animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
    485             animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
    486 
    487 
    488 
    489 
    490 
    491 
    492             /*     
    493                   KeyFrame* f1 = new KeyFrame;
    494                   f1->position = new Vector(-1.1, 0.0, 2.6);
    495                   f1->direction = new Quaternion();
    496                   f1->time = 1.0;
    497                   f1->mode = NEG_EXP;
     691        Animation3D* animation = new Animation3D(c);
     692        animation->setInfinity(ANIM_INF_REPLAY);
     693
     694
     695        animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     696        animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     697        animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     698
     699
     700
     701
     702
     703
     704        /*         
     705          KeyFrame* f1 = new KeyFrame;
     706          f1->position = new Vector(-1.1, 0.0, 2.6);
     707          f1->direction = new Quaternion();
     708          f1->time = 1.0;
     709          f1->mode = NEG_EXP;
    498710                 
    499711                 
    500                   KeyFrame* f2 = new KeyFrame;
    501                   f2->position = new Vector(-2.1, 0.0, 2.6);
    502                   f2->direction = new Quaternion();
    503                   f2->time = 0.1;
    504                   f2->mode = NEG_EXP;
     712          KeyFrame* f2 = new KeyFrame;
     713          f2->position = new Vector(-2.1, 0.0, 2.6);
     714          f2->direction = new Quaternion();
     715          f2->time = 0.1;
     716          f2->mode = NEG_EXP;
    505717                 
    506                   KeyFrame* f3 = new KeyFrame;
    507                   f3->position = new Vector(10.0, 2.0, -1.0);
    508                   f3->direction = new Quaternion();
    509                   f3->time = 0.2;
    510                   f3->mode = NEG_EXP;
     718          KeyFrame* f3 = new KeyFrame;
     719          f3->position = new Vector(10.0, 2.0, -1.0);
     720          f3->direction = new Quaternion();
     721          f3->time = 0.2;
     722          f3->mode = NEG_EXP;
    511723                 
    512                   KeyFrame* f4 = new KeyFrame;
    513                   f4->position = new Vector(10.0, 5.0, -1.0);
    514                   f4->direction = new Quaternion();
    515                   f4->time = 1.0;
    516                   f4->mode = NEG_EXP;
     724          KeyFrame* f4 = new KeyFrame;
     725          f4->position = new Vector(10.0, 5.0, -1.0);
     726          f4->direction = new Quaternion();
     727          f4->time = 1.0;
     728          f4->mode = NEG_EXP;
    517729                 
    518730                 
    519731                 
    520                   this->simpleAnimation->animatorBegin();
    521                   this->simpleAnimation->selectObject(b);
    522                   this->simpleAnimation->setAnimationMode(SINGLE);
    523                   this->simpleAnimation->addKeyFrame(f1);
    524                   this->simpleAnimation->addKeyFrame(f2);
    525                   this->simpleAnimation->start();
    526                   this->simpleAnimation->selectObject(c);
    527                   this->simpleAnimation->addKeyFrame(f3);
    528                   this->simpleAnimation->addKeyFrame(f4);
    529                   this->simpleAnimation->start();
    530                   this->simpleAnimation->animatorEnd();
    531             */
    532 
    533             /*
    534             Vector* es = new Vector (10, 5, 0);
    535             Quaternion* qs = new Quaternion ();
    536             WorldEntity* pr = new Primitive(P_CYLINDER);
    537             pr->setName("primitive");
    538             this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
    539             */
    540 
    541             /*monitor progress*/
    542             this->glmis->step();
    543 
    544             //      trackManager->setBindSlave(env);
    545             PNode* tn = trackManager->getTrackNode();
    546             tn->addChild(this->localPlayer);
    547 
    548             //localCamera->setParent(TrackNode::getInstance());
    549             tn->addChild(this->localCamera);
    550             //      localCamera->lookAt(tn);
    551             this->localPlayer->setMode(PNODE_ALL);
    552             //Vector* cameraOffset = new Vector (0, 5, -10);
    553             trackManager->condition(2, LEFTRIGHT, this->localPlayer);
    554             this->glmis->step();
    555 
    556             break;
    557           }
    558         default:
    559           printf("World::load() - no world with ID %i found", this->debugWorldNr );
    560         }
    561     }
    562   else if(this->worldName != NULL)
    563     {
    564 
    565     }
    566 
    567   // initialize debug coord system
    568   objectList = glGenLists(1);
    569   glNewList (objectList, GL_COMPILE);
    570  
    571   //  trackManager->drawGraph(.01);
    572   trackManager->debug(2);
    573   glEndList();
    574 
    575   terrain = new Terrain("../data/worlds/newGround.obj");
    576   terrain->setRelCoor(Vector(0,-10,0));
    577   this->spawn(terrain);
    578 
    579 }
     732          this->simpleAnimation->animatorBegin();
     733          this->simpleAnimation->selectObject(b);
     734          this->simpleAnimation->setAnimationMode(SINGLE);
     735          this->simpleAnimation->addKeyFrame(f1);
     736          this->simpleAnimation->addKeyFrame(f2);
     737          this->simpleAnimation->start();
     738          this->simpleAnimation->selectObject(c);
     739          this->simpleAnimation->addKeyFrame(f3);
     740          this->simpleAnimation->addKeyFrame(f4);
     741          this->simpleAnimation->start();
     742          this->simpleAnimation->animatorEnd();
     743        */
     744
     745        /*
     746          Vector* es = new Vector (10, 5, 0);
     747          Quaternion* qs = new Quaternion ();
     748          WorldEntity* pr = new Primitive(P_CYLINDER);
     749          pr->setName("primitive");
     750          this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     751        */
     752
     753        /*monitor progress*/
     754        this->glmis->step();
     755
     756        //          trackManager->setBindSlave(env);
     757        PNode* tn = trackManager->getTrackNode();
     758        tn->addChild(this->localPlayer);
     759
     760        //localCamera->setParent(TrackNode::getInstance());
     761        tn->addChild(this->localCamera);
     762        //          localCamera->lookAt(tn);
     763        this->localPlayer->setMode(PNODE_ALL);
     764        //Vector* cameraOffset = new Vector (0, 5, -10);
     765        trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     766        this->glmis->step();
     767
     768        break;
     769      }
     770    default:
     771      printf("World::load() - no world with ID %i found", this->debugWorldNr );
     772    }
     773}
     774
    580775
    581776
     
    8521047      this->tick ();
    8531048      // Update the state
    854       this->update ();      
     1049      this->update ();     
    8551050      // Process collision
    8561051      this->collide ();
     
    9351130        }
    9361131      delete iterator;
    937       //skySphere->updatePosition(localCamera->absCoordinate);
    938      
     1132
    9391133      /* update tick the rest */
    9401134      this->trackManager->tick(this->dt);
     
    10551249}
    10561250
     1251void World::setPath( const char* name)
     1252{
     1253  this->path = new char[strlen(name)+1];
     1254  strcpy(this->path, name);
     1255}
     1256
     1257const char* World::getPath( void)
     1258{
     1259  return path;
     1260}
Note: See TracChangeset for help on using the changeset viewer.