- Timestamp:
- Dec 30, 2005, 2:26:12 AM (19 years ago)
- Location:
- trunk/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/network_world.cc
r6341 r6345 20 20 21 21 #include "shell_command.h" 22 22 #include "resource_manager.h" 23 23 #include "state.h" 24 24 25 25 #include "p_node.h" 26 #include "pilot_node.h"27 26 #include "world_entity.h" 28 27 #include "player.h" 29 28 #include "camera.h" 30 29 #include "environment.h" 31 #include "skysphere.h" 32 #include "skybox.h" 33 #include "satellite.h" 30 #include "terrain.h" 31 34 32 #include "test_entity.h" 35 33 #include "terrain.h" … … 91 89 92 90 /** 93 * create a new NetworkWorld94 95 This creates a new empty world!96 */97 NetworkWorld::NetworkWorld (const char* name)98 {99 this->path = NULL;100 this->constuctorInit(name, -1);101 }102 103 /**104 * creates a new NetworkWorld...105 * @param worldID with this ID106 */107 NetworkWorld::NetworkWorld (int worldID)108 {109 this->path = NULL;110 this->constuctorInit(NULL, worldID);111 }112 113 /**114 91 * remove the NetworkWorld from memory 115 116 117 92 * 93 * delete everything explicitly, that isn't contained in the parenting tree! 94 * things contained in the tree are deleted automaticaly 118 95 */ 119 96 NetworkWorld::~NetworkWorld () … … 150 127 // unload the resources !! 151 128 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 152 153 delete[] this->path;154 129 } 155 130 … … 171 146 172 147 this->setName(name); 173 this->debugNetworkWorldNr = worldID;174 148 this->gameTime = 0.0f; 175 149 this->setSpeed(1.0); … … 228 202 229 203 GraphicsEngine::getInstance()->displayFPS(true); 204 this->displayLoadScreen(); 230 205 } 231 206 … … 233 208 /** 234 209 * loads the NetworkWorld by initializing all resources, and set their default values. 235 */210 */ 236 211 ErrorMessage NetworkWorld::load() 237 212 { … … 242 217 if( getPath() == NULL) 243 218 { 244 PRINTF(1)("NetworkWorld has no path specified for loading"); 245 this->loadDebugNetworkWorld(this->getStoryID()); 246 return (ErrorMessage){213,"Path not specified","NetworkWorld::load()"}; 219 PRINTF(1)("World has no path specified for loading"); 220 return (ErrorMessage){213,"Path not specified","World::load()"}; 247 221 } 248 222 … … 323 297 if( created != NULL ) 324 298 { 325 if(created->isA(CL_SPAWNING_POINT))326 this->spawn(dynamic_cast<WorldEntity*>(created));299 // if(created->isA(CL_SPAWNING_POINT)) 300 // this->spawn(dynamic_cast<WorldEntity*>(created)); 327 301 printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName()); 328 302 } … … 357 331 if( created != NULL ) 358 332 { 359 if(created->isA(CL_WORLD_ENTITY))360 this->spawn(dynamic_cast<WorldEntity*>(created));333 // if(created->isA(CL_WORLD_ENTITY)) 334 // this->spawn(dynamic_cast<WorldEntity*>(created)); 361 335 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 362 336 } … … 369 343 //todo do this more elegant 370 344 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 371 sky = dynamic_cast< SkyBox*>(created);345 sky = dynamic_cast<WorldEntity*>(created); 372 346 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 373 347 { 374 348 terrain = dynamic_cast<Terrain*>(created); 375 349 CDEngine::getInstance()->setTerrain(terrain); 350 376 351 } 377 352 … … 382 357 if( created != NULL ) 383 358 { 384 if(created->isA(CL_WORLD_ENTITY))385 this->spawn(dynamic_cast<WorldEntity*>(created));359 // if(created->isA(CL_WORLD_ENTITY)) 360 // this->spawn(dynamic_cast<WorldEntity*>(created)); 386 361 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 387 362 } … … 394 369 //todo do this more elegant 395 370 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 396 sky = dynamic_cast< SkyBox*>(created);371 sky = dynamic_cast<WorldEntity*>(created); 397 372 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 398 373 { … … 434 409 } 435 410 436 // bind camera437 playable->addChild (this->localCamera);438 411 439 412 // //localCamera->setParent(TrackNode::getInstance()); 440 413 // tn->addChild(this->localCamera); 441 414 localCamera->setClipRegion(1, 10000.0); 442 localCamera->lookAt(playable);415 // localCamera->lookAt(playable); 443 416 // this->localPlayer->setParentMode(PNODE_ALL); 444 if (sky != NULL) 445 { 446 this->sky->setParent(this->localCamera); 447 this->sky->setParentMode(PNODE_MOVEMENT); 448 } 449 450 // initialize debug coord system 451 objectList = glGenLists(1); 452 glNewList (objectList, GL_COMPILE); 453 454 glEndList(); 455 417 if (this->sky != NULL) 418 { 419 this->localCamera->addChild(sky); 420 } 456 421 SoundEngine::getInstance()->setListener(this->localCamera); 457 422 … … 483 448 } 484 449 485 486 487 /** 488 * creates a debug world: only for experimental stuff 489 */ 490 void NetworkWorld::loadDebugNetworkWorld(int worldID) 450 ErrorMessage NetworkWorld::postLoad() 491 451 { 492 452 /*monitor progress*/ … … 499 459 LightManager::getInstance()->debug(); 500 460 501 switch(this->debugNetworkWorldNr) 502 { 503 /* 504 this loads the hard-coded debug world. this only for simplicity and will be 505 removed by a reald world-loader, which interprets a world-file. 506 if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and 507 make whatever you want... 508 */ 509 case DEBUG_WORLD_0: 510 { 511 LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0); 512 /*monitor progress*/ 513 this->glmis->step(); 514 515 // bind camera 516 this->localCamera = new Camera(); 517 this->localCamera->setName ("camera"); 518 /*monitor progress*/ 519 this->glmis->step(); 520 521 522 // Create SkySphere 523 this->sky = new Skysphere("pictures/sky-replace.jpg"); 524 this->sky->setName("SkySphere"); 525 this->spawn(this->sky); 526 this->localCamera->addChild(this->sky); 527 this->sky->setParentMode(PNODE_MOVEMENT); 528 /*monitor progress*/ 529 this->glmis->step(); 530 531 532 terrain = new Terrain("worlds/newGround.obj"); 533 terrain->setRelCoor(Vector(0,-10,0)); 534 this->spawn(terrain); 535 /*monitor progress*/ 536 this->glmis->step(); 537 538 this->glmis->step(); 539 break; 540 } 541 case DEBUG_WORLD_1: 542 { 543 544 break; 545 } 546 case DEBUG_WORLD_2: 547 { 548 549 break; 550 } 551 default: 552 break; 553 } 554 } 461 this->releaseLoadScreen(); 462 } 463 555 464 556 465 /** … … 560 469 * started 561 470 */ 562 ErrorMessage NetworkWorld:: init()471 ErrorMessage NetworkWorld::preStart() 563 472 { 564 473 this->bPause = false; … … 567 476 PNode::getNullParent()->updateNode (0.001f); 568 477 PNode::getNullParent()->updateNode (0.001f); 569 570 478 } 571 479 … … 573 481 /** 574 482 * starts the NetworkWorld 575 */483 */ 576 484 ErrorMessage NetworkWorld::start() 577 485 { 578 PRINTF(3)("NetworkWorld::start() - starting current NetworkWorld: nr %i\n", this->debugNetworkWorldNr); 579 this->bQuitOrxonox = false; 580 this->bQuitCurrentGame = false; 486 this->bQuitWorld = false; 581 487 this->mainLoop(); 582 488 } … … 590 496 { 591 497 PRINTF(3)("NetworkWorld::stop() - got stop signal\n"); 592 this->bQuit CurrentGame= true;498 this->bQuitWorld= true; 593 499 } 594 500 … … 632 538 633 539 /** 634 * removes the loadscreen, and changes over to the game635 636 540 * @brief removes the loadscreen, and changes over to the game 541 * 542 * @todo take out the delay 637 543 */ 638 544 void NetworkWorld::releaseLoadScreen () … … 655 561 656 562 /** 657 * function to put your own debug stuff into it. it can display informations about658 the current class/procedure659 */660 // void NetworkWorld::debug()661 // {662 // PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");663 // tIterator<WorldEntity>* iterator = this->entities->getIterator();664 // WorldEntity* entity = iterator->firstElement();665 // while( entity != NULL)666 // {667 // PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());668 // entity = iterator->nextElement();669 // }670 // delete iterator;671 // }672 673 674 /**675 563 \brief main loop of the world: executing all world relevant function 676 677 564 in this loop we synchronize (if networked), handle input events, give the heart-beat to 678 565 all other member-entities of the world (tick to player, enemies etc.), checking for … … 682 569 { 683 570 this->lastFrame = SDL_GetTicks (); 684 PRINTF(3)("NetworkWorld::mainLoop() - Entering main loop\n"); 685 686 while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */ 687 { 688 ++this->cycle; 689 // PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize()); 571 PRINTF(3)("World::mainLoop() - Entering main loop\n"); 572 573 while(!this->bQuitWorld) /* @todo implement pause */ 574 { 575 ++this->cycle; 690 576 // Network 691 577 this->synchronize (); 692 578 // Process input 693 694 if( this->bQuitCurrentGame || this->bQuitOrxonox)695 579 this->handleInput (); 580 if( this->bQuitWorld) 581 break; 696 582 // Process time 697 583 this->tick (); 698 584 // Process collision 699 585 this->collide (); 700 586 // Update the state 701 587 this->update (); 702 588 // Draw 703 704 589 this->display (); 590 } 705 591 706 592 PRINTF(3)("NetworkWorld::mainLoop() - Exiting the main loop\n"); … … 775 661 this->gameTime += this->dtS; 776 662 777 /*this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);663 this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS); 778 664 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS); 779 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS); */665 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS); 780 666 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS); 781 667 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS); … … 815 701 GraphicsEngine::getInstance()->update(this->dtS); 816 702 PNode::getNullParent()->updateNode (this->dtS); 817 818 703 SoundEngine::getInstance()->update(); 819 704 //music->update(); … … 864 749 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 865 750 751 if( unlikely( this->showBV)) // to draw the bounding boxes of the objects at level 2 for debug purp 752 { 753 CDEngine* engine = CDEngine::getInstance(); 754 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 755 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON)); 756 engine->drawBV(State::getObjectManager()->getObjectList(OM_COMMON)); 757 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_00)); 758 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01)); 759 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 760 } 761 866 762 // { 867 763 // if( entity->isVisible() ) entity->draw(); 868 764 //FIXME 869 // if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp870 765 // entity = iterator->nextElement(); 871 766 // } 872 767 873 glCallList (objectList);874 875 768 ParticleEngine::getInstance()->draw(); 876 769 … … 880 773 engine->draw(); 881 774 //TextEngine::getInstance()->draw(); 882 }883 884 /**885 * add and spawn a new entity to this world886 * @param entity to be added887 */888 void NetworkWorld::spawn(WorldEntity* entity)889 {890 // this->entities->add (entity);891 entity->postSpawn ();892 893 }894 895 896 /**897 * add and spawn a new entity to this world898 * @param entity to be added899 * @param absCoor At what coordinates to add this entity.900 * @param absDir In which direction should it look.901 */902 void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)903 {904 // this->entities->add (entity);905 906 entity->setAbsCoor (*absCoor);907 entity->setAbsDir (*absDir);908 909 entity->postSpawn ();910 }911 912 913 /**914 * add and spawn a new entity to this world915 * @param entity to be added916 * @param entity to be added to (PNode)917 * @param At what relative coordinates to add this entity.918 * @param In which relative direction should it look.919 */920 void NetworkWorld::spawn(WorldEntity* entity, PNode* parentNode,921 Vector* relCoor, Quaternion* relDir)922 {923 if( parentNode != NULL)924 {925 parentNode->addChild (entity);926 927 entity->setRelCoor (*relCoor);928 entity->setRelDir (*relDir);929 930 // this->entities->add (entity);931 932 entity->postSpawn ();933 }934 775 } 935 776 -
trunk/src/story_entities/network_world.h
r6142 r6345 7 7 #define _WORLD_H 8 8 9 #include "stdincl.h" 10 #include "comincl.h" 9 #include "sdlincl.h" 11 10 #include "story_entity.h" 12 #include "p_node.h"13 11 #include "object_manager.h" 14 12 … … 33 31 34 32 public: 35 NetworkWorld (const char* name);36 NetworkWorld (int worldID);37 33 NetworkWorld (const TiXmlElement* root = NULL); 38 34 virtual ~NetworkWorld (); … … 45 41 virtual ErrorMessage preLoad(); 46 42 virtual ErrorMessage load (); 47 virtual ErrorMessage init (); 43 virtual ErrorMessage postLoad(); 44 45 virtual ErrorMessage preStart(); 48 46 virtual ErrorMessage start (); 49 47 virtual ErrorMessage stop (); … … 52 50 virtual ErrorMessage destroy (); 53 51 54 void loadDebugNetworkWorld(int worldID); 55 56 virtual void displayLoadScreen(); 57 virtual void releaseLoadScreen(); 58 59 /* command node functions */ 60 bool command (Command* cmd); 52 void displayLoadScreen(); 53 void releaseLoadScreen(); 61 54 62 55 /* interface to world */ 63 void spawn (WorldEntity* entity); 64 void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir); 65 void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir); 56 // void spawn (WorldEntity* entity); 66 57 67 58 /** @param speed sets the speed of the Game */ … … 69 60 const char* getPath(); 70 61 void setPath( const char* name); 71 72 inline Camera* getLocalCamera() { return this->localCamera; };73 62 74 63 void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; }; … … 78 67 void constuctorInit(const char* name, int worldID); 79 68 /* function for main-loop */ 80 void mainLoop ();81 69 void synchronize (); 82 70 void handleInput (); … … 86 74 void collide (); 87 75 void draw (); 76 void mainLoop (); 77 88 78 void display (); 89 79 void debug (); 90 80 91 81 private: 92 bool showPNodes; //!< if the PNodes should be visible. 93 bool showBV; //!< if the Bounding Volumes should be visible. 82 char* path; //!< The file from which this world is loaded 83 84 // FLAGS // 85 bool bQuitWorld; //!< quit only the current game and return to menu 86 bool bPause; //!< pause mode 87 88 bool showPNodes; //!< if the PNodes should be visible. 89 bool showBV; //!< if the Bounding Volumes should be visible. 90 91 // TIMING // 94 92 Uint32 lastFrame; //!< last time of frame 95 93 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) … … 98 96 float speed; //!< how fast the game flows 99 97 double gameTime; //!< this is where the game time is saved 100 bool bQuitOrxonox; //!< quit this application101 bool bQuitCurrentGame; //!< quit only the current game and return to menu102 bool bPause; //!< pause mode103 98 104 ObjectManager objectManager; //!< The ObjectManager of this World. 99 // INTERNAL ENGINES 100 ObjectManager objectManager; //!< The ObjectManager of this World. 101 Shell* shell; 102 OggPlayer* music; 105 103 106 104 GLMenuImageScreen* glmis; //!< The Level-Loader Display 107 105 108 int debugNetworkWorldNr; //!< The Debug Nr. needed, if something goes wrong109 char* path; //!< The file from which this world is loaded110 106 111 Shell* shell; 112 OggPlayer* music; 107 // IMPORTANT ENTITIES 108 Camera* localCamera; //!< The current Camera 109 Player* localPlayer; //!< The Player, you fly through the level. 113 110 114 // IMPORTANT WORLD-ENTITIES115 Camera* localCamera; //!< The current Camera116 111 WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted 117 112 Terrain* terrain; //!< The Terrain of the NetworkWorld. 118 119 GLuint objectList; //!< temporary: @todo this will be ereased soon120 121 Player* localPlayer; //!< The Player, you fly through the level.122 113 }; 123 114
Note: See TracChangeset
for help on using the changeset viewer.