Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5924 in orxonox.OLD for branches/avi_play/src/story_entities


Ignore:
Timestamp:
Dec 4, 2005, 11:37:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/avi_play: merged the Trunk back into the branche avi_play again

merged with command svn merge ../trunk/ avi_play/ -r5845:HEAD
no conflicts

Location:
branches/avi_play/src/story_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/story_entities/world.cc

    r5819 r5924  
    2626#include "null_parent.h"
    2727#include "pilot_node.h"
    28 #include "track_node.h"
    2928#include "world_entity.h"
    3029#include "player.h"
     
    4039#include "shell.h"
    4140
    42 #include "track_manager.h"
    4341#include "garbage_collector.h"
    4442#include "fast_factory.h"
     
    6361#include "weapons/projectile.h"
    6462#include "event_handler.h"
    65 
    6663#include "sound_engine.h"
    6764#include "ogg_player.h"
     
    7269#include "npcs/npc_test1.h"
    7370#include "shader.h"
     71
     72#include "playable.h"
    7473
    7574SHELL_COMMAND(speed, World, setSpeed);
     
    122121  PRINTF(3)("World::~World() - deleting current world\n");
    123122
     123
    124124  // here everything that is alocated by the World is deleted
    125125  delete this->entities;
    126126  State::setWorldEntityList(NULL);
    127127
     128  delete this->localPlayer;
    128129
    129130  // delete all the initialized Engines.
    130131  FastFactory::flushAll(true);
    131132  delete LightManager::getInstance();
    132   delete TrackManager::getInstance();
    133133  delete ParticleEngine::getInstance();
    134134  delete AnimationPlayer::getInstance();
     
    142142  // erease everything that is left.
    143143  delete NullParent::getInstance();
     144
    144145  Shader::suspendShader();
    145146
     
    172173  this->shell = NULL;
    173174  this->entities = NULL;
     175  this->localPlayer = NULL;
     176  this->localCamera = NULL;
    174177
    175178  this->showPNodes = false;
     
    213216
    214217  AnimationPlayer::getInstance(); // initializes the animationPlayer
     218  ParticleEngine::getInstance();
    215219  PhysicsEngine::getInstance();
    216220
     
    242246    }
    243247
    244   TiXmlDocument* XMLDoc = new TiXmlDocument( path);
     248  TiXmlDocument* XMLDoc = new TiXmlDocument( getPath());
    245249  // load the campaign document
    246250  if( !XMLDoc->LoadFile())
    247251  {
    248252    // report an error
    249     PRINTF(1)("loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     253    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    250254    delete XMLDoc;
    251255    return (ErrorMessage){213,"XML File parsing error","World::load()"};
     
    313317      while( element != NULL)
    314318        {
    315           WorldEntity* created = dynamic_cast<WorldEntity*>( loader->fabricate( element));
    316           if( created != NULL) this->spawn( created);
     319          BaseObject* created = (loader->fabricate(element));
     320          if( created != NULL )
     321          {
     322            if(created->isA(CL_WORLD_ENTITY))
     323              this->spawn(dynamic_cast<WorldEntity*>(created));
     324            printf("Created a %s: %s\n", created->getClassName(), created->getName());
     325          }
     326
    317327          // if we load a 'Player' we use it as localPlayer
     328
     329
    318330          //todo do this more elegant
    319           if( element->Value() != NULL && !strcmp( element->Value(), "Player"))
    320           {
    321             localPlayer = (Player*) created;
    322             CDEngine::getInstance()->setPlayer(localPlayer);
    323           }
    324           if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created;
     331          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
     332            sky = dynamic_cast<SkyBox*>(created);
    325333          if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    326334          {
    327             terrain = (Terrain*) created;
     335            terrain = dynamic_cast<Terrain*>(created);
    328336            CDEngine::getInstance()->setTerrain(terrain);
    329337          }
     
    340348    LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);
    341349
    342     LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);
    343     LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
    344 
    345   // find Track
    346   element = root->FirstChildElement( "Track");
    347   if( element == NULL)
    348     {
    349       PRINTF(0)("World is missing a 'Track'\n");
    350     }
    351   else
    352     {
    353       //load track
    354       PRINTF(4)("Loading Track\n");
    355 
    356       TrackManager::getInstance()->loadParams( element);
    357       TrackManager::getInstance()->finalize();
    358     }
     350   LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);
     351//   LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
    359352
    360353  // free the XML data
     
    363356  /* GENERIC LOADING PROCESS FINISHED */
    364357
    365   // bind input
    366   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_UP);
    367   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_DOWN);
    368   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_LEFT);
    369   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_RIGHT);
    370   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1);
    371   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON);
    372   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON);
    373   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEUP);
    374   EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEDOWN);
     358
     359  // Create a Player
     360  this->localPlayer = new Player();
     361
     362  Playable* playable;
     363  const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
     364  if (playableList != NULL)
     365  {
     366    playable = dynamic_cast<Playable*>(playableList->front());
     367    this->localPlayer->setControllable(playable);
     368  }
    375369
    376370  // bind camera
    377   //this->localCamera->bind (localPlayer);
    378  // this->localPlayer->addChild (this->localCamera);
    379 
    380 
    381   //        TrackManager::getInstance()->setBindSlave(env);
    382   PNode* tn = TrackManager::getInstance()->getTrackNode();
    383   tn->addChild(this->localPlayer);
    384 
    385   //localCamera->setParent(TrackNode::getInstance());
    386   tn->addChild(this->localCamera);
    387   localCamera->lookAt(tn);
     371  playable->addChild (this->localCamera);
     372
     373//   //localCamera->setParent(TrackNode::getInstance());
     374//  tn->addChild(this->localCamera);
    388375  localCamera->setClipRegion(1, 10000.0);
    389   this->localPlayer->setParentMode(PNODE_ALL);
    390   TrackManager::getInstance()->condition(1, LEFTRIGHT, this->localPlayer);
    391 
     376  localCamera->lookAt(playable);
     377//  this->localPlayer->setParentMode(PNODE_ALL);
    392378  if (sky != NULL)
    393379  {
     
    400386  glNewList (objectList, GL_COMPILE);
    401387
    402   //TrackManager::getInstance()->drawGraph(.01);
    403   //TrackManager::getInstance()->debug(2);
    404388  glEndList();
    405389
     
    412396  ////////////
    413397
    414   Gravity* test = new Gravity();
    415 
    416   // SYSTEM TRAILING THE PLAYER
    417   // Creating a Test Particle System
    418 
    419   //new PhysicsConnection(system, gravity);
    420   //    new PhysicsConnection(this->localPlayer, gravity);
    421398
    422399//   TestEntity* testEntity = new TestEntity();
     
    424401//   testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    425402//   this->spawn(testEntity);
    426 
    427 //   TestEntity* testEntity2 = new TestEntity();
    428 //   testEntity2->setAnim(STAND);
    429 //   testEntity2->setRelCoor(Vector(2400.0, 10.0, -30.0));
    430 //   testEntity2->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    431 //   //testEntity2->setParent(this->localPlayer);
    432 //   this->spawn(testEntity2);
    433 //
    434 //   TestEntity* testEntity3 = new TestEntity();
    435 //   testEntity3->setAnim(BOOM);
    436 //   testEntity3->setRelCoor(Vector(2450.0, 10.0, -40.0));
    437 //   testEntity3->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    438 //   this->spawn(testEntity3);
    439 //
    440 //   TestEntity* testEntity4 = new TestEntity();
    441 //   testEntity4->setAnim(FLIP);
    442 //   testEntity4->setRelCoor(Vector(2500.0, 10.0, -22.0));
    443 //   testEntity4->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    444 //   this->spawn(testEntity4);
    445 //
    446 //   TestEntity* testEntity5 = new TestEntity();
    447 //   testEntity5->setAnim(WAVE);
    448 //   testEntity5->setRelCoor(Vector(2420.0, 10.0, -50.0));
    449 //   testEntity5->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    450 //   this->spawn(testEntity5);
    451 //
    452 //   TestEntity* testEntity6 = new TestEntity();
    453 //   testEntity6->setAnim(WAVE);
    454 //   testEntity6->setRelCoor(Vector(2420.0, 10.0, -20.0));
    455 //   testEntity6->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    456 //   this->spawn(testEntity6);
    457 //
    458 //   TestEntity* testEntity7 = new TestEntity();
    459 //   testEntity7->setAnim(WAVE);
    460 //   testEntity7->setRelCoor(Vector(2500.0, 10.0, -50.0));
    461 //   testEntity7->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    462 //   this->spawn(testEntity7);
    463 
    464 
    465 
    466 //  PhysicsEngine::getInstance()->debug();
    467 
    468 
    469403
    470404  for(int i = 0; i < 100; i++)
     
    476410    tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
    477411    this->spawn(tmp);
    478 
    479 
    480412  }
    481 
    482 
    483 
    484 //  ClassList::debug();
    485413
    486414  this->music = NULL;//(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);
     
    498426  this->glmis->step();
    499427  // stuff beyond this point remains to be loaded properly
    500 
    501   // initializing the TrackManager
    502   TrackManager::getInstance()->addPointV(Vector(150, -35, 5));
    503   TrackManager::getInstance()->addPointV(Vector(200,-35, 5));
    504   TrackManager::getInstance()->addPointV(Vector(250, -35, 5));
    505   TrackManager::getInstance()->addPointV(Vector(320,-33,-.55));
    506   TrackManager::getInstance()->setDuration(1);
    507   TrackManager::getInstance()->setSavePoint();
    508 
    509   TrackManager::getInstance()->addPointV(Vector(410, 0, 0));
    510   TrackManager::getInstance()->addPointV(Vector(510, 20, -10));
    511   TrackManager::getInstance()->addPointV(Vector(550, 20, -10));
    512   TrackManager::getInstance()->addPointV(Vector(570, 20, -10));
    513   TrackManager::getInstance()->setDuration(2);
    514 
    515   TrackManager::getInstance()->forkS("testFork1,testFork2");
    516   TrackManager::getInstance()->workOnS("testFork1");
    517   TrackManager::getInstance()->addPointV(Vector(640, 25, -30));
    518   TrackManager::getInstance()->addPointV(Vector(700, 40, -120));
    519   TrackManager::getInstance()->addPointV(Vector(800, 50, -150));
    520   TrackManager::getInstance()->addPointV(Vector(900, 60, -100));
    521   TrackManager::getInstance()->addPointV(Vector(900, 60, -70));
    522   TrackManager::getInstance()->addPointV(Vector(990, 65, -15));
    523   TrackManager::getInstance()->addPointV(Vector(1050, 65, -10));
    524   TrackManager::getInstance()->addPointV(Vector(1100, 65, -20));
    525   TrackManager::getInstance()->setDuration(4);
    526 
    527   TrackManager::getInstance()->workOnS("testFork2");
    528   TrackManager::getInstance()->addPointV(Vector(640, 25, 20));
    529   TrackManager::getInstance()->addPointV(Vector(670, 50, 120));
    530   TrackManager::getInstance()->addPointV(Vector(700, 70, 80));
    531   TrackManager::getInstance()->addPointV(Vector(800, 70, 65));
    532   TrackManager::getInstance()->addPointV(Vector(850, 65, 65));
    533   TrackManager::getInstance()->addPointV(Vector(920, 35, 40));
    534   TrackManager::getInstance()->addPointV(Vector(945, 40, 40));
    535   TrackManager::getInstance()->addPointV(Vector(970, 24, 40));
    536   TrackManager::getInstance()->addPointV(Vector(1000, 40, -7));
    537 
    538   TrackManager::getInstance()->setDuration(4);
    539 
    540 
    541   TrackManager::getInstance()->joinS("testFork1,testFork2");
    542 
    543   TrackManager::getInstance()->addPointV(Vector(1200, 60, -50));
    544   TrackManager::getInstance()->addPointV(Vector(1300, 50, -50));
    545   TrackManager::getInstance()->addPointV(Vector(1400, 40, -50));
    546   TrackManager::getInstance()->addPointV(Vector(1500, 40, -60));
    547   TrackManager::getInstance()->addPointV(Vector(1600, 35, -55));
    548   TrackManager::getInstance()->addPointV(Vector(1700, 45, -40));
    549   TrackManager::getInstance()->addPointV(Vector(1750, 60, -40));
    550   TrackManager::getInstance()->addPointV(Vector(1770, 80, -40));
    551   TrackManager::getInstance()->addPointV(Vector(1800, 100, -40));
    552   TrackManager::getInstance()->setDuration(10);
    553 
    554   TrackManager::getInstance()->finalize();
    555 
    556428
    557429  // LIGHT initialisation
     
    571443      {
    572444        LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0);
    573 
    574 
    575         this->localPlayer = new Player ();
    576         this->localPlayer->setName ("player");
    577         this->spawn (this->localPlayer);
    578         this->localPlayer->setRelCoor(Vector(5,0,0));
    579445        /*monitor progress*/
    580446        this->glmis->step();
    581 
    582 
    583         EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1);
    584         EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON);
    585         EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON);
    586 
    587         /*
    588         Field* testField = new Gravity();
    589         testField->setMagnitude(10);
    590         new PhysicsConnection(this->localPlayer, testField);
    591         */
    592447
    593448        // bind camera
     
    614469        this->glmis->step();
    615470
    616         this->pilotNode = new PilotNode();
    617         this->spawn(this->pilotNode);
    618         this->pilotNode->setAbsCoor(Vector(150, -35, 5));
    619         this->pilotNode->addChild(this->localPlayer);
    620         this->pilotNode->addChild(this->localCamera);
    621         this->localCamera->lookAt(this->localPlayer);
    622 
    623         EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_UP);
    624         EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_DOWN);
    625         EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_LEFT);
    626         EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_RIGHT);
    627         EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, EV_MOUSE_MOTION);
    628 
    629         /*
    630         PNode* tn = TrackManager::getInstance()->getTrackNode();
    631         tn->addChild(this->localPlayer);
    632         this->localCamera->lookAt(tn);
    633 
    634         tn->addChild(this->localCamera);
    635         this->localPlayer->setParentMode(PNODE_ALL);
    636         TrackManager::getInstance()->condition(2, LEFTRIGHT, this->localPlayer);
    637         */
    638471        this->glmis->step();
    639472        break;
     
    663496{
    664497  this->bPause = false;
    665   this->pilotNode = NULL;
    666498
    667499  /* update the object position before game start - so there are no wrong coordinates used in the first processing */
     
    838670void World::handleInput ()
    839671{
    840   // localinput
    841   //CommandNode* cn = Orxonox::getInstance()->getLocalInput();
    842   //cn->process();
    843 
    844672  EventHandler::getInstance()->process();
    845673
     
    893721
    894722      /* update tick the rest */
    895       TrackManager::getInstance()->tick(this->dtS);
    896723      this->localCamera->tick(this->dtS);
    897724      // tick the engines
  • branches/avi_play/src/story_entities/world.h

    r5429 r5924  
    1616class Camera;
    1717class Player;
    18 class PNode;
    1918class GLMenuImageScreen;
    2019class Terrain;
     
    2221class Text;
    2322class TiXmlElement;
    24 class PilotNode;
    2523
    2624class Shell;
     
    121119    tList<WorldEntity>* entities;       //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
    122120    Player* localPlayer;                //!< The Player, you fly through the level.
    123     PilotNode* pilotNode;               //!< THe pilot node to fly with the mouse
    124 
    125 
    126121};
    127122
Note: See TracChangeset for help on using the changeset viewer.