Changeset 4217 in orxonox.OLD for orxonox/branches/movie_player/src/story_entities
- Timestamp:
- May 18, 2005, 11:27:40 AM (20 years ago)
- Location:
- orxonox/branches/movie_player/src/story_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/movie_player/src/story_entities/campaign.cc
r4010 r4217 41 41 int id; 42 42 43 PRINTF 0("Loading Campaign...\n");43 PRINTF(3)("Loading Campaign...\n"); 44 44 45 45 assert( root != NULL); … … 53 53 if( string == NULL || sscanf(string, "%d", &id) != 1) 54 54 { 55 PRINTF 0("Campaign is missing a proper 'identifier'\n");55 PRINTF(2)("Campaign is missing a proper 'identifier'\n"); 56 56 this->setStoryID( -1); 57 57 } … … 62 62 if( element == NULL) 63 63 { 64 PRINTF 0("Campaign is missing a proper 'WorldList'\n");64 PRINTF(2)("Campaign is missing a proper 'WorldList'\n"); 65 65 } 66 66 else -
orxonox/branches/movie_player/src/story_entities/world.cc
r4010 r4217 40 40 #include "garbage_collector.h" 41 41 #include "animation_player.h" 42 #include "particle_engine.h" 42 43 43 44 #include "command_node.h" … … 121 122 { 122 123 this->constuctorInit("", -1); 123 124 this->path = NULL; 124 125 const char *string; 125 126 char *name; … … 169 170 World::World (char* name) 170 171 { 172 this->path = NULL; 171 173 this->constuctorInit(name, -1); 172 174 //NullParent* np = NullParent::getInstance(); … … 179 181 World::World (int worldID) 180 182 { 183 this->path = NULL; 181 184 this->constuctorInit(NULL, worldID); 182 185 } … … 195 198 cn->reset(); 196 199 197 ResourceManager::getInstance()->debug();198 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);199 ResourceManager::getInstance()->debug();200 201 200 delete WorldInterface::getInstance(); 202 201 … … 205 204 delete this->lightMan; 206 205 delete this->trackManager; 206 delete this->particleEngine; 207 207 TextEngine::getInstance()->flush(); 208 208 209 AnimationPlayer::getInstance()->debug();210 209 delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence. 211 210 //delete garbagecollecor 212 211 //delete animator 213 212 214 213 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 215 214 } 216 215 … … 249 248 this->garbageCollector = GarbageCollector::getInstance(); 250 249 250 this->particleEngine = ParticleEngine::getInstance(); 251 251 this->trackManager = TrackManager::getInstance(); 252 252 this->lightMan = LightManager::getInstance(); … … 256 256 AnimationPlayer::getInstance(); // initializes the animationPlayer 257 257 258 this->localCamera = new Camera(); 259 this->localCamera->setName ("camera"); 258 260 } 259 261 … … 264 266 ErrorMessage World::load() 265 267 { 266 PRINTF 0("> Loading world: '%s'\n", getPath());267 268 PRINTF(3)("> Loading world: '%s'\n", getPath()); 269 TiXmlElement* element; 268 270 GameLoader* loader = GameLoader::getInstance(); 269 271 270 272 if( getPath() == NULL) 271 273 { 272 PRINTF 0("World has no path specified for loading");274 PRINTF(1)("World has no path specified for loading"); 273 275 return (ErrorMessage){213,"Path not specified","World::load()"}; 274 276 } … … 276 278 TiXmlDocument* XMLDoc = new TiXmlDocument( path); 277 279 // load the campaign document 278 if( !XMLDoc->LoadFile()) 279 //this->glmis->step(); 280 280 if( !XMLDoc->LoadFile()) 281 281 { 282 282 // report an error 283 PRINTF 0("Errorloading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());283 PRINTF(1)("loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 284 284 delete XMLDoc; 285 285 return (ErrorMessage){213,"XML File parsing error","World::load()"}; … … 293 293 { 294 294 // report an error 295 PRINTF 0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");295 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 296 296 delete XMLDoc; 297 297 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; … … 304 304 if( string == NULL) 305 305 { 306 PRINTF 0("World is missing a proper 'name'\n");306 PRINTF(2)("World is missing a proper 'name'\n"); 307 307 string = "Unknown"; 308 308 temp = new char[strlen(string + 2)]; … … 316 316 this->worldName = temp; 317 317 } 318 319 318 //////////////// 319 // LOADSCREEN // 320 //////////////// 321 element = root->FirstChildElement("LoadScreen"); 322 if (element == NULL) 323 { 324 PRINTF(2)("no LoadScreen specified, loading default\n"); 325 326 glmis->setBackgroundImage("pictures/load_screen.jpg"); 327 this->glmis->setMaximum(8); 328 this->glmis->draw(); 329 } 330 else 331 { 332 this->glmis->load(element); 333 this->glmis->draw(); 334 } 335 this->glmis->draw(); 320 336 // find WorldEntities 321 TiXmlElement* element = root->FirstChildElement("WorldEntities");337 element = root->FirstChildElement("WorldEntities"); 322 338 323 339 if( element == NULL) 324 340 { 325 PRINTF 0("World is missing 'WorldEntities'\n");341 PRINTF(1)("World is missing 'WorldEntities'\n"); 326 342 } 327 343 else … … 329 345 element = element->FirstChildElement(); 330 346 // load Players/Objects/Whatever 331 PRINTF 0("Loading WorldEntities\n");347 PRINTF(4)("Loading WorldEntities\n"); 332 348 while( element != NULL) 333 349 { … … 337 353 //todo do this more elegant 338 354 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created; 339 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky Box= (SkyBox*) created;355 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created; 340 356 element = element->NextSiblingElement(); 357 glmis->step(); //! \todo temporary 341 358 } 342 PRINTF 0("Done loading WorldEntities\n");359 PRINTF(4)("Done loading WorldEntities\n"); 343 360 } 344 361 … … 360 377 361 378 // free the XML data 379 362 380 delete XMLDoc; 363 364 // finalize world 365 // initialize Font 366 // testFont = new FontSet(); 367 // testFont->buildFont("../data/pictures/font.tga"); 368 369 // create null parent 370 this->nullParent = NullParent::getInstance (); 371 this->nullParent->setName ("NullParent"); 372 373 // finalize myPlayer 374 if( localPlayer == NULL) 375 { 376 PRINTF0("No Player specified in World '%s'\n", this->worldName); 377 return (ErrorMessage){213,"No Player defined","World::load()"}; 378 } 381 /* GENERIC LOADING PROCESS FINISHED */ 379 382 380 383 // bind input … … 383 386 384 387 // bind camera 385 this->localCamera = new Camera();386 this->localCamera->setName ("camera");387 388 //this->localCamera->bind (localPlayer); 388 389 this->localPlayer->addChild (this->localCamera); … … 450 451 451 452 452 // LIGHT initialisation453 lightMan = LightManager::getInstance();454 453 lightMan->setAmbientColor(.1,.1,.1); 455 454 lightMan->addLight(); … … 469 468 tn->addChild(this->localCamera); 470 469 localCamera->lookAt(tn); 470 localCamera->setMode(PNODE_MOVEMENT); 471 471 this->localPlayer->setMode(PNODE_ALL); 472 472 Vector* cameraOffset = new Vector (0, 5, -10); 473 473 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 474 474 475 this->sky->setParent(this->localCamera); 475 476 476 477 // initialize debug coord system … … 482 483 glEndList(); 483 484 484 terrain = new Terrain(" ../data/worlds/newGround.obj");485 terrain = new Terrain("worlds/newGround.obj"); 485 486 terrain->setRelCoor(Vector(0,-10,0)); 486 487 this->spawn(terrain); 487 488 489 490 ParticleSystem* system = new ParticleSystem(1000, PARTICLE_SPRITE); 491 system->setLifeSpan(.5); 492 system->setConserve(.99); 493 system->setRadius(2, 0, 2, 0); 494 495 ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 100, .05); 496 emitter->setParent(this->localPlayer); 497 498 particleEngine->addConnection(emitter, system); 488 499 } 489 500 … … 541 552 this->glmis->step(); 542 553 543 // Create SkySphere 544 // this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg"); 545 // this->skySphere->setName("SkySphere"); 546 // this->localCamera->addChild(this->skySphere); 547 // this->spawn(this->skySphere); 548 skyBox = new SkyBox(); 549 skyBox->setTexture("pictures/sky/skybox", "jpg"); 550 skyBox->setParent(localCamera); 551 this->spawn(skyBox); 554 sky = new SkyBox(); 555 // (SkyBox*)(sky)->setTexture("pictures/sky/skybox", "jpg"); 556 sky->setParent(localCamera); 557 this->spawn(sky); 552 558 553 559 /*monitor progress*/ … … 610 616 611 617 // Create SkySphere 612 sky Sphere = new Skysphere("../data/pictures/sky-replace.jpg");613 this->localPlayer->addChild(this->sky Sphere);614 this->spawn(this->sky Sphere);618 sky = new Skysphere("pictures/sky-replace.jpg"); 619 this->localPlayer->addChild(this->sky); 620 this->spawn(this->sky); 615 621 Vector* es = new Vector (20, 0, 0); 616 622 Quaternion* qs = new Quaternion (); … … 655 661 656 662 // Create SkySphere 657 this->sky Sphere = new Skysphere("../data/pictures/sky-replace.jpg");658 this->sky Sphere->setName("SkySphere");659 this->spawn(this->sky Sphere);660 this->localCamera->addChild(this->sky Sphere);661 this->sky Sphere->setMode(PNODE_MOVEMENT);663 this->sky = new Skysphere("pictures/sky-replace.jpg"); 664 this->sky->setName("SkySphere"); 665 this->spawn(this->sky); 666 this->localCamera->addChild(this->sky); 667 this->sky->setMode(PNODE_MOVEMENT); 662 668 /*monitor progress*/ 663 669 this->glmis->step(); … … 844 850 845 851 //GLMenuImageScreen* 846 this->glmis = GLMenuImageScreen::getInstance();852 this->glmis = new GLMenuImageScreen(); 847 853 this->glmis->init(); 848 854 this->glmis->setMaximum(8); 849 this->glmis->draw();855 // this->glmis->draw(); 850 856 851 857 PRINTF(3)("World::displayLoadScreen - end\n"); … … 861 867 PRINTF(3)("World::releaseLoadScreen - start\n"); 862 868 this->glmis->setValue(this->glmis->getMaximum()); 863 //SDL_Delay(500);864 869 PRINTF(3)("World::releaseLoadScreen - end\n"); 870 delete this->glmis; 865 871 } 866 872 … … 952 958 953 959 TextEngine::getInstance()->draw(); 960 particleEngine->draw(this->dtS); //!< \todo should be dts like in the Trunk; 961 954 962 lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes // 955 963 } … … 1119 1127 1120 1128 /* function to let all entities tick (iterate through list) */ 1121 float seconds =this->dt / 1000.0;1122 this->gameTime += seconds;1129 this->dtS = (float)this->dt / 1000.0; 1130 this->gameTime += this->dtS; 1123 1131 //entity = entities->enumerate(); 1124 1132 tIterator<WorldEntity>* iterator = this->entities->getIterator(); … … 1126 1134 while( entity != NULL) 1127 1135 { 1128 entity->tick ( seconds);1136 entity->tick (this->dtS); 1129 1137 entity = iterator->nextElement(); 1130 1138 } … … 1134 1142 this->trackManager->tick(this->dt); 1135 1143 this->localCamera->tick(this->dt); 1136 this->garbageCollector->tick(seconds); 1137 1138 AnimationPlayer::getInstance()->tick(seconds); 1144 this->garbageCollector->tick(this->dtS); 1145 1146 AnimationPlayer::getInstance()->tick(this->dtS); 1147 particleEngine->tick(this->dtS); 1139 1148 } 1140 1149 this->lastFrame = currentFrame; … … 1151 1160 { 1152 1161 this->garbageCollector->update(); 1153 this->nullParent->update ( dt);1162 this->nullParent->update (this->dtS); 1154 1163 } 1155 1164 … … 1239 1248 bool World::command(Command* cmd) 1240 1249 { 1241 if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);1242 else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);1243 else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);1244 else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);1245 else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);1246 else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);1250 if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW0)) this->localCamera->setViewMode(VIEW_NORMAL); 1251 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW1)) this->localCamera->setViewMode(VIEW_BEHIND); 1252 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW2)) this->localCamera->setViewMode(VIEW_FRONT); 1253 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW3)) this->localCamera->setViewMode(VIEW_LEFT); 1254 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW4)) this->localCamera->setViewMode(VIEW_RIGHT); 1255 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW5)) this->localCamera->setViewMode(VIEW_TOP); 1247 1256 1248 1257 return false; … … 1251 1260 void World::setPath( const char* name) 1252 1261 { 1253 this->path = new char[strlen(name)+1]; 1254 strcpy(this->path, name); 1262 if (this->path) 1263 delete this->path; 1264 if (ResourceManager::isFile(name)) 1265 { 1266 this->path = new char[strlen(name)+1]; 1267 strcpy(this->path, name); 1268 } 1269 else 1270 { 1271 this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1]; 1272 sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name); 1273 } 1255 1274 } 1256 1275 -
orxonox/branches/movie_player/src/story_entities/world.h
r4010 r4217 19 19 class PNode; 20 20 class GLMenuImageScreen; 21 class Skysphere;22 class SkyBox;23 21 class LightManager; 22 class ParticleEngine; 24 23 class Terrain; 25 24 class GarbageCollector; … … 96 95 Uint32 lastFrame; //!< last time of frame 97 96 Uint32 dt; //!< time needed to calculate this frame 97 float dtS; //!< The time needed for caluculations in seconds 98 98 double gameTime; //!< this is where the game time is saved 99 99 bool bQuitOrxonox; //!< quit this application … … 109 109 PNode* nullParent; //!< The zero-point, that everything has as its parent. 110 110 TrackManager* trackManager; //!< The reference of the TrackManager that handles the course through the Level. 111 ParticleEngine* particleEngine; //!< The ParticleEngine of the World. 111 112 Camera* localCamera; //!< The current Camera 112 Skysphere* skySphere; //!< The Environmental Heaven of orxonox \todo insert this to environment insted 113 SkyBox* skyBox; 113 WorldEntity* sky; //!< The Environmental Heaven of orxonox \todo insert this to environment insted 114 114 LightManager* lightMan; //!< The Lights of the Level 115 115 Terrain* terrain; //!< The Terrain of the World.
Note: See TracChangeset
for help on using the changeset viewer.