Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 18, 2005, 11:27:40 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/movie_player: merged the trunk back into the movie_player
merged with command:
svn merge -r 4014:HEAD ../trunk/ movie_player/
no conflicts

File:
1 edited

Legend:

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

    r4010 r4217  
    4040#include "garbage_collector.h"
    4141#include "animation_player.h"
     42#include "particle_engine.h"
    4243
    4344#include "command_node.h"
     
    121122{
    122123  this->constuctorInit("", -1);
    123 
     124  this->path = NULL;
    124125  const char *string;
    125126  char *name;
     
    169170World::World (char* name)
    170171{
     172  this->path = NULL;
    171173  this->constuctorInit(name, -1);
    172174  //NullParent* np = NullParent::getInstance();
     
    179181World::World (int worldID)
    180182{
     183  this->path = NULL;
    181184  this->constuctorInit(NULL, worldID);
    182185}
     
    195198  cn->reset();
    196199
    197   ResourceManager::getInstance()->debug();
    198   ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
    199   ResourceManager::getInstance()->debug();
    200 
    201200  delete WorldInterface::getInstance();
    202201
     
    205204  delete this->lightMan;
    206205  delete this->trackManager;
     206  delete this->particleEngine;
    207207  TextEngine::getInstance()->flush();
    208208
    209   AnimationPlayer::getInstance()->debug();
    210209  delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence.
    211210  //delete garbagecollecor
    212211  //delete animator
    213212
    214 
     213  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
    215214}
    216215
     
    249248  this->garbageCollector = GarbageCollector::getInstance();
    250249
     250  this->particleEngine = ParticleEngine::getInstance();
    251251  this->trackManager = TrackManager::getInstance();
    252252  this->lightMan = LightManager::getInstance();
     
    256256  AnimationPlayer::getInstance(); // initializes the animationPlayer
    257257
     258  this->localCamera = new Camera();
     259  this->localCamera->setName ("camera");
    258260}
    259261
     
    264266ErrorMessage World::load()
    265267{       
    266   PRINTF0("> Loading world: '%s'\n", getPath());
    267  
     268  PRINTF(3)("> Loading world: '%s'\n", getPath());
     269  TiXmlElement* element;
    268270  GameLoader* loader = GameLoader::getInstance();
    269271 
    270272  if( getPath() == NULL)
    271273    {
    272       PRINTF0("World has no path specified for loading");
     274      PRINTF(1)("World has no path specified for loading");
    273275      return (ErrorMessage){213,"Path not specified","World::load()"};
    274276    }
     
    276278  TiXmlDocument* XMLDoc = new TiXmlDocument( path);
    277279  // load the campaign document
    278   if( !XMLDoc->LoadFile())
    279     //this->glmis->step();
    280  
     280  if( !XMLDoc->LoadFile()) 
    281281  {
    282282    // report an error
    283     PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     283    PRINTF(1)("loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    284284    delete XMLDoc;
    285285    return (ErrorMessage){213,"XML File parsing error","World::load()"};
     
    293293    {
    294294      // report an error
    295       PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
     295      PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
    296296      delete XMLDoc;
    297297      return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
     
    304304  if( string == NULL)
    305305    {
    306       PRINTF0("World is missing a proper 'name'\n");
     306      PRINTF(2)("World is missing a proper 'name'\n");
    307307      string = "Unknown";
    308308      temp = new char[strlen(string + 2)];
     
    316316      this->worldName = temp;
    317317    }
    318  
    319  
     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();
    320336  // find WorldEntities
    321   TiXmlElement* element = root->FirstChildElement( "WorldEntities");
     337  element = root->FirstChildElement("WorldEntities");
    322338 
    323339  if( element == NULL)
    324340    {
    325       PRINTF0("World is missing 'WorldEntities'\n");
     341      PRINTF(1)("World is missing 'WorldEntities'\n");
    326342    }
    327343  else
     
    329345      element = element->FirstChildElement();
    330346      // load Players/Objects/Whatever
    331       PRINTF0("Loading WorldEntities\n");
     347      PRINTF(4)("Loading WorldEntities\n");
    332348      while( element != NULL)
    333349        {
     
    337353          //todo do this more elegant
    338354          if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
    339           if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) skyBox = (SkyBox*) created;
     355          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created;
    340356          element = element->NextSiblingElement();
     357          glmis->step(); //! \todo temporary
    341358        }
    342       PRINTF0("Done loading WorldEntities\n");
     359      PRINTF(4)("Done loading WorldEntities\n");
    343360    }
    344361 
     
    360377 
    361378  // free the XML data
     379
    362380  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     }
     381  /* GENERIC LOADING PROCESS FINISHED */
    379382 
    380383  // bind input
     
    383386 
    384387  // bind camera
    385   this->localCamera = new Camera();
    386   this->localCamera->setName ("camera");
    387388  //this->localCamera->bind (localPlayer);
    388389  this->localPlayer->addChild (this->localCamera);
     
    450451
    451452     
    452   // LIGHT initialisation
    453   lightMan = LightManager::getInstance();
    454453  lightMan->setAmbientColor(.1,.1,.1);
    455454  lightMan->addLight();
     
    469468  tn->addChild(this->localCamera);
    470469  localCamera->lookAt(tn);
     470  localCamera->setMode(PNODE_MOVEMENT);
    471471  this->localPlayer->setMode(PNODE_ALL);
    472472  Vector* cameraOffset = new Vector (0, 5, -10);
    473473  trackManager->condition(2, LEFTRIGHT, this->localPlayer);
    474474 
     475  this->sky->setParent(this->localCamera);
    475476
    476477  // initialize debug coord system
     
    482483  glEndList();
    483484
    484   terrain = new Terrain("../data/worlds/newGround.obj");
     485  terrain = new Terrain("worlds/newGround.obj");
    485486  terrain->setRelCoor(Vector(0,-10,0));
    486487  this->spawn(terrain);
    487488
     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);
    488499}
    489500
     
    541552        this->glmis->step();
    542553
    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);
     554        sky = new SkyBox();
     555        //      (SkyBox*)(sky)->setTexture("pictures/sky/skybox", "jpg");
     556        sky->setParent(localCamera);
     557        this->spawn(sky);
    552558
    553559        /*monitor progress*/
     
    610616
    611617        // Create SkySphere
    612         skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    613         this->localPlayer->addChild(this->skySphere);
    614         this->spawn(this->skySphere);
     618        sky = new Skysphere("pictures/sky-replace.jpg");
     619        this->localPlayer->addChild(this->sky);
     620        this->spawn(this->sky);
    615621        Vector* es = new Vector (20, 0, 0);
    616622        Quaternion* qs = new Quaternion ();
     
    655661
    656662        // 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);
     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);
    662668        /*monitor progress*/
    663669        this->glmis->step();
     
    844850 
    845851  //GLMenuImageScreen*
    846   this->glmis = GLMenuImageScreen::getInstance();
     852  this->glmis = new GLMenuImageScreen();
    847853  this->glmis->init();
    848854  this->glmis->setMaximum(8);
    849   this->glmis->draw();
     855  //  this->glmis->draw();
    850856 
    851857  PRINTF(3)("World::displayLoadScreen - end\n");
     
    861867  PRINTF(3)("World::releaseLoadScreen - start\n");
    862868  this->glmis->setValue(this->glmis->getMaximum());
    863   //SDL_Delay(500);
    864869  PRINTF(3)("World::releaseLoadScreen - end\n");
     870  delete this->glmis;
    865871}
    866872
     
    952958
    953959  TextEngine::getInstance()->draw();
     960  particleEngine->draw(this->dtS); //!< \todo should be dts like in the Trunk;
     961
    954962  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
    955963}
     
    11191127     
    11201128      /* function to let all entities tick (iterate through list) */
    1121       float seconds = this->dt / 1000.0;     
    1122       this->gameTime += seconds;
     1129      this->dtS = (float)this->dt / 1000.0;     
     1130      this->gameTime += this->dtS;
    11231131      //entity = entities->enumerate();
    11241132      tIterator<WorldEntity>* iterator = this->entities->getIterator();
     
    11261134      while( entity != NULL)
    11271135        {
    1128           entity->tick (seconds);
     1136          entity->tick (this->dtS);
    11291137          entity = iterator->nextElement();
    11301138        }
     
    11341142      this->trackManager->tick(this->dt);
    11351143      this->localCamera->tick(this->dt);
    1136       this->garbageCollector->tick(seconds);
    1137 
    1138       AnimationPlayer::getInstance()->tick(seconds);
     1144      this->garbageCollector->tick(this->dtS);
     1145
     1146      AnimationPlayer::getInstance()->tick(this->dtS);
     1147      particleEngine->tick(this->dtS);
    11391148    }
    11401149  this->lastFrame = currentFrame;
     
    11511160{
    11521161  this->garbageCollector->update();
    1153   this->nullParent->update (dt);
     1162  this->nullParent->update (this->dtS);
    11541163}
    11551164
     
    12391248bool World::command(Command* cmd)
    12401249{
    1241   if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);
    1242   else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);
    1243   else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);
    1244   else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);
    1245   else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);
    1246   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);
    12471256
    12481257  return false;
     
    12511260void World::setPath( const char* name)
    12521261{
    1253   this->path = new char[strlen(name)+1];
    1254   strcpy(this->path, name);
     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    }
    12551274}
    12561275
Note: See TracChangeset for help on using the changeset viewer.