Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2005, 11:29:19 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/heightMap: merged the Trunk back into branches/heightMap:
merged with Command
svn merge -r 3918:HEAD trunk branches/heightMap
conflicts resolved in favor of the Trunk

Location:
orxonox/branches/heightMap
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/heightMap

    • Property svn:externals
      •  

        old new  
        1 data http://svn.orxonox.ethz.ch/data
         1
  • orxonox/branches/heightMap/src/story_entities/campaign.cc

    r3832 r4122  
    1919#include "campaign.h"
    2020
     21#include "game_loader.h"
    2122#include "story_entity.h"
    2223
     
    3435  this->isInit = false;
    3536}
    36 
     37Campaign::Campaign ( TiXmlElement* root)
     38{
     39  TiXmlElement* element;
     40  const char* string;
     41  int id;
     42 
     43  PRINTF(3)("Loading Campaign...\n");
     44 
     45  assert( root != NULL);
     46  GameLoader* loader = GameLoader::getInstance();
     47 
     48  this->entities = new tList<StoryEntity>();
     49  this->isInit = false;
     50 
     51  // grab all the necessary parameters
     52  string = grabParameter( root, "identifier");
     53  if( string == NULL || sscanf(string, "%d", &id) != 1)
     54    {
     55      PRINTF(2)("Campaign is missing a proper 'identifier'\n");
     56      this->setStoryID( -1);
     57    }
     58  else this->setStoryID( id);
     59 
     60  // find WorldList
     61  element = root->FirstChildElement( "WorldList");
     62  if( element == NULL)
     63    {
     64      PRINTF(2)("Campaign is missing a proper 'WorldList'\n");
     65    }
     66  else
     67    element = element->FirstChildElement();
     68 
     69  // load Worlds/Subcampaigns/Whatever
     70  StoryEntity* lastCreated = NULL;
     71  while( element != NULL)
     72    {
     73      printf("Campaign: Constructor: adding a world\n");
     74      StoryEntity* created = (StoryEntity*) loader->fabricate( element);
     75      /*
     76      if( lastCreated != NULL)
     77        created->setNextStoryID( lastCreated->getStoryID());
     78      else
     79        created->setNextStoryID( WORLD_ID_GAMEEND);
     80      */
     81      if( created != NULL)
     82        {
     83          this->addEntity( created);   
     84          lastCreated = created;
     85        }
     86      element = element->NextSiblingElement();
     87    }
     88  //if( lastCreated != NULL)
     89  //lastCreated->setStoryID( WORLD_ID_GAMEEND);
     90}
    3791
    3892Campaign::~Campaign () {}
  • orxonox/branches/heightMap/src/story_entities/campaign.h

    r3608 r4122  
    1414 public:
    1515  Campaign ();
     16  Campaign ( TiXmlElement* root);
    1617  virtual ~Campaign ();
    1718
  • orxonox/branches/heightMap/src/story_entities/world.cc

    r4093 r4122  
     1
    12
    23/*
     
    4344#include "glmenu_imagescreen.h"
    4445#include "list.h"
    45 
    46 
     46#include "game_loader.h"
     47
     48#include "animation3d.h"
     49
     50#include "substring.h"
    4751
    4852using namespace std;
    49 
    5053
    5154WorldInterface* WorldInterface::singletonRef = 0;
     
    113116}
    114117
    115 
     118CREATE_FACTORY(World);
     119
     120World::World( TiXmlElement* root)
     121{
     122  this->constuctorInit("", -1);
     123  this->path = NULL;
     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}
    116163
    117164/**
     
    122169World::World (char* name)
    123170{
    124   this->init(name, -1);
     171  this->path = NULL;
     172  this->constuctorInit(name, -1);
    125173  //NullParent* np = NullParent::getInstance();
    126174}
     
    132180World::World (int worldID)
    133181{
    134   this->init(NULL, worldID);
     182  this->path = NULL;
     183  this->constuctorInit(NULL, worldID);
    135184}
    136185
     
    177226   NO LEVEL LOADING HERE - NEVER!
    178227*/
    179 void World::init(char* name, int worldID)
     228void World::constuctorInit(char* name, int worldID)
    180229{
    181230  this->setClassName ("World");
    182231
    183   this->worldName = name;
     232  //this->worldName = name;
     233  //this->worldName = new char[strlen(name)+1];
     234  //strcpy(this->worldName, name);
    184235  this->debugWorldNr = worldID;
    185236  this->entities = new tList<WorldEntity>();
    186   AnimationPlayer::getInstance(); // initializes the animationPlayer
    187237}
    188238
     
    200250  wi->init(this);
    201251  this->garbageCollector = GarbageCollector::getInstance();
     252
     253  this->trackManager = TrackManager::getInstance();
     254  this->lightMan = LightManager::getInstance();
     255  this->nullParent = NullParent::getInstance ();
     256  this->nullParent->setName ("NullParent");
     257
     258  AnimationPlayer::getInstance(); // initializes the animationPlayer
     259
     260  this->localCamera = new Camera();
     261  this->localCamera->setName ("camera");
    202262}
    203263
     
    207267*/
    208268ErrorMessage World::load()
    209 {
    210   //  BezierCurve* tmpCurve = new BezierCurve();
    211   if(this->debugWorldNr != -1)
    212     {
    213       // initializing Font
    214       this->glmis->step();
     269{       
     270  PRINTF(3)("> Loading world: '%s'\n", getPath());
     271  TiXmlElement* element;
     272  GameLoader* loader = GameLoader::getInstance();
     273 
     274  if( getPath() == NULL)
     275    {
     276      PRINTF(1)("World has no path specified for loading");
     277      return (ErrorMessage){213,"Path not specified","World::load()"};
     278    }
     279 
     280  TiXmlDocument* XMLDoc = new TiXmlDocument( path);
     281  // load the campaign document
     282  if( !XMLDoc->LoadFile()) 
     283  {
     284    // report an error
     285    PRINTF(1)("loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     286    delete XMLDoc;
     287    return (ErrorMessage){213,"XML File parsing error","World::load()"};
     288  }
     289 
     290  // check basic validity
     291  TiXmlElement* root = XMLDoc->RootElement();
     292  assert( root != NULL);
     293 
     294  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
     295    {
     296      // report an error
     297      PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
     298      delete XMLDoc;
     299      return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
     300    }
     301 
     302  // load the parameters
     303  // name
     304  char* temp;
     305  const char* string = grabParameter( root, "name");
     306  if( string == NULL)
     307    {
     308      PRINTF(2)("World is missing a proper 'name'\n");
     309      string = "Unknown";
     310      temp = new char[strlen(string + 2)];
     311      strcpy( temp, string);
     312      this->worldName = temp;
     313    }
     314  else
     315    {
     316      temp = new char[strlen(string + 2)];
     317      strcpy( temp, string);
     318      this->worldName = temp;
     319    }
     320  ////////////////
     321  // LOADSCREEN //
     322  ////////////////
     323  element = root->FirstChildElement("LoadScreen");
     324  if (element == NULL)
     325    {
     326      PRINTF(2)("no LoadScreen specified, loading default\n");
     327
     328      glmis->setBackgroundImage("pictures/load_screen.jpg");
     329      this->glmis->setMaximum(8);
     330      this->glmis->draw();
     331    }
     332  else
     333    {
     334      this->glmis->load(element);
     335      this->glmis->draw();
     336    }
     337  this->glmis->draw();
     338  // find WorldEntities
     339  element = root->FirstChildElement("WorldEntities");
     340 
     341  if( element == NULL)
     342    {
     343      PRINTF(1)("World is missing 'WorldEntities'\n");
     344    }
     345  else
     346    {
     347      element = element->FirstChildElement();
     348      // load Players/Objects/Whatever
     349      PRINTF(4)("Loading WorldEntities\n");
     350      while( element != NULL)
     351        {
     352          WorldEntity* created = (WorldEntity*) loader->fabricate( element);
     353          if( created != NULL) this->spawn( created);
     354          // if we load a 'Player' we use it as localPlayer
     355          //todo do this more elegant
     356          if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
     357          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created;
     358          element = element->NextSiblingElement();
     359          glmis->step(); //! \todo temporary
     360        }
     361      PRINTF(4)("Done loading WorldEntities\n");
     362    }
     363 
     364  // find Track
     365  /*element = root->FirstChildElement( "Track");
     366  if( element == NULL)
     367    {
     368      PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n");
     369    }
     370  else
     371    {   
     372      //load track
     373      PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n");
     374
     375      trackManager->loadTrack( element);
     376      trackManager->finalize();
     377      PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n");
     378    }*/
     379 
     380  // free the XML data
     381
     382  delete XMLDoc;
     383  /* GENERIC LOADING PROCESS FINISHED */
     384 
     385  // bind input
     386  Orxonox *orx = Orxonox::getInstance ();
     387  orx->getLocalInput()->bind (localPlayer);
     388 
     389  // bind camera
     390  //this->localCamera->bind (localPlayer);
     391  this->localPlayer->addChild (this->localCamera);
     392 
     393 
     394  // stuff beyond this point remains to be loaded properly
     395 
    215396      // initializing the TrackManager
    216       trackManager = TrackManager::getInstance();
     397  this->trackManager = TrackManager::getInstance();
    217398      //trackManager->addPoint(Vector(0,0,0));
    218399      trackManager->addPoint(Vector(150, -35, 5));
     
    272453
    273454     
    274       /*monitor progress*/
    275       this->glmis->step();
    276 
    277       // LIGHT initialisation
    278       lightMan = LightManager::getInstance();
    279       lightMan->setAmbientColor(.1,.1,.1);
    280       lightMan->addLight();
    281       //      lightMan->setAttenuation(1.0, .01, 0.0);
    282       //      lightMan->setDiffuseColor(1,1,1);
    283       //  lightMan->addLight(1);
    284       //  lightMan->setPosition(20, 10, -20);
    285       //  lightMan->setDiffuseColor(0,0,0);
    286       lightMan->debug();
    287 
    288       switch(this->debugWorldNr)
    289         {
    290           /*
    291             this loads the hard-coded debug world. this only for simplicity and will be
    292             removed by a reald world-loader, which interprets a world-file.
    293             if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
    294             make whatever you want...
    295            */
    296         case DEBUG_WORLD_0:
    297           {
    298             lightMan->setPosition(-5.0, 10.0, -40.0);
    299             this->nullParent = NullParent::getInstance ();
    300             this->nullParent->setName ("NullParent");
    301 
    302             // !\todo old track-system has to be removed
    303 
    304             //create helper for player
    305             //HelperParent* hp = new HelperParent ();
    306             /* the player has to be added to this helper */
    307 
    308             // create a player
    309             this->localPlayer = new Player ();
    310             this->localPlayer->setName ("player");
    311             this->spawn (this->localPlayer);
    312             /*monitor progress*/
    313             //this->glmis->step();
    314             this->glmis->step();
    315 
    316             // bind input
    317             Orxonox *orx = Orxonox::getInstance ();
    318             orx->getLocalInput()->bind (this->localPlayer);
     455  lightMan->setAmbientColor(.1,.1,.1);
     456  lightMan->addLight();
     457  //      lightMan->setAttenuation(1.0, .01, 0.0);
     458  //      lightMan->setDiffuseColor(1,1,1);
     459  //  lightMan->addLight(1);
     460  //  lightMan->setPosition(20, 10, -20);
     461  //  lightMan->setDiffuseColor(0,0,0);
     462  lightMan->debug();
     463  lightMan->setPosition(-5.0, 10.0, -40.0);
     464 
     465  //        trackManager->setBindSlave(env);
     466  PNode* tn = trackManager->getTrackNode();
     467  tn->addChild(this->localPlayer);
     468 
     469  //localCamera->setParent(TrackNode::getInstance());
     470  tn->addChild(this->localCamera);
     471  localCamera->lookAt(tn);
     472  localCamera->setMode(PNODE_MOVEMENT);
     473  this->localPlayer->setMode(PNODE_ALL);
     474  Vector* cameraOffset = new Vector (0, 5, -10);
     475  trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     476 
     477  this->sky->setParent(this->localCamera);
     478
     479  // initialize debug coord system
     480  objectList = glGenLists(1);
     481  glNewList (objectList, GL_COMPILE);
     482 
     483  //  trackManager->drawGraph(.01);
     484  trackManager->debug(2);
     485  glEndList();
     486
     487  terrain = new Terrain("worlds/newGround.obj");
     488  terrain->setRelCoor(Vector(0,-10,0));
     489  this->spawn(terrain);
     490
     491}
     492
     493void World::loadDebugWorld(int worldID)
     494{
     495  /*monitor progress*/
     496  this->glmis->step();
     497
     498  // LIGHT initialisation
     499
     500  lightMan->setAmbientColor(.1,.1,.1);
     501  lightMan->addLight();
     502  //      lightMan->setAttenuation(1.0, .01, 0.0);
     503  //      lightMan->setDiffuseColor(1,1,1);
     504  //  lightMan->addLight(1);
     505  //  lightMan->setPosition(20, 10, -20);
     506  //  lightMan->setDiffuseColor(0,0,0);
     507  lightMan->debug();
     508
     509  switch(this->debugWorldNr)
     510    {
     511      /*
     512        this loads the hard-coded debug world. this only for simplicity and will be
     513        removed by a reald world-loader, which interprets a world-file.
     514        if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
     515        make whatever you want...
     516      */
     517    case DEBUG_WORLD_0:
     518      {
     519        lightMan->setPosition(-5.0, 10.0, -40.0);
     520
     521        // !\todo old track-system has to be removed
     522
     523        //create helper for player
     524        //HelperParent* hp = new HelperParent ();
     525        /* the player has to be added to this helper */
     526
     527        // create a player
     528        this->localPlayer = new Player ();
     529        this->localPlayer->setName ("player");
     530        this->spawn (this->localPlayer);
     531        /*monitor progress*/
     532        //this->glmis->step();
     533        this->glmis->step();
     534
     535        // bind input
     536        Orxonox *orx = Orxonox::getInstance ();
     537        orx->getLocalInput()->bind (this->localPlayer);
    319538           
    320             // bind camera
    321             this->localCamera = new Camera();
    322             this->localCamera->setName ("camera");
     539        // bind camera
     540        this->localCamera = new Camera();
     541        this->localCamera->setName ("camera");
    323542           
    324             /*monitor progress*/
    325             this->glmis->step();
    326 
    327             // Create SkySphere
    328             //      this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    329             //      this->skySphere->setName("SkySphere");
    330             //      this->localCamera->addChild(this->skySphere);
    331             //      this->spawn(this->skySphere);
    332             skyBox = new SkyBox();
    333             skyBox->setTexture("pictures/sky/skybox", "jpg");
    334             skyBox->setParent(localCamera);
    335             this->spawn(skyBox);
    336 
    337             /*monitor progress*/
    338             this->glmis->step();
     543        /*monitor progress*/
     544        this->glmis->step();
     545
     546        sky = new SkyBox();
     547        //      (SkyBox*)(sky)->setTexture("pictures/sky/skybox", "jpg");
     548        sky->setParent(localCamera);
     549        this->spawn(sky);
     550
     551        /*monitor progress*/
     552        this->glmis->step();
    339553
    340554           
    341             WorldEntity* env = new Environment();
    342             env->setName ("env");
    343             this->spawn(env);
     555        WorldEntity* env = new Environment();
     556        env->setName ("env");
     557        this->spawn(env);
    344558
    345559           
    346             /*
    347             Vector* es = new Vector (10, 5, 0);
    348             Quaternion* qs = new Quaternion ();
    349             WorldEntity* pr = new Primitive(P_CYLINDER);
    350             pr->setName("primitive");
    351             this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
    352             */
    353 
    354             /*monitor progress*/
    355             this->glmis->step();
    356 
    357             //      trackManager->setBindSlave(env);
    358             PNode* tn = trackManager->getTrackNode();
    359             tn->addChild(this->localPlayer);
    360             this->localCamera->lookAt(tn);
    361 
    362             //localCamera->setParent(TrackNode::getInstance());
    363             tn->addChild(this->localCamera);
    364             //      localCamera->lookAt(tn);
    365             this->localPlayer->setMode(PNODE_ALL);
    366             //Vector* cameraOffset = new Vector (0, 5, -10);
    367             trackManager->condition(2, LEFTRIGHT, this->localPlayer);
    368             this->glmis->step();
    369             break;
    370           }
    371         case DEBUG_WORLD_1:
    372           {
    373             lightMan->setPosition(.0, .0, .0);
    374             lightMan->setAttenuation(1.0, .01, 0.0);
    375             lightMan->setSpecularColor(1,0,0);
    376             this->nullParent = NullParent::getInstance ();
    377             this->nullParent->setName ("NullParent");
    378 
    379             // create a player
    380             WorldEntity* myPlayer = new Player();
    381             myPlayer->setName ("player");
    382             this->spawn(myPlayer);
    383             this->localPlayer = myPlayer;           
     560        /*
     561          Vector* es = new Vector (10, 5, 0);
     562          Quaternion* qs = new Quaternion ();
     563          WorldEntity* pr = new Primitive(P_CYLINDER);
     564          pr->setName("primitive");
     565          this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     566        */
     567
     568        /*monitor progress*/
     569        this->glmis->step();
     570
     571        //          trackManager->setBindSlave(env);
     572        PNode* tn = trackManager->getTrackNode();
     573        tn->addChild(this->localPlayer);
     574        this->localCamera->lookAt(tn);
     575
     576        //localCamera->setParent(TrackNode::getInstance());
     577        tn->addChild(this->localCamera);
     578        //          localCamera->lookAt(tn);
     579        this->localPlayer->setMode(PNODE_ALL);
     580        //Vector* cameraOffset = new Vector (0, 5, -10);
     581        trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     582        this->glmis->step();
     583        break;
     584      }
     585    case DEBUG_WORLD_1:
     586      {
     587        lightMan->setPosition(.0, .0, .0);
     588        lightMan->setAttenuation(1.0, .01, 0.0);
     589        lightMan->setSpecularColor(1,0,0);
     590        this->nullParent = NullParent::getInstance ();
     591        this->nullParent->setName ("NullParent");
     592
     593        // create a player
     594        WorldEntity* myPlayer = new Player();
     595        myPlayer->setName ("player");
     596        this->spawn(myPlayer);
     597        this->localPlayer = myPlayer;       
    384598           
    385             // bind input
    386             Orxonox *orx = Orxonox::getInstance();
    387             orx->getLocalInput()->bind (myPlayer);
     599        // bind input
     600        Orxonox *orx = Orxonox::getInstance();
     601        orx->getLocalInput()->bind (myPlayer);
    388602           
    389             // bind camera
    390             this->localCamera = new Camera ();
    391             this->localCamera->setName ("camera");
    392             this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
    393             this->localCamera->setParent(this->localPlayer);
    394 
    395             // Create SkySphere
    396             skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    397             this->localPlayer->addChild(this->skySphere);
    398             this->spawn(this->skySphere);
    399             Vector* es = new Vector (20, 0, 0);
    400             Quaternion* qs = new Quaternion ();
    401 
    402             lightMan->getLight(0)->setParent(trackManager->getTrackNode());
    403             break;
    404           }
    405         case DEBUG_WORLD_2:
    406           {
    407             lightMan->setAmbientColor(.1,.1,.1);
    408             lightMan->addLight();
    409             lightMan->setPosition(-5.0, 10.0, -40.0);
    410             this->nullParent = NullParent::getInstance ();
    411             this->nullParent->setName ("NullParent");
    412 
    413             // !\todo old track-system has to be removed
    414 
    415             //create helper for player
    416             //HelperParent* hp = new HelperParent ();
    417             /* the player has to be added to this helper */
    418 
    419             // create a player
    420             this->localPlayer = new Player ();
    421             this->localPlayer->setName ("player");
    422             this->spawn (this->localPlayer);
    423             /*monitor progress*/
    424             //this->glmis->step();         
    425             this->glmis->step();
    426 
    427             // bind input
    428             Orxonox *orx = Orxonox::getInstance ();
    429             orx->getLocalInput()->bind (this->localPlayer);
     603        // bind camera
     604        this->localCamera = new Camera ();
     605        this->localCamera->setName ("camera");
     606        this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
     607        this->localCamera->setParent(this->localPlayer);
     608
     609        // Create SkySphere
     610        sky = new Skysphere("pictures/sky-replace.jpg");
     611        this->localPlayer->addChild(this->sky);
     612        this->spawn(this->sky);
     613        Vector* es = new Vector (20, 0, 0);
     614        Quaternion* qs = new Quaternion ();
     615
     616        lightMan->getLight(0)->setParent(trackManager->getTrackNode());
     617        break;
     618      }
     619    case DEBUG_WORLD_2:
     620      {
     621        lightMan->setAmbientColor(.1,.1,.1);
     622        lightMan->addLight();
     623        lightMan->setPosition(-5.0, 10.0, -40.0);
     624        this->nullParent = NullParent::getInstance ();
     625        this->nullParent->setName ("NullParent");
     626
     627        // !\todo old track-system has to be removed
     628
     629        //create helper for player
     630        //HelperParent* hp = new HelperParent ();
     631        /* the player has to be added to this helper */
     632
     633        // create a player
     634        this->localPlayer = new Player ();
     635        this->localPlayer->setName ("player");
     636        this->spawn (this->localPlayer);
     637        /*monitor progress*/
     638        //this->glmis->step();     
     639        this->glmis->step();
     640
     641        // bind input
     642        Orxonox *orx = Orxonox::getInstance ();
     643        orx->getLocalInput()->bind (this->localPlayer);
    430644           
    431             // bind camera
    432             this->localCamera = new Camera();
    433             this->localCamera->setName ("camera");
    434             this->localCamera->lookAt(this->localPlayer);
    435             this->localCamera->setParent(this->localPlayer);
     645        // bind camera
     646        this->localCamera = new Camera();
     647        this->localCamera->setName ("camera");
     648        this->localCamera->lookAt(this->localPlayer);
     649        this->localCamera->setParent(this->localPlayer);
    436650           
    437             /*monitor progress*/
    438             this->glmis->step();
    439 
    440             // Create SkySphere
    441             this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    442             this->skySphere->setName("SkySphere");
    443             this->spawn(this->skySphere);
    444             this->localCamera->addChild(this->skySphere);
    445             this->skySphere->setMode(PNODE_MOVEMENT);
    446             /*monitor progress*/
    447             this->glmis->step();
    448 
    449 
    450             WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2);
    451             this->localPlayer->addChild(baseNode);
    452             baseNode->setRelCoor(Vector(10.0, 2.0, 1.0));
    453             this->spawn(baseNode);
    454 
    455             WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
    456             baseNode->addChild(secondNode);
    457             secondNode->setRelCoor(Vector(0.0, 0.0, 3.0));
    458             this->spawn(secondNode);
    459 
    460 
    461             WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
    462             secondNode->addChild(thirdNode);
    463             thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0));
    464             this->spawn(thirdNode);
     651        /*monitor progress*/
     652        this->glmis->step();
     653
     654        // Create SkySphere
     655        this->sky = new Skysphere("pictures/sky-replace.jpg");
     656        this->sky->setName("SkySphere");
     657        this->spawn(this->sky);
     658        this->localCamera->addChild(this->sky);
     659        this->sky->setMode(PNODE_MOVEMENT);
     660        /*monitor progress*/
     661        this->glmis->step();
     662
     663
     664        WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2);
     665        this->localPlayer->addChild(baseNode);
     666        baseNode->setRelCoor(Vector(10.0, 2.0, 1.0));
     667        this->spawn(baseNode);
     668
     669        WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
     670        baseNode->addChild(secondNode);
     671        secondNode->setRelCoor(Vector(0.0, 0.0, 3.0));
     672        this->spawn(secondNode);
     673
     674
     675        WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
     676        secondNode->addChild(thirdNode);
     677        thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0));
     678        this->spawn(thirdNode);
    465679
    466680           
     681   
     682        WorldEntity* c = new Environment();
     683        this->localPlayer->addChild(c);
     684        c->setRelCoor(Vector(10.0, 2.0, -1.0));
     685        this->spawn(c);
     686
     687
    467688           
    468 
    469             WorldEntity* b = new Environment();
    470             this->localPlayer->addChild(b);
    471             b->setRelCoor(Vector(10.0, 1.0, 1.0));
    472             this->spawn(b);
    473 
    474            
    475             WorldEntity* c = new Environment();
    476             this->localPlayer->addChild(c);
    477             c->setRelCoor(Vector(10.0, 2.0, -1.0));
    478             this->spawn(c);
    479            
    480             /*     
    481                   KeyFrame* f1 = new KeyFrame;
    482                   f1->position = new Vector(-1.1, 0.0, 2.6);
    483                   f1->direction = new Quaternion();
    484                   f1->time = 1.0;
    485                   f1->mode = NEG_EXP;
     689        Animation3D* animation = new Animation3D(c);
     690        animation->setInfinity(ANIM_INF_REPLAY);
     691
     692
     693        animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     694        animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     695        animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     696
     697
     698
     699
     700
     701
     702        /*         
     703          KeyFrame* f1 = new KeyFrame;
     704          f1->position = new Vector(-1.1, 0.0, 2.6);
     705          f1->direction = new Quaternion();
     706          f1->time = 1.0;
     707          f1->mode = NEG_EXP;
    486708                 
    487709                 
    488                   KeyFrame* f2 = new KeyFrame;
    489                   f2->position = new Vector(-2.1, 0.0, 2.6);
    490                   f2->direction = new Quaternion();
    491                   f2->time = 0.1;
    492                   f2->mode = NEG_EXP;
     710          KeyFrame* f2 = new KeyFrame;
     711          f2->position = new Vector(-2.1, 0.0, 2.6);
     712          f2->direction = new Quaternion();
     713          f2->time = 0.1;
     714          f2->mode = NEG_EXP;
    493715                 
    494                   KeyFrame* f3 = new KeyFrame;
    495                   f3->position = new Vector(10.0, 2.0, -1.0);
    496                   f3->direction = new Quaternion();
    497                   f3->time = 0.2;
    498                   f3->mode = NEG_EXP;
     716          KeyFrame* f3 = new KeyFrame;
     717          f3->position = new Vector(10.0, 2.0, -1.0);
     718          f3->direction = new Quaternion();
     719          f3->time = 0.2;
     720          f3->mode = NEG_EXP;
    499721                 
    500                   KeyFrame* f4 = new KeyFrame;
    501                   f4->position = new Vector(10.0, 5.0, -1.0);
    502                   f4->direction = new Quaternion();
    503                   f4->time = 1.0;
    504                   f4->mode = NEG_EXP;
     722          KeyFrame* f4 = new KeyFrame;
     723          f4->position = new Vector(10.0, 5.0, -1.0);
     724          f4->direction = new Quaternion();
     725          f4->time = 1.0;
     726          f4->mode = NEG_EXP;
    505727                 
    506728                 
    507729                 
    508                   this->simpleAnimation->animatorBegin();
    509                   this->simpleAnimation->selectObject(b);
    510                   this->simpleAnimation->setAnimationMode(SINGLE);
    511                   this->simpleAnimation->addKeyFrame(f1);
    512                   this->simpleAnimation->addKeyFrame(f2);
    513                   this->simpleAnimation->start();
    514                   this->simpleAnimation->selectObject(c);
    515                   this->simpleAnimation->addKeyFrame(f3);
    516                   this->simpleAnimation->addKeyFrame(f4);
    517                   this->simpleAnimation->start();
    518                   this->simpleAnimation->animatorEnd();
    519             */
    520 
    521             /*
    522             Vector* es = new Vector (10, 5, 0);
    523             Quaternion* qs = new Quaternion ();
    524             WorldEntity* pr = new Primitive(P_CYLINDER);
    525             pr->setName("primitive");
    526             this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
    527             */
    528 
    529             /*monitor progress*/
    530             this->glmis->step();
    531 
    532             //      trackManager->setBindSlave(env);
    533             PNode* tn = trackManager->getTrackNode();
    534             tn->addChild(this->localPlayer);
    535 
    536             //localCamera->setParent(TrackNode::getInstance());
    537             tn->addChild(this->localCamera);
    538             //      localCamera->lookAt(tn);
    539             this->localPlayer->setMode(PNODE_ALL);
    540             //Vector* cameraOffset = new Vector (0, 5, -10);
    541             trackManager->condition(2, LEFTRIGHT, this->localPlayer);
    542             this->glmis->step();
    543 
    544             break;
    545             }
    546            
    547         case DEBUG_WORLD_3:
    548           {
    549             lightMan->setPosition(-5.0, 10.0, -40.0);
    550             this->nullParent = NullParent::getInstance ();
    551             this->nullParent->setName ("NullParent");
    552 
    553             // !\todo old track-system has to be removed
    554 
    555             //create helper for player
    556             //HelperParent* hp = new HelperParent ();
    557             /* the player has to be added to this helper */
    558 
    559             // create a player
    560             this->localPlayer = new Player ();
    561             this->localPlayer->setName ("player");
    562             this->spawn (this->localPlayer);
    563             /*monitor progress*/
    564             //this->glmis->step();
    565             this->glmis->step();
    566 
    567             // bind input
    568             Orxonox *orx = Orxonox::getInstance ();
    569             orx->getLocalInput()->bind (this->localPlayer);
    570            
    571             // bind camera
    572             this->localCamera = new Camera();
    573             this->localCamera->setName ("camera");
    574            
    575             /*monitor progress*/
    576             this->glmis->step();
    577 
    578             // Create SkySphere
    579             skyBox = new SkyBox();
    580             skyBox->setTexture("pictures/sky/skybox", "jpg");
    581             skyBox->setParent(localCamera);
    582             this->spawn(skyBox);
    583 
    584             /*monitor progress*/
    585             this->glmis->step();
    586 
    587             //WorldEntity* env = new Environment();
    588             //env->setName ("env");
    589             //this->spawn(env);
    590 
    591             /*monitor progress*/
    592             this->glmis->step();
    593 
    594             // trackManager->setBindSlave(env);
    595             PNode* tn = trackManager->getTrackNode();
    596             tn->addChild(this->localPlayer);
    597             this->localCamera->lookAt(tn);
    598 
    599             //localCamera->setParent(TrackNode::getInstance());
    600             tn->addChild(this->localCamera);
    601             //      localCamera->lookAt(tn);
    602             this->localPlayer->setMode(PNODE_ALL);
    603             //Vector* cameraOffset = new Vector (0, 5, -10);
    604             trackManager->condition(2, LEFTRIGHT, this->localPlayer);
    605             this->glmis->step();
    606             break;
    607           }
    608 
    609 
    610         default:
    611           printf("World::load() - no world with ID %i found", this->debugWorldNr );
    612         }
    613        
    614     }
    615   else if(this->worldName != NULL)
    616     {
    617 
    618     }
    619 
    620   // initialize debug coord system
    621   objectList = glGenLists(1);
    622   glNewList (objectList, GL_COMPILE);
    623  
    624   //  trackManager->drawGraph(.01);
    625   trackManager->debug(2);
    626   glEndList();
    627 
    628   //terrain = new Terrain("../data/worlds/newGround.obj");
    629   terrain = new Terrain("../data/pictures/heightmapHello.bmp",100,1);
    630   terrain->setRelCoor(Vector(0,-10,0));
    631   this->spawn(terrain);
    632 
    633 }
     730          this->simpleAnimation->animatorBegin();
     731          this->simpleAnimation->selectObject(b);
     732          this->simpleAnimation->setAnimationMode(SINGLE);
     733          this->simpleAnimation->addKeyFrame(f1);
     734          this->simpleAnimation->addKeyFrame(f2);
     735          this->simpleAnimation->start();
     736          this->simpleAnimation->selectObject(c);
     737          this->simpleAnimation->addKeyFrame(f3);
     738          this->simpleAnimation->addKeyFrame(f4);
     739          this->simpleAnimation->start();
     740          this->simpleAnimation->animatorEnd();
     741        */
     742
     743        /*
     744          Vector* es = new Vector (10, 5, 0);
     745          Quaternion* qs = new Quaternion ();
     746          WorldEntity* pr = new Primitive(P_CYLINDER);
     747          pr->setName("primitive");
     748          this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     749        */
     750
     751        /*monitor progress*/
     752        this->glmis->step();
     753
     754        //          trackManager->setBindSlave(env);
     755        PNode* tn = trackManager->getTrackNode();
     756        tn->addChild(this->localPlayer);
     757
     758        //localCamera->setParent(TrackNode::getInstance());
     759        tn->addChild(this->localCamera);
     760        //          localCamera->lookAt(tn);
     761        this->localPlayer->setMode(PNODE_ALL);
     762        //Vector* cameraOffset = new Vector (0, 5, -10);
     763        trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     764        this->glmis->step();
     765
     766        break;
     767      }
     768    default:
     769      printf("World::load() - no world with ID %i found", this->debugWorldNr );
     770    }
     771}
     772
    634773
    635774
     
    703842 
    704843  //GLMenuImageScreen*
    705   this->glmis = GLMenuImageScreen::getInstance();
     844  this->glmis = new GLMenuImageScreen();
    706845  this->glmis->init();
     846  glmis->setBackgroundImage("pictures/load_screen.jpg");
    707847  this->glmis->setMaximum(8);
    708   this->glmis->draw();
     848  //  this->glmis->draw();
    709849 
    710850  PRINTF(3)("World::displayLoadScreen - end\n");
     
    720860  PRINTF(3)("World::releaseLoadScreen - start\n");
    721861  this->glmis->setValue(this->glmis->getMaximum());
    722   //SDL_Delay(500);
    723862  PRINTF(3)("World::releaseLoadScreen - end\n");
     863  delete this->glmis;
    724864}
    725865
     
    9061046      this->tick ();
    9071047      // Update the state
    908       this->update ();      
     1048      this->update ();     
    9091049      // Process collision
    9101050      this->collide ();
     
    9891129        }
    9901130      delete iterator;
    991       //skySphere->updatePosition(localCamera->absCoordinate);
    992      
     1131
    9931132      /* update tick the rest */
    9941133      this->trackManager->tick(this->dt);
     
    10991238bool World::command(Command* cmd)
    11001239{
    1101   if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
    1102   else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
    1103   else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
    1104   else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
    1105   else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
    1106   else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);
     1240  if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW0)) this->localCamera->setViewMode(VIEW_NORMAL);
     1241  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW1)) this->localCamera->setViewMode(VIEW_BEHIND);
     1242  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW2)) this->localCamera->setViewMode(VIEW_FRONT);
     1243  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW3)) this->localCamera->setViewMode(VIEW_LEFT);
     1244  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW4)) this->localCamera->setViewMode(VIEW_RIGHT);
     1245  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW5)) this->localCamera->setViewMode(VIEW_TOP);
    11071246
    11081247  return false;
    11091248}
    11101249
     1250void World::setPath( const char* name)
     1251{
     1252  if (this->path)
     1253    delete this->path;
     1254  if (ResourceManager::isFile(name))
     1255  {
     1256    this->path = new char[strlen(name)+1];
     1257    strcpy(this->path, name);
     1258  }
     1259  else
     1260    {
     1261      this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];
     1262      sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
     1263    }
     1264}
     1265
     1266const char* World::getPath( void)
     1267{
     1268  return path;
     1269}
  • orxonox/branches/heightMap/src/story_entities/world.h

    r3851 r4122  
    1111#include "story_entity.h"
    1212#include "p_node.h"
    13 
     13#include "xmlparser/tinyxml.h"
    1414
    1515class World;
     
    1919class PNode;
    2020class GLMenuImageScreen;
    21 class Skysphere;
    22 class SkyBox;
    2321class LightManager;
    2422class Terrain;
     
    5755  World (char* name);
    5856  World (int worldID);
     57  World (TiXmlElement* root);
    5958  virtual ~World ();
    6059
     
    7069  virtual ErrorMessage resume ();
    7170  virtual ErrorMessage destroy ();
     71
     72  void loadDebugWorld(int worldID);
    7273
    7374  virtual void displayLoadScreen();
     
    8586             int parentingMode);
    8687
     88  const char* getPath();
     89  void setPath( const char* name);
    8790
    8891 private:
    89   void init(char* name, int worldID);
     92  void constuctorInit(char* name, int worldID);
    9093
    9194  Uint32 lastFrame;                   //!< last time of frame
     
    100103  char* worldName;                    //!< The name of this World
    101104  int debugWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
     105  char* path;                         //!< The file from which this world is loaded
    102106
    103107  PNode* nullParent;                  //!< The zero-point, that everything has as its parent.
    104108  TrackManager* trackManager;         //!< The reference of the TrackManager that handles the course through the Level.
    105109  Camera* localCamera;                //!< The current Camera
    106   Skysphere* skySphere;               //!< The Environmental Heaven of orxonox \todo insert this to environment insted
    107   SkyBox* skyBox;
     110  WorldEntity* sky;                   //!< The Environmental Heaven of orxonox \todo insert this to environment insted
    108111  LightManager* lightMan;             //!< The Lights of the Level
    109112  Terrain* terrain;                   //!< The Terrain of the World.
Note: See TracChangeset for help on using the changeset viewer.