Changeset 3746 in orxonox.OLD for orxonox/branches/levelloader/src/story_entities
- Timestamp:
- Apr 7, 2005, 3:54:49 PM (20 years ago)
- Location:
- orxonox/branches/levelloader/src/story_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/story_entities/campaign.cc
r3557 r3746 18 18 19 19 #include "campaign.h" 20 21 #include "story_entity.h" 22 20 23 #include "world.h" 21 24 #include "camera.h" 22 #include "story_entity.h"23 25 #include "factory.h" 24 26 #include "game_loader.h" 25 27 28 #include "list.h" 29 26 30 using namespace std; 27 31 … … 30 34 Campaign::Campaign () 31 35 { 32 this->entities = new ListTemplate<StoryEntity>();36 this->entities = new tList<StoryEntity>(); 33 37 this->isInit = false; 34 38 } 39 35 40 36 41 Campaign::~Campaign () {} … … 47 52 GameLoader* loader = GameLoader::getInstance(); 48 53 49 this->entities = new ListTemplate<StoryEntity>();54 this->entities = new tList<StoryEntity>(); 50 55 this->isInit = false; 51 56 … … 106 111 { 107 112 se->displayLoadScreen(); 113 se->preLoad(); 108 114 se->load(); 109 115 se->init(); … … 232 238 if( storyID == WORLD_ID_GAMEEND) 233 239 return NULL; 234 ListTemplate<StoryEntity>* l; 240 241 /* 242 tList<StoryEntity>* l; 235 243 StoryEntity* entity = NULL; 236 244 l = this->entities->getNext(); … … 239 247 entity = l->getObject(); 240 248 l = l->getNext(); 249 241 250 int id = entity->getStoryID(); 242 251 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); … … 246 255 return entity; 247 256 } 248 } 257 258 } 259 */ 260 261 262 263 StoryEntity* entity = this->entities->enumerate(); 264 while( entity != NULL) 265 { 266 int id = entity->getStoryID(); 267 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); 268 if(id == storyID) 269 { 270 //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n"); 271 return entity; 272 } 273 entity = this->entities->nextElement(); 274 } 275 276 277 249 278 return NULL; 250 279 } -
orxonox/branches/levelloader/src/story_entities/campaign.h
r3605 r3746 8 8 9 9 class World; 10 template<class T> class tList; 10 11 11 12 class Campaign : public StoryEntity { … … 34 35 35 36 private: 36 ListTemplate<StoryEntity>* entities; 37 //ListTemplate<StoryEntity>* entities; 38 tList<StoryEntity>* entities; 37 39 bool running; 38 40 -
orxonox/branches/levelloader/src/story_entities/story_entity.cc
r3499 r3746 72 72 73 73 74 /** 75 \brief stuff that will have to be initialized before load 76 77 this gives all storyentities the possibility to init stuff before the 78 load function, where all the stuff is been made ready for start 79 */ 80 ErrorMessage StoryEntity::preLoad() 81 {} 82 83 /** 84 \brief loads the current entity 85 86 this is here to enable you loading maps into the entities. for all other actions you 87 should take the init() function. 88 load() is exec before init() 89 */ 90 ErrorMessage StoryEntity::load() 91 {} 92 93 74 94 /** 75 95 \brief initialize the entity before use. … … 78 98 After execution of this function, the Entity is ready to be played/executed, 79 99 this shifts the initialisation work before the execution - very important... 100 init() is exec shortly before start() 80 101 */ 81 102 ErrorMessage StoryEntity::init() 82 103 {} 83 104 84 85 /**86 \brief loads the current entity87 88 this is here to enable you loading maps into the entities. for all other actions you89 should take the init() function.90 */91 ErrorMessage StoryEntity::load()92 {}93 105 94 106 /** -
orxonox/branches/levelloader/src/story_entities/story_entity.h
r3525 r3746 8 8 #define _STORY_ENTITY_H 9 9 10 #include " stdincl.h"10 #include "base_object.h" 11 11 12 12 #include "story_def.h" 13 #include "error.h" 14 13 15 14 16 //! A class that represents something to play in orxonox. it is a container for worlds, movies, mission briefings, etc... … … 23 25 bool isPaused; //! is true if the entity is paused 24 26 27 virtual ErrorMessage preLoad(); 25 28 virtual ErrorMessage load(); 26 29 virtual ErrorMessage init(); -
orxonox/branches/levelloader/src/story_entities/world.cc
r3606 r3746 18 18 19 19 #include "world.h" 20 #include "world_entity.h" 21 #include "track_manager.h" 22 #include "player.h" 23 #include "command_node.h" 24 #include "camera.h" 25 #include "environment.h" 26 #include "primitive.h" 20 21 #include "orxonox.h" 22 27 23 #include "p_node.h" 28 24 #include "null_parent.h" 29 25 #include "helper_parent.h" 26 #include "track_node.h" 27 #include "world_entity.h" 28 #include "player.h" 29 #include "camera.h" 30 #include "environment.h" 31 #include "skysphere.h" 32 #include "terrain.h" 33 #include "light.h" 34 35 #include "track_manager.h" 36 #include "garbage_collector.h" 37 #include "simple_animation.h" 38 39 #include "command_node.h" 30 40 #include "glmenu_imagescreen.h" 31 #include "skysphere.h"32 #include "light.h"33 41 #include "fontset.h" 42 #include "list.h" 34 43 #include "factory.h" 35 44 #include "game_loader.h" … … 37 46 #include "terrain.h" 38 47 48 49 39 50 using namespace std; 40 51 41 52 CREATE_FACTORY(World); 53 54 WorldInterface* WorldInterface::singletonRef = 0; 55 56 57 /** 58 \brief private constructor because of singleton 59 */ 60 WorldInterface::WorldInterface() 61 { 62 this->worldIsInitialized = false; 63 this->worldReference = NULL; 64 } 65 66 /** 67 \brief public deconstructor 68 */ 69 WorldInterface::~WorldInterface() 70 { 71 this->singletonRef = NULL; 72 this->worldIsInitialized = false; 73 this->worldReference = NULL; 74 } 75 76 /** 77 \brief gets the singleton instance 78 \returns singleton instance 79 */ 80 WorldInterface* WorldInterface::getInstance() 81 { 82 if( singletonRef == NULL) 83 singletonRef = new WorldInterface(); 84 return singletonRef; 85 } 86 87 88 /** 89 \brief initializes the interface 90 \param reference to the world 91 92 if the worldinterface is not initilizes, there wont be any 93 useable interface 94 */ 95 void WorldInterface::init(World* world) 96 { 97 this->worldReference = world; 98 if( world != NULL) 99 { 100 this->worldIsInitialized = true; 101 PRINTF(3)("WorldInterface up and running\n"); 102 } 103 } 104 105 106 /** 107 \brief gets the entity list from the world 108 \return entity list 109 */ 110 tList<WorldEntity>* WorldInterface::getEntityList() 111 { 112 if( this->worldIsInitialized) 113 return this->worldReference->getEntities(); 114 PRINT(1)("Someone tried to use the WorldInterface before it has been initizlized! this can result in SEGFAULTs!\n"); 115 return NULL; 116 } 117 118 42 119 43 120 World::World( TiXmlElement* root) … … 110 187 cn->reset(); 111 188 189 ResourceManager::getInstance()->debug(); 190 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 191 ResourceManager::getInstance()->debug(); 192 193 delete WorldInterface::getInstance(); 194 112 195 delete this->nullParent; 113 196 delete this->entities; … … 116 199 if( this->worldName) delete this->worldName; 117 200 if( this->path) delete this->path; 118 } 119 120 /** 121 \brief initializes a new World 201 202 //delete garbagecollecor 203 //delete animator 204 } 205 206 /** 207 \brief initializes the world. 208 209 set all stuff here that is world generic and does not use to much memory 210 because the real init() function StoryEntity::init() will be called 211 shortly before start of the game. 212 since all worlds are initiated/referenced before they will be started. 213 NO LEVEL LOADING HERE - NEVER! 122 214 */ 123 215 void World::init(char* name, int worldID) … … 128 220 this->debugWorldNr = worldID; 129 221 this->entities = new tList<WorldEntity>(); 130 131 // Enable default GL stuff 132 glEnable(GL_DEPTH_TEST); 133 222 } 223 224 225 /** 226 \brief this is executed before load 227 228 since the load function sometimes needs data, that has been init before 229 the load and after the proceeding storyentity has finished 230 */ 231 ErrorMessage World::preLoad() 232 { 233 /* init the world interface */ 234 WorldInterface* wi = WorldInterface::getInstance(); 235 wi->init(this); 236 this->garbageCollector = GarbageCollector::getInstance(); 237 this->simpleAnimation = SimpleAnimation::getInstance(); 134 238 } 135 239 … … 153 257 // load the campaign document 154 258 if( !XMLDoc->LoadFile()) 259 this->glmis->step(); 155 260 156 261 { … … 257 362 258 363 // bind camera 259 this->localCamera = new Camera( this);364 this->localCamera = new Camera(); 260 365 this->localCamera->setName ("camera"); 261 this->localCamera->bind (localPlayer);366 //this->localCamera->bind (localPlayer); 262 367 this->localPlayer->addChild (this->localCamera); 263 368 … … 267 372 /*monitor progress*/ 268 373 // this->glmis->step(); 374 375 // LIGHT initialisation 376 lightMan = LightManager::getInstance(); 377 lightMan->setAmbientColor(.1,.1,.1); 378 lightMan->addLight(); 379 // lightMan->setAttenuation(1.0, .01, 0.0); 380 // lightMan->setDiffuseColor(1,1,1); 381 // lightMan->addLight(1); 382 // lightMan->setPosition(20, 10, -20); 383 // lightMan->setDiffuseColor(0,0,0); 384 lightMan->debug(); 385 lightMan->setPosition(-5.0, 10.0, -40.0); 386 269 387 270 388 // Create SkySphere … … 274 392 this->skySphere->setMode(PNODE_MOVEMENT); 275 393 276 /*monitor progress*/ 277 // this->glmis->step(); 278 279 // trackManager->setBindSlave(env); 394 395 // trackManager->setBindSlave(env); 396 PNode* tn = trackManager->getTrackNode(); 397 tn->addChild(this->localPlayer); 398 399 //localCamera->setParent(TrackNode::getInstance()); 400 tn->addChild(this->localCamera); 401 // localCamera->lookAt(tn); 402 this->localPlayer->setMode(PNODE_ALL); 403 //Vector* cameraOffset = new Vector (0, 5, -10); 404 //trackManager->condition(2, LEFTRIGHT, this->localPlayer); 280 405 281 406 // initialize debug coord system … … 290 415 terrain->setRelCoor(new Vector(0,-10,0)); 291 416 this->spawn(terrain); 292 293 } 294 295 /** 296 \brief initializes a new World 417 } 418 419 420 /** 421 \brief initializes a new World shortly before start 422 423 this is the function, that will be loaded shortly before the world is 424 started 297 425 */ 298 426 ErrorMessage World::init() … … 302 430 cn->addToWorld(this); 303 431 cn->enable(true); 304 305 432 PRINTF0("> Done Loading world: '%s'\n", getPath()); 306 433 } … … 363 490 this->glmis = GLMenuImageScreen::getInstance(); 364 491 this->glmis->init(); 365 this->glmis->setMaximum( 10);492 this->glmis->setMaximum(8); 366 493 this->glmis->draw(); 367 494 … … 378 505 PRINTF(3)("World::releaseLoadScreen - start\n"); 379 506 this->glmis->setValue(this->glmis->getMaximum()); 380 SDL_Delay(500);507 //SDL_Delay(500); 381 508 PRINTF(3)("World::releaseLoadScreen - end\n"); 509 } 510 511 512 /** 513 \brief gets the list of entities from the world 514 \returns entity list 515 */ 516 tList<WorldEntity>* World::getEntities() 517 { 518 return this->entities; 519 } 520 521 522 /** 523 \brief this returns the current game time 524 \returns elapsed game time 525 */ 526 double World::getGameTime() 527 { 528 return this->gameTime; 382 529 } 383 530 … … 435 582 glLoadIdentity(); 436 583 437 entity = this->entities->enumerate(); 584 //entity = this->entities->enumerate(); 585 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 586 entity = iterator->nextElement(); 438 587 while( entity != NULL ) 439 588 { 440 589 if( entity->bDraw ) entity->draw(); 441 entity = this->entities->nextElement(); 442 } 590 //entity = this->entities->nextElement(); 591 entity = iterator->nextElement(); 592 } 593 delete iterator; 443 594 444 595 glCallList (objectList); … … 477 628 p4->debug (); 478 629 479 p1->update ( );630 p1->update (0); 480 631 481 632 printf ("World::debug() - update\n"); … … 486 637 487 638 p2->shiftCoor (new Vector(-1, -1, -1)); 488 p1->update ( );639 p1->update (0); 489 640 490 641 p1->debug (); … … 496 647 497 648 498 p1->update ( );649 p1->update (0); 499 650 500 651 p1->debug (); … … 593 744 if(!this->bPause) 594 745 { 595 Uint32dt = currentFrame - this->lastFrame;746 this->dt = currentFrame - this->lastFrame; 596 747 597 if( dt > 0)748 if( this->dt > 0) 598 749 { 599 750 float fps = 1000/dt; … … 607 758 PRINTF(2)("fps = 1000 - frame rate is adjusted\n"); 608 759 SDL_Delay(10); 609 dt = 10;760 this->dt = 10; 610 761 } 611 762 //this->timeSlice (dt); 612 763 613 764 /* function to let all entities tick (iterate through list) */ 614 WorldEntity* entity; 615 float seconds = dt / 1000.0; 616 assert( this->nullParent != NULL); 617 entity = entities->enumerate(); 765 float seconds = this->dt / 1000.0; 766 this->gameTime += seconds; 767 //entity = entities->enumerate(); 768 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 769 WorldEntity* entity = iterator->nextElement(); 618 770 while( entity != NULL) 619 771 { 620 772 entity->tick (seconds); 621 entity = entities->nextElement(); 622 } 773 entity = iterator->nextElement(); 774 } 775 delete iterator; 776 //skySphere->updatePosition(localCamera->absCoordinate); 777 623 778 /* update tick the rest */ 779 this->trackManager->tick(this->dt); 624 780 assert( this->localCamera != NULL); 625 781 assert( this->trackManager != NULL); 626 this->localCamera->tick( dt);627 628 this-> trackManager->tick(dt);782 this->localCamera->tick(this->dt); 783 this->garbageCollector->tick(seconds); 784 this->simpleAnimation->tick(seconds); 629 785 } 630 786 this->lastFrame = currentFrame; … … 640 796 void World::update() 641 797 { 642 this->nullParent->update (); 798 this->garbageCollector->update(); 799 this->nullParent->update (dt); 643 800 } 644 801 … … 728 885 bool World::command(Command* cmd) 729 886 { 887 if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL); 888 else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND); 889 else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT); 890 else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT); 891 else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT); 892 else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP); 893 730 894 return false; 731 895 } -
orxonox/branches/levelloader/src/story_entities/world.h
r3605 r3746 8 8 9 9 #include "stdincl.h" 10 10 #include "comincl.h" 11 11 #include "story_entity.h" 12 12 #include "p_node.h" 13 13 14 15 class World; 16 class WorldEntity; 14 17 class TrackManager; 15 class WorldEntity;16 18 class Camera; 17 19 class PNode; … … 21 23 class FontSet; 22 24 class Terrain; 25 class GarbageCollector; 26 class SimpleAnimation; 23 27 28 //! The game world Interface 29 /** 30 this is a singleton interface, that enables world_entities to access the 31 world. for those objects, there is no easier way than over this interface! 32 */ 33 class WorldInterface : BaseObject { 34 35 public: 36 ~WorldInterface(); 37 static WorldInterface* getInstance(); 38 void init(World* world); 39 tList<WorldEntity>* getEntityList(); 40 41 private: 42 WorldInterface(); 43 static WorldInterface* singletonRef; //!< singleton reference to this object 44 bool worldIsInitialized; //!< true if the world has been initialized 45 World* worldReference; //!< this is a reference to the running world 46 47 }; 24 48 25 49 //! The game world … … 39 63 virtual ~World (); 40 64 65 double getGameTime(); 41 66 42 67 /* classes from story-entity */ 68 virtual ErrorMessage preLoad(); 43 69 virtual ErrorMessage load (); 44 70 virtual ErrorMessage init (); … … 55 81 bool command (Command* cmd); 56 82 83 tList<WorldEntity>* getEntities(); 84 57 85 /* interface to world */ 58 86 void spawn (WorldEntity* entity); … … 68 96 void init(char* name, int worldID); 69 97 70 Uint32 lastFrame; //!< last time of frame 71 bool bQuitOrxonox; //!< quit this application 72 bool bQuitCurrentGame; //!< quit only the current game and return to menu 73 bool bPause; //!< pause mode 98 Uint32 lastFrame; //!< last time of frame 99 Uint32 dt; //!< time needed to calculate this frame 100 double gameTime; //!< this is where the game time is saved 101 bool bQuitOrxonox; //!< quit this application 102 bool bQuitCurrentGame; //!< quit only the current game and return to menu 103 bool bPause; //!< pause mode 74 104 75 FontSet* testFont; //!< A test Font. \todo fix this, so it is for real.76 GLMenuImageScreen* glmis; //!< The Level-Loader Display105 FontSet* testFont; //!< A test Font. \todo fix this, so it is for real. 106 GLMenuImageScreen* glmis; //!< The Level-Loader Display 77 107 78 108 char* worldName; //!< The name of this World … … 80 110 int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong 81 111 82 PNode* nullParent; //!< The zero-point, that everything has as its parent.83 TrackManager* trackManager; //!< The reference of the TrackManager that handles the course through the Level.84 Camera* localCamera; //!< The current Camera85 Skysphere* skySphere; //!< The Environmental Heaven of orxonox \todo insert this to environment insted86 LightManager* lightMan; //!< The Lights of the Level87 Terrain* terrain; //!< The Terrain of the World.112 PNode* nullParent; //!< The zero-point, that everything has as its parent. 113 TrackManager* trackManager; //!< The reference of the TrackManager that handles the course through the Level. 114 Camera* localCamera; //!< The current Camera 115 Skysphere* skySphere; //!< The Environmental Heaven of orxonox \todo insert this to environment insted 116 LightManager* lightMan; //!< The Lights of the Level 117 Terrain* terrain; //!< The Terrain of the World. 88 118 89 GLuint objectList; //!< temporary: \todo this will be ereased soon 90 tList<WorldEntity>* entities;//!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 91 WorldEntity* localPlayer; //!< The Player, you fly through the level. 119 GLuint objectList; //!< temporary: \todo this will be ereased soon 120 tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 121 WorldEntity* localPlayer; //!< The Player, you fly through the level. 122 123 GarbageCollector* garbageCollector; //!< reference to the garbage collector 124 125 SimpleAnimation* simpleAnimation; //!< reference to the SimpleAnimation object 92 126 93 127 /* function for main-loop */
Note: See TracChangeset
for help on using the changeset viewer.