- Timestamp:
- Dec 17, 2005, 5:56:25 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/world.cc
r6142 r6150 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 34 31 #include "test_entity.h" 35 32 #include "terrain.h" … … 91 88 92 89 /** 93 * create a new World94 95 This creates a new empty world!96 */97 World::World (const char* name)98 {99 this->path = NULL;100 this->constuctorInit(name, -1);101 }102 103 /**104 * creates a new World...105 * @param worldID with this ID106 */107 World::World (int worldID)108 {109 this->path = NULL;110 this->constuctorInit(NULL, worldID);111 }112 113 /**114 90 * remove the World from memory 115 116 117 91 * 92 * delete everything explicitly, that isn't contained in the parenting tree! 93 * things contained in the tree are deleted automaticaly 118 94 */ 119 95 World::~World () … … 150 126 // unload the resources !! 151 127 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 152 153 delete[] this->path;154 128 } 155 129 … … 170 144 171 145 this->setName(name); 172 this->debugWorldNr = worldID;173 146 this->gameTime = 0.0f; 174 147 this->setSpeed(1.0); … … 232 205 /** 233 206 * loads the World by initializing all resources, and set their default values. 234 */207 */ 235 208 ErrorMessage World::load() 236 209 { … … 242 215 { 243 216 PRINTF(1)("World has no path specified for loading"); 244 this->loadDebugWorld(this->getStoryID());245 217 return (ErrorMessage){213,"Path not specified","World::load()"}; 246 218 } … … 330 302 //todo do this more elegant 331 303 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 332 sky = dynamic_cast<SkyBox*>(created);304 this->sky = dynamic_cast<WorldEntity*>(created); 333 305 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 334 306 { … … 382 354 } 383 355 384 // initialize debug coord system385 objectList = glGenLists(1);386 glNewList (objectList, GL_COMPILE);387 388 glEndList();389 390 356 SoundEngine::getInstance()->setListener(this->localCamera); 391 357 … … 418 384 419 385 420 421 /**422 * creates a debug world: only for experimental stuff423 */424 void World::loadDebugWorld(int worldID)425 {426 /*monitor progress*/427 this->glmis->step();428 // stuff beyond this point remains to be loaded properly429 430 // LIGHT initialisation431 LightManager::getInstance()->setAmbientColor(.1,.1,.1);432 // LightManager::getInstance()->addLight();433 LightManager::getInstance()->debug();434 435 switch(this->debugWorldNr)436 {437 /*438 this loads the hard-coded debug world. this only for simplicity and will be439 removed by a reald world-loader, which interprets a world-file.440 if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and441 make whatever you want...442 */443 case DEBUG_WORLD_0:444 {445 LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0);446 /*monitor progress*/447 this->glmis->step();448 449 // bind camera450 this->localCamera = new Camera();451 this->localCamera->setName ("camera");452 /*monitor progress*/453 this->glmis->step();454 455 456 // Create SkySphere457 this->sky = new Skysphere("pictures/sky-replace.jpg");458 this->sky->setName("SkySphere");459 this->spawn(this->sky);460 this->localCamera->addChild(this->sky);461 this->sky->setParentMode(PNODE_MOVEMENT);462 /*monitor progress*/463 this->glmis->step();464 465 466 terrain = new Terrain("worlds/newGround.obj");467 terrain->setRelCoor(Vector(0,-10,0));468 this->spawn(terrain);469 /*monitor progress*/470 this->glmis->step();471 472 this->glmis->step();473 break;474 }475 case DEBUG_WORLD_1:476 {477 478 break;479 }480 case DEBUG_WORLD_2:481 {482 483 break;484 }485 default:486 break;487 }488 }489 490 386 /** 491 387 * initializes a new World shortly before start … … 501 397 PNode::getNullParent()->updateNode (0.001f); 502 398 PNode::getNullParent()->updateNode (0.001f); 503 504 399 } 505 400 … … 507 402 /** 508 403 * starts the World 509 */404 */ 510 405 ErrorMessage World::start() 511 406 { 512 PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);513 407 this->bQuitOrxonox = false; 514 408 this->bQuitCurrentGame = false; … … 566 460 567 461 /** 568 * removes the loadscreen, and changes over to the game569 570 462 * @brief removes the loadscreen, and changes over to the game 463 * 464 * @todo take out the delay 571 465 */ 572 466 void World::releaseLoadScreen () … … 588 482 } 589 483 590 /**591 \brief main loop of the world: executing all world relevant function592 593 in this loop we synchronize (if networked), handle input events, give the heart-beat to594 all other member-entities of the world (tick to player, enemies etc.), checking for595 collisions drawing everything to the screen.596 */597 void World::mainLoop()598 {599 this->lastFrame = SDL_GetTicks ();600 PRINTF(3)("World::mainLoop() - Entering main loop\n");601 602 while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */603 {604 ++this->cycle;605 // Network606 this->synchronize ();607 // Process input608 this->handleInput ();609 if( this->bQuitCurrentGame || this->bQuitOrxonox)610 break;611 // Process time612 this->tick ();613 // Process collision614 this->collide ();615 // Update the state616 this->update ();617 // Draw618 this->display ();619 }620 621 PRINTF(3)("World::mainLoop() - Exiting the main loop\n");622 }623 484 624 485 … … 786 647 // } 787 648 788 glCallList (objectList);789 790 649 ParticleEngine::getInstance()->draw(); 791 650 … … 797 656 } 798 657 658 659 /** 660 * \brief main loop of the world: executing all world relevant function 661 * 662 * in this loop we synchronize (if networked), handle input events, give the heart-beat to 663 * all other member-entities of the world (tick to player, enemies etc.), checking for 664 * collisions drawing everything to the screen. 665 */ 666 void World::mainLoop() 667 { 668 this->lastFrame = SDL_GetTicks (); 669 PRINTF(3)("World::mainLoop() - Entering main loop\n"); 670 671 while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */ 672 { 673 ++this->cycle; 674 // Network 675 this->synchronize (); 676 // Process input 677 this->handleInput (); 678 if( this->bQuitCurrentGame || this->bQuitOrxonox) 679 break; 680 // Process time 681 this->tick (); 682 // Process collision 683 this->collide (); 684 // Update the state 685 this->update (); 686 // Draw 687 this->display (); 688 } 689 690 PRINTF(3)("World::mainLoop() - Exiting the main loop\n"); 691 } 692 693 694 799 695 /** 800 696 * add and spawn a new entity to this world … … 805 701 // this->entities->add (entity); 806 702 entity->postSpawn (); 807 }808 809 810 /**811 * add and spawn a new entity to this world812 * @param entity to be added813 * @param absCoor At what coordinates to add this entity.814 * @param absDir In which direction should it look.815 */816 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)817 {818 // this->entities->add (entity);819 820 entity->setAbsCoor (*absCoor);821 entity->setAbsDir (*absDir);822 823 entity->postSpawn ();824 }825 826 827 /**828 * add and spawn a new entity to this world829 * @param entity to be added830 * @param entity to be added to (PNode)831 * @param At what relative coordinates to add this entity.832 * @param In which relative direction should it look.833 */834 void World::spawn(WorldEntity* entity, PNode* parentNode,835 Vector* relCoor, Quaternion* relDir)836 {837 if( parentNode != NULL)838 {839 parentNode->addChild (entity);840 841 entity->setRelCoor (*relCoor);842 entity->setRelDir (*relDir);843 844 // this->entities->add (entity);845 846 entity->postSpawn ();847 }848 703 } 849 704 -
trunk/src/story_entities/world.h
r6142 r6150 32 32 33 33 public: 34 World (const char* name);35 World (int worldID);36 34 World (const TiXmlElement* root = NULL); 37 35 virtual ~World (); … … 51 49 virtual ErrorMessage destroy (); 52 50 53 void loadDebugWorld(int worldID);54 55 51 virtual void displayLoadScreen(); 56 52 virtual void releaseLoadScreen(); … … 61 57 /* interface to world */ 62 58 void spawn (WorldEntity* entity); 63 void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir);64 void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir);65 59 66 60 /** @param speed sets the speed of the Game */ … … 68 62 const char* getPath(); 69 63 void setPath( const char* name); 70 71 inline Camera* getLocalCamera() { return this->localCamera; };72 64 73 65 void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; }; … … 77 69 void constuctorInit(const char* name, int worldID); 78 70 /* function for main-loop */ 79 void mainLoop ();80 71 void synchronize (); 81 72 void handleInput (); … … 85 76 void collide (); 86 77 void draw (); 78 void mainLoop (); 79 87 80 void display (); 88 81 void debug (); 89 82 90 83 private: 84 char* path; //!< The file from which this world is loaded 85 91 86 bool showPNodes; //!< if the PNodes should be visible. 92 87 bool showBV; //!< if the Bounding Volumes should be visible. 88 93 89 Uint32 lastFrame; //!< last time of frame 94 90 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) … … 105 101 GLMenuImageScreen* glmis; //!< The Level-Loader Display 106 102 107 int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong108 char* path; //!< The file from which this world is loaded109 110 103 Shell* shell; 111 104 OggPlayer* music; … … 116 109 Terrain* terrain; //!< The Terrain of the World. 117 110 118 GLuint objectList; //!< temporary: @todo this will be ereased soon119 120 111 Player* localPlayer; //!< The Player, you fly through the level. 121 112 }; -
trunk/src/util/loading/game_loader.cc
r6139 r6150 151 151 case DEBUG_CAMPAIGN_0: 152 152 { 153 Campaign* debugCampaign = new Campaign(); 153 // FIXME 154 /* Campaign* debugCampaign = new Campaign(); 154 155 155 156 World* world0 = new World(DEBUG_WORLD_0); … … 166 167 167 168 this->currentCampaign = debugCampaign; 168 break; 169 break;*/ 169 170 } 170 171 } -
trunk/src/world_entities/power_ups/power_up.cc
r6148 r6150 33 33 this->sphereMaterial->setTransparency(.1); 34 34 this->sphereMaterial->setDiffuse(r, g, b); 35 36 this->toList(OM_COMMON); 35 37 } 36 38
Note: See TracChangeset
for help on using the changeset viewer.