Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4194 in orxonox.OLD for orxonox/branches/openAL/src/story_entities


Ignore:
Timestamp:
May 16, 2005, 1:33:19 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/openAL: merged trunk back to openAL
merged with command:

svn merge ../trunk/ openAL/ -r 3920:HEAD

no conflicts at all

Location:
orxonox/branches/openAL
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/openAL

    • Property svn:externals
      •  

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

    r3832 r4194  
    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/openAL/src/story_entities/campaign.h

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

    r3870 r4194  
     1
    12
    23/*
     
    3940#include "garbage_collector.h"
    4041#include "animation_player.h"
     42#include "particle_engine.h"
    4143
    4244#include "command_node.h"
    4345#include "glmenu_imagescreen.h"
    4446#include "list.h"
    45 
    46 
     47#include "game_loader.h"
     48
     49#include "animation3d.h"
     50
     51#include "substring.h"
    4752
    4853using namespace std;
    49 
    5054
    5155WorldInterface* WorldInterface::singletonRef = 0;
     
    113117}
    114118
    115 
     119CREATE_FACTORY(World);
     120
     121World::World( TiXmlElement* root)
     122{
     123  this->constuctorInit("", -1);
     124  this->path = NULL;
     125  const char *string;
     126  char *name;
     127  int id;
     128 
     129  PRINTF0("Creating a World\n");
     130 
     131  // identifier
     132  string = grabParameter( root, "identifier");
     133  if( string == NULL || sscanf(string, "%d", &id) != 1)
     134    {
     135      PRINTF0("World is missing a proper 'identifier'\n");
     136      this->setStoryID( -1);
     137    }
     138  else setStoryID( id);
     139
     140  // next id
     141  string = grabParameter( root, "nextid");
     142  if( string == NULL || sscanf(string, "%d", &id) != 1)
     143    {
     144      PRINTF0("World is missing a proper 'nextid'\n");
     145      this->setStoryID( -1);
     146    }
     147  else setNextStoryID( id);
     148 
     149
     150  // path
     151  string = grabParameter( root, "path");
     152  if( string == NULL)
     153    {
     154      PRINTF0("World is missing a proper 'path'\n");
     155      this->setPath( NULL);
     156    }
     157  else
     158    {
     159      name = new char[strlen(string + 2)];
     160      strcpy( name, string);
     161      this->setPath( name);
     162    }
     163}
    116164
    117165/**
     
    122170World::World (char* name)
    123171{
    124   this->init(name, -1);
     172  this->path = NULL;
     173  this->constuctorInit(name, -1);
    125174  //NullParent* np = NullParent::getInstance();
    126175}
     
    132181World::World (int worldID)
    133182{
    134   this->init(NULL, worldID);
     183  this->path = NULL;
     184  this->constuctorInit(NULL, worldID);
    135185}
    136186
     
    148198  cn->reset();
    149199
    150   ResourceManager::getInstance()->debug();
    151   ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
    152   ResourceManager::getInstance()->debug();
    153 
    154200  delete WorldInterface::getInstance();
    155201
     
    158204  delete this->lightMan;
    159205  delete this->trackManager;
     206  delete this->particleEngine;
    160207  TextEngine::getInstance()->flush();
    161208
    162   AnimationPlayer::getInstance()->debug();
    163209  delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence.
    164210  //delete garbagecollecor
    165211  //delete animator
    166212
    167 
     213  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
    168214}
    169215
     
    177223   NO LEVEL LOADING HERE - NEVER!
    178224*/
    179 void World::init(char* name, int worldID)
     225void World::constuctorInit(char* name, int worldID)
    180226{
    181227  this->setClassName ("World");
    182228
    183   this->worldName = name;
     229  //this->worldName = name;
     230  //this->worldName = new char[strlen(name)+1];
     231  //strcpy(this->worldName, name);
    184232  this->debugWorldNr = worldID;
    185233  this->entities = new tList<WorldEntity>();
    186   AnimationPlayer::getInstance(); // initializes the animationPlayer
    187234}
    188235
     
    200247  wi->init(this);
    201248  this->garbageCollector = GarbageCollector::getInstance();
     249
     250  this->particleEngine = ParticleEngine::getInstance();
     251  this->trackManager = TrackManager::getInstance();
     252  this->lightMan = LightManager::getInstance();
     253  this->nullParent = NullParent::getInstance ();
     254  this->nullParent->setName ("NullParent");
     255
     256  AnimationPlayer::getInstance(); // initializes the animationPlayer
     257
     258  this->localCamera = new Camera();
     259  this->localCamera->setName ("camera");
    202260}
    203261
     
    207265*/
    208266ErrorMessage World::load()
    209 {
    210   //  BezierCurve* tmpCurve = new BezierCurve();
    211   if(this->debugWorldNr != -1)
    212     {
    213       // initializing Font
    214       this->glmis->step();
     267{       
     268  PRINTF(3)("> Loading world: '%s'\n", getPath());
     269  TiXmlElement* element;
     270  GameLoader* loader = GameLoader::getInstance();
     271 
     272  if( getPath() == NULL)
     273    {
     274      PRINTF(1)("World has no path specified for loading");
     275      return (ErrorMessage){213,"Path not specified","World::load()"};
     276    }
     277 
     278  TiXmlDocument* XMLDoc = new TiXmlDocument( path);
     279  // load the campaign document
     280  if( !XMLDoc->LoadFile()) 
     281  {
     282    // report an error
     283    PRINTF(1)("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      PRINTF(1)("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      PRINTF(2)("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  // LOADSCREEN //
     320  ////////////////
     321  element = root->FirstChildElement("LoadScreen");
     322  if (element == NULL)
     323    {
     324      PRINTF(2)("no LoadScreen specified, loading default\n");
     325
     326      glmis->setBackgroundImage("pictures/load_screen.jpg");
     327      this->glmis->setMaximum(8);
     328      this->glmis->draw();
     329    }
     330  else
     331    {
     332      this->glmis->load(element);
     333      this->glmis->draw();
     334    }
     335  this->glmis->draw();
     336  // find WorldEntities
     337  element = root->FirstChildElement("WorldEntities");
     338 
     339  if( element == NULL)
     340    {
     341      PRINTF(1)("World is missing 'WorldEntities'\n");
     342    }
     343  else
     344    {
     345      element = element->FirstChildElement();
     346      // load Players/Objects/Whatever
     347      PRINTF(4)("Loading WorldEntities\n");
     348      while( element != NULL)
     349        {
     350          WorldEntity* created = (WorldEntity*) loader->fabricate( element);
     351          if( created != NULL) this->spawn( created);
     352          // if we load a 'Player' we use it as localPlayer
     353          //todo do this more elegant
     354          if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
     355          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created;
     356          element = element->NextSiblingElement();
     357          glmis->step(); //! \todo temporary
     358        }
     359      PRINTF(4)("Done loading WorldEntities\n");
     360    }
     361 
     362  // find Track
     363  /*element = root->FirstChildElement( "Track");
     364  if( element == NULL)
     365    {
     366      PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n");
     367    }
     368  else
     369    {   
     370      //load track
     371      PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n");
     372
     373      trackManager->loadTrack( element);
     374      trackManager->finalize();
     375      PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n");
     376    }*/
     377 
     378  // free the XML data
     379
     380  delete XMLDoc;
     381  /* GENERIC LOADING PROCESS FINISHED */
     382 
     383  // bind input
     384  Orxonox *orx = Orxonox::getInstance ();
     385  orx->getLocalInput()->bind (localPlayer);
     386 
     387  // bind camera
     388  //this->localCamera->bind (localPlayer);
     389  this->localPlayer->addChild (this->localCamera);
     390 
     391 
     392  // stuff beyond this point remains to be loaded properly
     393 
    215394      // initializing the TrackManager
    216       trackManager = TrackManager::getInstance();
     395  this->trackManager = TrackManager::getInstance();
    217396      //trackManager->addPoint(Vector(0,0,0));
    218397      trackManager->addPoint(Vector(150, -35, 5));
     
    272451
    273452     
    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);
     453  lightMan->setAmbientColor(.1,.1,.1);
     454  lightMan->addLight();
     455  //      lightMan->setAttenuation(1.0, .01, 0.0);
     456  //      lightMan->setDiffuseColor(1,1,1);
     457  //  lightMan->addLight(1);
     458  //  lightMan->setPosition(20, 10, -20);
     459  //  lightMan->setDiffuseColor(0,0,0);
     460  lightMan->debug();
     461  lightMan->setPosition(-5.0, 10.0, -40.0);
     462 
     463  //        trackManager->setBindSlave(env);
     464  PNode* tn = trackManager->getTrackNode();
     465  tn->addChild(this->localPlayer);
     466 
     467  //localCamera->setParent(TrackNode::getInstance());
     468  tn->addChild(this->localCamera);
     469  localCamera->lookAt(tn);
     470  localCamera->setMode(PNODE_MOVEMENT);
     471  this->localPlayer->setMode(PNODE_ALL);
     472  Vector* cameraOffset = new Vector (0, 5, -10);
     473  trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     474 
     475  this->sky->setParent(this->localCamera);
     476
     477  // initialize debug coord system
     478  objectList = glGenLists(1);
     479  glNewList (objectList, GL_COMPILE);
     480 
     481  //  trackManager->drawGraph(.01);
     482  trackManager->debug(2);
     483  glEndList();
     484
     485  terrain = new Terrain("worlds/newGround.obj");
     486  terrain->setRelCoor(Vector(0,-10,0));
     487  this->spawn(terrain);
     488
     489
     490  ParticleSystem* system = new ParticleSystem(1000, PARTICLE_SPRITE);
     491  system->setLifeSpan(.5);
     492  system->setConserve(.99);
     493  system->setRadius(2, 0, 2, 0);
     494
     495  ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 100, .05);
     496  emitter->setParent(this->localPlayer);
     497 
     498  particleEngine->addConnection(emitter, system);
     499}
     500
     501void World::loadDebugWorld(int worldID)
     502{
     503  /*monitor progress*/
     504  this->glmis->step();
     505
     506  // LIGHT initialisation
     507
     508  lightMan->setAmbientColor(.1,.1,.1);
     509  lightMan->addLight();
     510  //      lightMan->setAttenuation(1.0, .01, 0.0);
     511  //      lightMan->setDiffuseColor(1,1,1);
     512  //  lightMan->addLight(1);
     513  //  lightMan->setPosition(20, 10, -20);
     514  //  lightMan->setDiffuseColor(0,0,0);
     515  lightMan->debug();
     516
     517  switch(this->debugWorldNr)
     518    {
     519      /*
     520        this loads the hard-coded debug world. this only for simplicity and will be
     521        removed by a reald world-loader, which interprets a world-file.
     522        if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
     523        make whatever you want...
     524      */
     525    case DEBUG_WORLD_0:
     526      {
     527        lightMan->setPosition(-5.0, 10.0, -40.0);
     528
     529        // !\todo old track-system has to be removed
     530
     531        //create helper for player
     532        //HelperParent* hp = new HelperParent ();
     533        /* the player has to be added to this helper */
     534
     535        // create a player
     536        this->localPlayer = new Player ();
     537        this->localPlayer->setName ("player");
     538        this->spawn (this->localPlayer);
     539        /*monitor progress*/
     540        //this->glmis->step();
     541        this->glmis->step();
     542
     543        // bind input
     544        Orxonox *orx = Orxonox::getInstance ();
     545        orx->getLocalInput()->bind (this->localPlayer);
    319546           
    320             // bind camera
    321             this->localCamera = new Camera();
    322             this->localCamera->setName ("camera");
     547        // bind camera
     548        this->localCamera = new Camera();
     549        this->localCamera->setName ("camera");
    323550           
    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();
     551        /*monitor progress*/
     552        this->glmis->step();
     553
     554        sky = new SkyBox();
     555        //      (SkyBox*)(sky)->setTexture("pictures/sky/skybox", "jpg");
     556        sky->setParent(localCamera);
     557        this->spawn(sky);
     558
     559        /*monitor progress*/
     560        this->glmis->step();
    339561
    340562           
    341             WorldEntity* env = new Environment();
    342             env->setName ("env");
    343             this->spawn(env);
     563        WorldEntity* env = new Environment();
     564        env->setName ("env");
     565        this->spawn(env);
    344566
    345567           
    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;           
     568        /*
     569          Vector* es = new Vector (10, 5, 0);
     570          Quaternion* qs = new Quaternion ();
     571          WorldEntity* pr = new Primitive(P_CYLINDER);
     572          pr->setName("primitive");
     573          this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     574        */
     575
     576        /*monitor progress*/
     577        this->glmis->step();
     578
     579        //          trackManager->setBindSlave(env);
     580        PNode* tn = trackManager->getTrackNode();
     581        tn->addChild(this->localPlayer);
     582        this->localCamera->lookAt(tn);
     583
     584        //localCamera->setParent(TrackNode::getInstance());
     585        tn->addChild(this->localCamera);
     586        //          localCamera->lookAt(tn);
     587        this->localPlayer->setMode(PNODE_ALL);
     588        //Vector* cameraOffset = new Vector (0, 5, -10);
     589        trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     590        this->glmis->step();
     591        break;
     592      }
     593    case DEBUG_WORLD_1:
     594      {
     595        lightMan->setPosition(.0, .0, .0);
     596        lightMan->setAttenuation(1.0, .01, 0.0);
     597        lightMan->setSpecularColor(1,0,0);
     598        this->nullParent = NullParent::getInstance ();
     599        this->nullParent->setName ("NullParent");
     600
     601        // create a player
     602        WorldEntity* myPlayer = new Player();
     603        myPlayer->setName ("player");
     604        this->spawn(myPlayer);
     605        this->localPlayer = myPlayer;       
    384606           
    385             // bind input
    386             Orxonox *orx = Orxonox::getInstance();
    387             orx->getLocalInput()->bind (myPlayer);
     607        // bind input
     608        Orxonox *orx = Orxonox::getInstance();
     609        orx->getLocalInput()->bind (myPlayer);
    388610           
    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);
     611        // bind camera
     612        this->localCamera = new Camera ();
     613        this->localCamera->setName ("camera");
     614        this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
     615        this->localCamera->setParent(this->localPlayer);
     616
     617        // Create SkySphere
     618        sky = new Skysphere("pictures/sky-replace.jpg");
     619        this->localPlayer->addChild(this->sky);
     620        this->spawn(this->sky);
     621        Vector* es = new Vector (20, 0, 0);
     622        Quaternion* qs = new Quaternion ();
     623
     624        lightMan->getLight(0)->setParent(trackManager->getTrackNode());
     625        break;
     626      }
     627    case DEBUG_WORLD_2:
     628      {
     629        lightMan->setAmbientColor(.1,.1,.1);
     630        lightMan->addLight();
     631        lightMan->setPosition(-5.0, 10.0, -40.0);
     632        this->nullParent = NullParent::getInstance ();
     633        this->nullParent->setName ("NullParent");
     634
     635        // !\todo old track-system has to be removed
     636
     637        //create helper for player
     638        //HelperParent* hp = new HelperParent ();
     639        /* the player has to be added to this helper */
     640
     641        // create a player
     642        this->localPlayer = new Player ();
     643        this->localPlayer->setName ("player");
     644        this->spawn (this->localPlayer);
     645        /*monitor progress*/
     646        //this->glmis->step();     
     647        this->glmis->step();
     648
     649        // bind input
     650        Orxonox *orx = Orxonox::getInstance ();
     651        orx->getLocalInput()->bind (this->localPlayer);
    430652           
    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);
     653        // bind camera
     654        this->localCamera = new Camera();
     655        this->localCamera->setName ("camera");
     656        this->localCamera->lookAt(this->localPlayer);
     657        this->localCamera->setParent(this->localPlayer);
    436658           
    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);
     659        /*monitor progress*/
     660        this->glmis->step();
     661
     662        // Create SkySphere
     663        this->sky = new Skysphere("pictures/sky-replace.jpg");
     664        this->sky->setName("SkySphere");
     665        this->spawn(this->sky);
     666        this->localCamera->addChild(this->sky);
     667        this->sky->setMode(PNODE_MOVEMENT);
     668        /*monitor progress*/
     669        this->glmis->step();
     670
     671
     672        WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2);
     673        this->localPlayer->addChild(baseNode);
     674        baseNode->setRelCoor(Vector(10.0, 2.0, 1.0));
     675        this->spawn(baseNode);
     676
     677        WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
     678        baseNode->addChild(secondNode);
     679        secondNode->setRelCoor(Vector(0.0, 0.0, 3.0));
     680        this->spawn(secondNode);
     681
     682
     683        WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
     684        secondNode->addChild(thirdNode);
     685        thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0));
     686        this->spawn(thirdNode);
    465687
    466688           
     689   
     690        WorldEntity* c = new Environment();
     691        this->localPlayer->addChild(c);
     692        c->setRelCoor(Vector(10.0, 2.0, -1.0));
     693        this->spawn(c);
     694
     695
    467696           
    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;
     697        Animation3D* animation = new Animation3D(c);
     698        animation->setInfinity(ANIM_INF_REPLAY);
     699
     700
     701        animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     702        animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     703        animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR);
     704
     705
     706
     707
     708
     709
     710        /*         
     711          KeyFrame* f1 = new KeyFrame;
     712          f1->position = new Vector(-1.1, 0.0, 2.6);
     713          f1->direction = new Quaternion();
     714          f1->time = 1.0;
     715          f1->mode = NEG_EXP;
    486716                 
    487717                 
    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;
     718          KeyFrame* f2 = new KeyFrame;
     719          f2->position = new Vector(-2.1, 0.0, 2.6);
     720          f2->direction = new Quaternion();
     721          f2->time = 0.1;
     722          f2->mode = NEG_EXP;
    493723                 
    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;
     724          KeyFrame* f3 = new KeyFrame;
     725          f3->position = new Vector(10.0, 2.0, -1.0);
     726          f3->direction = new Quaternion();
     727          f3->time = 0.2;
     728          f3->mode = NEG_EXP;
    499729                 
    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;
     730          KeyFrame* f4 = new KeyFrame;
     731          f4->position = new Vector(10.0, 5.0, -1.0);
     732          f4->direction = new Quaternion();
     733          f4->time = 1.0;
     734          f4->mode = NEG_EXP;
    505735                 
    506736                 
    507737                 
    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         default:
    547           printf("World::load() - no world with ID %i found", this->debugWorldNr );
    548         }
    549     }
    550   else if(this->worldName != NULL)
    551     {
    552 
    553     }
    554 
    555   // initialize debug coord system
    556   objectList = glGenLists(1);
    557   glNewList (objectList, GL_COMPILE);
    558  
    559   //  trackManager->drawGraph(.01);
    560   trackManager->debug(2);
    561   glEndList();
    562 
    563   terrain = new Terrain("../data/worlds/newGround.obj");
    564   terrain->setRelCoor(Vector(0,-10,0));
    565   this->spawn(terrain);
    566 
    567 }
     738          this->simpleAnimation->animatorBegin();
     739          this->simpleAnimation->selectObject(b);
     740          this->simpleAnimation->setAnimationMode(SINGLE);
     741          this->simpleAnimation->addKeyFrame(f1);
     742          this->simpleAnimation->addKeyFrame(f2);
     743          this->simpleAnimation->start();
     744          this->simpleAnimation->selectObject(c);
     745          this->simpleAnimation->addKeyFrame(f3);
     746          this->simpleAnimation->addKeyFrame(f4);
     747          this->simpleAnimation->start();
     748          this->simpleAnimation->animatorEnd();
     749        */
     750
     751        /*
     752          Vector* es = new Vector (10, 5, 0);
     753          Quaternion* qs = new Quaternion ();
     754          WorldEntity* pr = new Primitive(P_CYLINDER);
     755          pr->setName("primitive");
     756          this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     757        */
     758
     759        /*monitor progress*/
     760        this->glmis->step();
     761
     762        //          trackManager->setBindSlave(env);
     763        PNode* tn = trackManager->getTrackNode();
     764        tn->addChild(this->localPlayer);
     765
     766        //localCamera->setParent(TrackNode::getInstance());
     767        tn->addChild(this->localCamera);
     768        //          localCamera->lookAt(tn);
     769        this->localPlayer->setMode(PNODE_ALL);
     770        //Vector* cameraOffset = new Vector (0, 5, -10);
     771        trackManager->condition(2, LEFTRIGHT, this->localPlayer);
     772        this->glmis->step();
     773
     774        break;
     775      }
     776    default:
     777      printf("World::load() - no world with ID %i found", this->debugWorldNr );
     778    }
     779}
     780
    568781
    569782
     
    637850 
    638851  //GLMenuImageScreen*
    639   this->glmis = GLMenuImageScreen::getInstance();
     852  this->glmis = new GLMenuImageScreen();
    640853  this->glmis->init();
    641854  this->glmis->setMaximum(8);
    642   this->glmis->draw();
     855  //  this->glmis->draw();
    643856 
    644857  PRINTF(3)("World::displayLoadScreen - end\n");
     
    654867  PRINTF(3)("World::releaseLoadScreen - start\n");
    655868  this->glmis->setValue(this->glmis->getMaximum());
    656   //SDL_Delay(500);
    657869  PRINTF(3)("World::releaseLoadScreen - end\n");
     870  delete this->glmis;
    658871}
    659872
     
    745958
    746959  TextEngine::getInstance()->draw();
     960  particleEngine->draw(this->dtS); //!< \todo should be dts like in the Trunk;
     961
    747962  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
    748963}
     
    8401055      this->tick ();
    8411056      // Update the state
    842       this->update ();      
     1057      this->update ();     
    8431058      // Process collision
    8441059      this->collide ();
     
    9121127     
    9131128      /* function to let all entities tick (iterate through list) */
    914       float seconds = this->dt / 1000.0;     
    915       this->gameTime += seconds;
     1129      this->dtS = (float)this->dt / 1000.0;     
     1130      this->gameTime += this->dtS;
    9161131      //entity = entities->enumerate();
    9171132      tIterator<WorldEntity>* iterator = this->entities->getIterator();
     
    9191134      while( entity != NULL)
    9201135        {
    921           entity->tick (seconds);
     1136          entity->tick (this->dtS);
    9221137          entity = iterator->nextElement();
    9231138        }
    9241139      delete iterator;
    925       //skySphere->updatePosition(localCamera->absCoordinate);
    926      
     1140
    9271141      /* update tick the rest */
    9281142      this->trackManager->tick(this->dt);
    9291143      this->localCamera->tick(this->dt);
    930       this->garbageCollector->tick(seconds);
    931 
    932       AnimationPlayer::getInstance()->tick(seconds);
     1144      this->garbageCollector->tick(this->dtS);
     1145
     1146      AnimationPlayer::getInstance()->tick(this->dtS);
     1147      particleEngine->tick(this->dtS);
    9331148    }
    9341149  this->lastFrame = currentFrame;
     
    9451160{
    9461161  this->garbageCollector->update();
    947   this->nullParent->update (dt);
     1162  this->nullParent->update (this->dtS);
    9481163}
    9491164
     
    10331248bool World::command(Command* cmd)
    10341249{
    1035   if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
    1036   else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
    1037   else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
    1038   else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
    1039   else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
    1040   else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);
     1250  if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW0)) this->localCamera->setViewMode(VIEW_NORMAL);
     1251  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW1)) this->localCamera->setViewMode(VIEW_BEHIND);
     1252  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW2)) this->localCamera->setViewMode(VIEW_FRONT);
     1253  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW3)) this->localCamera->setViewMode(VIEW_LEFT);
     1254  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW4)) this->localCamera->setViewMode(VIEW_RIGHT);
     1255  else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW5)) this->localCamera->setViewMode(VIEW_TOP);
    10411256
    10421257  return false;
    10431258}
    10441259
     1260void World::setPath( const char* name)
     1261{
     1262  if (this->path)
     1263    delete this->path;
     1264  if (ResourceManager::isFile(name))
     1265  {
     1266    this->path = new char[strlen(name)+1];
     1267    strcpy(this->path, name);
     1268  }
     1269  else
     1270    {
     1271      this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];
     1272      sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
     1273    }
     1274}
     1275
     1276const char* World::getPath( void)
     1277{
     1278  return path;
     1279}
  • orxonox/branches/openAL/src/story_entities/world.h

    r3851 r4194  
    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;
     22class ParticleEngine;
    2423class Terrain;
    2524class GarbageCollector;
     
    5756  World (char* name);
    5857  World (int worldID);
     58  World (TiXmlElement* root);
    5959  virtual ~World ();
    6060
     
    7070  virtual ErrorMessage resume ();
    7171  virtual ErrorMessage destroy ();
     72
     73  void loadDebugWorld(int worldID);
    7274
    7375  virtual void displayLoadScreen();
     
    8587             int parentingMode);
    8688
     89  const char* getPath();
     90  void setPath( const char* name);
    8791
    8892 private:
    89   void init(char* name, int worldID);
     93  void constuctorInit(char* name, int worldID);
    9094
    9195  Uint32 lastFrame;                   //!< last time of frame
    9296  Uint32 dt;                          //!< time needed to calculate this frame
     97  float dtS;                          //!< The time needed for caluculations in seconds
    9398  double gameTime;                    //!< this is where the game time is saved
    9499  bool bQuitOrxonox;                  //!< quit this application
     
    100105  char* worldName;                    //!< The name of this World
    101106  int debugWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
     107  char* path;                         //!< The file from which this world is loaded
    102108
    103109  PNode* nullParent;                  //!< The zero-point, that everything has as its parent.
    104110  TrackManager* trackManager;         //!< The reference of the TrackManager that handles the course through the Level.
     111  ParticleEngine* particleEngine;     //!< The ParticleEngine of the World.
    105112  Camera* localCamera;                //!< The current Camera
    106   Skysphere* skySphere;               //!< The Environmental Heaven of orxonox \todo insert this to environment insted
    107   SkyBox* skyBox;
     113  WorldEntity* sky;                   //!< The Environmental Heaven of orxonox \todo insert this to environment insted
    108114  LightManager* lightMan;             //!< The Lights of the Level
    109115  Terrain* terrain;                   //!< The Terrain of the World.
Note: See TracChangeset for help on using the changeset viewer.