Changeset 6069 in orxonox.OLD for branches/network
- Timestamp:
- Dec 12, 2005, 5:18:36 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/network_world.cc
r6065 r6069 75 75 76 76 77 SHELL_COMMAND(speed, World, setSpeed);78 SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);79 SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);77 SHELL_COMMAND(speed, NetworkWorld, setSpeed); 78 SHELL_COMMAND(togglePNodeVisibility, NetworkWorld, togglePNodeVisibility); 79 SHELL_COMMAND(toggleBVVisibility, NetworkWorld, toggleBVVisibility); 80 80 81 81 using namespace std; 82 82 83 //! This creates a Factory to fabricate a World84 CREATE_FACTORY( World, CL_WORLD);85 86 World::World(const TiXmlElement* root)83 //! This creates a Factory to fabricate a NetworkWorld 84 CREATE_FACTORY(NetworkWorld, CL_WORLD); 85 86 NetworkWorld::NetworkWorld(const TiXmlElement* root) 87 87 { 88 88 this->constuctorInit("", -1); … … 93 93 94 94 /** 95 * create a new World95 * create a new NetworkWorld 96 96 97 97 This creates a new empty world! 98 98 */ 99 World::World (const char* name)99 NetworkWorld::NetworkWorld (const char* name) 100 100 { 101 101 this->path = NULL; … … 104 104 105 105 /** 106 * creates a new World...106 * creates a new NetworkWorld... 107 107 * @param worldID with this ID 108 108 */ 109 World::World (int worldID)109 NetworkWorld::NetworkWorld (int worldID) 110 110 { 111 111 this->path = NULL; … … 114 114 115 115 /** 116 * remove the World from memory116 * remove the NetworkWorld from memory 117 117 118 118 delete everything explicitly, that isn't contained in the parenting tree! 119 119 things contained in the tree are deleted automaticaly 120 120 */ 121 World::~World ()121 NetworkWorld::~NetworkWorld () 122 122 { 123 123 delete this->shell; 124 PRINTF(3)(" World::~World() - deleting current world\n");125 126 127 // here everything that is alocated by the World is deleted124 PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n"); 125 126 127 // here everything that is alocated by the NetworkWorld is deleted 128 128 delete this->entities; 129 129 State::setWorldEntityList(NULL); … … 165 165 * NO LEVEL LOADING HERE - NEVER! 166 166 */ 167 void World::constuctorInit(const char* name, int worldID)168 { 169 this->setClassID(CL_WORLD, " World");167 void NetworkWorld::constuctorInit(const char* name, int worldID) 168 { 169 this->setClassID(CL_WORLD, "NetworkWorld"); 170 170 171 171 this->setName(name); 172 this->debug WorldNr = worldID;172 this->debugNetworkWorldNr = worldID; 173 173 this->gameTime = 0.0f; 174 174 this->setSpeed(1.0); … … 184 184 185 185 /** 186 * loads the parameters of a World from an XML-element186 * loads the parameters of a NetworkWorld from an XML-element 187 187 * @param root the XML-element to load from 188 188 */ 189 void World::loadParams(const TiXmlElement* root)190 { 191 PRINTF(4)("Creating a World\n");192 193 LoadParam(root, "identifier", this, World, setStoryID)189 void NetworkWorld::loadParams(const TiXmlElement* root) 190 { 191 PRINTF(4)("Creating a NetworkWorld\n"); 192 193 LoadParam(root, "identifier", this, NetworkWorld, setStoryID) 194 194 .describe("Sets the StoryID of this world"); 195 195 196 LoadParam(root, "nextid", this, World, setNextStoryID)196 LoadParam(root, "nextid", this, NetworkWorld, setNextStoryID) 197 197 .describe("Sets the ID of the next world"); 198 198 199 LoadParam(root, "path", this, World, setPath)200 .describe("The Filename of this World (relative from the data-dir)");199 LoadParam(root, "path", this, NetworkWorld, setPath) 200 .describe("The Filename of this NetworkWorld (relative from the data-dir)"); 201 201 } 202 202 … … 207 207 * before the load and after the proceeding storyentity has finished 208 208 */ 209 ErrorMessage World::preLoad()209 ErrorMessage NetworkWorld::preLoad() 210 210 { 211 211 State::setWorldEntityList(this->entities = new tList<WorldEntity>()); … … 223 223 224 224 this->localCamera = new Camera(); 225 this->localCamera->setName (" World-Camera");225 this->localCamera->setName ("NetworkWorld-Camera"); 226 226 227 227 State::setCamera(this->localCamera, this->localCamera->getTarget()); … … 234 234 235 235 /** 236 * loads the World by initializing all resources, and set their default values.237 */ 238 ErrorMessage World::load()236 * loads the NetworkWorld by initializing all resources, and set their default values. 237 */ 238 ErrorMessage NetworkWorld::load() 239 239 { 240 240 PRINTF(3)("> Loading world: '%s'\n", getPath()); … … 244 244 if( getPath() == NULL) 245 245 { 246 PRINTF(1)(" World has no path specified for loading");247 this->loadDebug World(this->getStoryID());248 return (ErrorMessage){213,"Path not specified"," World::load()"};246 PRINTF(1)("NetworkWorld has no path specified for loading"); 247 this->loadDebugNetworkWorld(this->getStoryID()); 248 return (ErrorMessage){213,"Path not specified","NetworkWorld::load()"}; 249 249 } 250 250 … … 256 256 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 257 257 delete XMLDoc; 258 return (ErrorMessage){213,"XML File parsing error"," World::load()"};258 return (ErrorMessage){213,"XML File parsing error","NetworkWorld::load()"}; 259 259 } 260 260 … … 268 268 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 269 269 delete XMLDoc; 270 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; 271 } 270 return (ErrorMessage){213,"Path not a WorldDataFile","NetworkWorld::load()"}; 271 } 272 272 273 273 274 // load the parameters … … 283 284 this->setName(string); 284 285 } 286 285 287 286 288 //////////////// … … 303 305 this->glmis->draw(); 304 306 307 308 309 //////////////////////////// 310 // Loading Spawning Point // 311 //////////////////////////// 312 element = root->FirstChildElement("SpawningPoints"); 313 if( element == NULL) 314 { 315 PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n"); 316 } 317 else 318 { 319 element = element->FirstChildElement(); 320 // load Players/Objects/Whatever 321 PRINTF(4)("Loading Spawning Points\n"); 322 while( element != NULL) 323 { 324 BaseObject* created = Factory::fabricate(element); 325 if( created != NULL ) 326 { 327 if(created->isA(CL_WORLD_ENTITY)) 328 this->spawn(dynamic_cast<WorldEntity*>(created)); 329 printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName()); 330 } 331 332 // if we load a 'Player' we use it as localPlayer 333 334 335 //todo do this more elegant 336 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 337 sky = dynamic_cast<SkyBox*>(created); 338 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 339 { 340 terrain = dynamic_cast<Terrain*>(created); 341 CDEngine::getInstance()->setTerrain(terrain); 342 } 343 element = element->NextSiblingElement(); 344 glmis->step(); //! @todo temporary 345 } 346 PRINTF(4)("Done loading NetworkWorldEntities\n"); 347 } 348 349 305 350 //////////////////////// 306 351 // find WorldEntities // 307 352 //////////////////////// 308 309 353 element = root->FirstChildElement("WorldEntities"); 310 311 354 if( element == NULL) 312 355 { 313 PRINTF(1)(" World is missing 'WorldEntities'\n");356 PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n"); 314 357 } 315 358 else … … 317 360 element = element->FirstChildElement(); 318 361 // load Players/Objects/Whatever 319 PRINTF(4)("Loading WorldEntities\n");362 PRINTF(4)("Loading NetworkWorldEntities\n"); 320 363 while( element != NULL) 321 364 { … … 342 385 glmis->step(); //! @todo temporary 343 386 } 344 PRINTF(4)("Done loading WorldEntities\n");387 PRINTF(4)("Done loading NetworkWorldEntities\n"); 345 388 } 346 389 … … 424 467 * creates a debug world: only for experimental stuff 425 468 */ 426 void World::loadDebugWorld(int worldID)469 void NetworkWorld::loadDebugNetworkWorld(int worldID) 427 470 { 428 471 /*monitor progress*/ … … 435 478 LightManager::getInstance()->debug(); 436 479 437 switch(this->debug WorldNr)480 switch(this->debugNetworkWorldNr) 438 481 { 439 482 /* … … 491 534 492 535 /** 493 * initializes a new World shortly before start536 * initializes a new NetworkWorld shortly before start 494 537 * 495 538 * this is the function, that will be loaded shortly before the world is 496 539 * started 497 540 */ 498 ErrorMessage World::init()541 ErrorMessage NetworkWorld::init() 499 542 { 500 543 this->bPause = false; … … 508 551 509 552 /** 510 * starts the World511 */ 512 ErrorMessage World::start()513 { 514 PRINTF(3)(" World::start() - starting current World: nr %i\n", this->debugWorldNr);553 * starts the NetworkWorld 554 */ 555 ErrorMessage NetworkWorld::start() 556 { 557 PRINTF(3)("NetworkWorld::start() - starting current NetworkWorld: nr %i\n", this->debugNetworkWorldNr); 515 558 this->bQuitOrxonox = false; 516 559 this->bQuitCurrentGame = false; … … 523 566 This happens, when the player decides to end the Level. 524 567 */ 525 ErrorMessage World::stop()526 { 527 PRINTF(3)(" World::stop() - got stop signal\n");568 ErrorMessage NetworkWorld::stop() 569 { 570 PRINTF(3)("NetworkWorld::stop() - got stop signal\n"); 528 571 this->bQuitCurrentGame = true; 529 572 } … … 532 575 * pauses the Game 533 576 */ 534 ErrorMessage World::pause()577 ErrorMessage NetworkWorld::pause() 535 578 { 536 579 this->isPaused = true; … … 540 583 * ends the pause Phase 541 584 */ 542 ErrorMessage World::resume()585 ErrorMessage NetworkWorld::resume() 543 586 { 544 587 this->isPaused = false; … … 546 589 547 590 /** 548 * destroys the World549 */ 550 ErrorMessage World::destroy()591 * destroys the NetworkWorld 592 */ 593 ErrorMessage NetworkWorld::destroy() 551 594 { 552 595 … … 556 599 * shows the loading screen 557 600 */ 558 void World::displayLoadScreen ()559 { 560 PRINTF(3)(" World::displayLoadScreen - start\n");601 void NetworkWorld::displayLoadScreen () 602 { 603 PRINTF(3)("NetworkWorld::displayLoadScreen - start\n"); 561 604 562 605 //GLMenuImageScreen* … … 564 607 this->glmis->setMaximum(8); 565 608 566 PRINTF(3)(" World::displayLoadScreen - end\n");609 PRINTF(3)("NetworkWorld::displayLoadScreen - end\n"); 567 610 } 568 611 … … 572 615 @todo take out the delay 573 616 */ 574 void World::releaseLoadScreen ()575 { 576 PRINTF(3)(" World::releaseLoadScreen - start\n");617 void NetworkWorld::releaseLoadScreen () 618 { 619 PRINTF(3)("NetworkWorld::releaseLoadScreen - start\n"); 577 620 this->glmis->setValue(this->glmis->getMaximum()); 578 PRINTF(3)(" World::releaseLoadScreen - end\n");621 PRINTF(3)("NetworkWorld::releaseLoadScreen - end\n"); 579 622 delete this->glmis; 580 623 } … … 585 628 * @returns entity list 586 629 */ 587 tList<WorldEntity>* World::getEntities()630 tList<WorldEntity>* NetworkWorld::getEntities() 588 631 { 589 632 return this->entities; … … 595 638 * @returns elapsed game time 596 639 */ 597 double World::getGameTime()640 double NetworkWorld::getGameTime() 598 641 { 599 642 return this->gameTime; … … 605 648 the current class/procedure 606 649 */ 607 void World::debug()608 { 609 PRINTF(0)("Printing out the List of alive WorldEntities:\n");650 void NetworkWorld::debug() 651 { 652 PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n"); 610 653 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 611 654 WorldEntity* entity = iterator->firstElement(); … … 626 669 collisions drawing everything to the screen. 627 670 */ 628 void World::mainLoop()671 void NetworkWorld::mainLoop() 629 672 { 630 673 this->lastFrame = SDL_GetTicks (); 631 PRINTF(3)(" World::mainLoop() - Entering main loop\n");674 PRINTF(3)("NetworkWorld::mainLoop() - Entering main loop\n"); 632 675 633 676 while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */ 634 677 { 635 678 ++this->cycle; 636 PRINTF(4)(" World::mainloop() - number of entities: %i\n", this->entities->getSize());679 PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize()); 637 680 // Network 638 681 this->synchronize (); … … 651 694 } 652 695 653 PRINTF(3)(" World::mainLoop() - Exiting the main loop\n");696 PRINTF(3)("NetworkWorld::mainLoop() - Exiting the main loop\n"); 654 697 } 655 698 … … 658 701 * synchronize local data with remote data 659 702 */ 660 void World::synchronize ()703 void NetworkWorld::synchronize () 661 704 { 662 705 // Get remote input … … 672 715 sdl and has its own event-passing-queue. 673 716 */ 674 void World::handleInput ()717 void NetworkWorld::handleInput () 675 718 { 676 719 EventHandler::getInstance()->process(); … … 687 730 a heart-beat. 688 731 */ 689 void World::tick ()732 void NetworkWorld::tick () 690 733 { 691 734 Uint32 currentFrame = SDL_GetTicks(); … … 755 798 state to the whole system. 756 799 */ 757 void World::update()800 void NetworkWorld::update() 758 801 { 759 802 GarbageCollector::getInstance()->update(); … … 766 809 767 810 768 void World::collide()811 void NetworkWorld::collide() 769 812 { 770 813 CDEngine::getInstance()->checkCollisions(); … … 776 819 clear all buffers and draw the world 777 820 */ 778 void World::display ()821 void NetworkWorld::display () 779 822 { 780 823 // clear buffer … … 796 839 * runs through all entities calling their draw() methods 797 840 */ 798 void World::draw ()841 void NetworkWorld::draw () 799 842 { 800 843 /* draw entities */ … … 826 869 * @param entity to be added 827 870 */ 828 void World::spawn(WorldEntity* entity)871 void NetworkWorld::spawn(WorldEntity* entity) 829 872 { 830 873 this->entities->add (entity); … … 839 882 * @param absDir In which direction should it look. 840 883 */ 841 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)884 void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir) 842 885 { 843 886 this->entities->add (entity); … … 857 900 * @param In which relative direction should it look. 858 901 */ 859 void World::spawn(WorldEntity* entity, PNode* parentNode,902 void NetworkWorld::spawn(WorldEntity* entity, PNode* parentNode, 860 903 Vector* relCoor, Quaternion* relDir) 861 904 { … … 873 916 } 874 917 875 void World::setPath( const char* name)918 void NetworkWorld::setPath( const char* name) 876 919 { 877 920 if (this->path) … … 889 932 } 890 933 891 const char* World::getPath( void)934 const char* NetworkWorld::getPath( void) 892 935 { 893 936 return path; -
branches/network/src/story_entities/network_world.h
r6065 r6069 12 12 #include "p_node.h" 13 13 14 class World;14 class NetworkWorld; 15 15 class WorldEntity; 16 16 class Camera; … … 30 30 it is the main driving factor during gameplay. 31 31 */ 32 class World : public StoryEntity {32 class NetworkWorld : public StoryEntity { 33 33 34 34 public: 35 World (const char* name);36 World (int worldID);37 World (const TiXmlElement* root = NULL);38 virtual ~ World ();35 NetworkWorld (const char* name); 36 NetworkWorld (int worldID); 37 NetworkWorld (const TiXmlElement* root = NULL); 38 virtual ~NetworkWorld (); 39 39 40 40 void loadParams(const TiXmlElement* root); … … 52 52 virtual ErrorMessage destroy (); 53 53 54 void loadDebug World(int worldID);54 void loadDebugNetworkWorld(int worldID); 55 55 56 56 virtual void displayLoadScreen(); … … 105 105 GLMenuImageScreen* glmis; //!< The Level-Loader Display 106 106 107 int debug WorldNr; //!< The Debug Nr. needed, if something goes wrong107 int debugNetworkWorldNr; //!< The Debug Nr. needed, if something goes wrong 108 108 char* path; //!< The file from which this world is loaded 109 109 … … 114 114 Camera* localCamera; //!< The current Camera 115 115 WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted 116 Terrain* terrain; //!< The Terrain of the World.116 Terrain* terrain; //!< The Terrain of the NetworkWorld. 117 117 118 118 GLuint objectList; //!< temporary: @todo this will be ereased soon -
branches/network/src/world_entities/camera.h
r5005 r6069 8 8 9 9 #include "p_node.h" 10 #include "vector.h"11 10 #include "event_listener.h" 12 11
Note: See TracChangeset
for help on using the changeset viewer.