Changeset 4194 in orxonox.OLD for orxonox/branches/openAL/src/story_entities
- Timestamp:
- May 16, 2005, 1:33:19 PM (20 years ago)
- Location:
- orxonox/branches/openAL
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/openAL
- Property svn:externals
-
old new 1 data http://svn.orxonox.ethz.ch/data 1
-
- Property svn:externals
-
orxonox/branches/openAL/src/story_entities/campaign.cc
r3832 r4194 19 19 #include "campaign.h" 20 20 21 #include "game_loader.h" 21 22 #include "story_entity.h" 22 23 … … 34 35 this->isInit = false; 35 36 } 36 37 Campaign::Campaign ( TiXmlElement* root) 38 { 39 TiXmlElement* element; 40 const char* string; 41 int id; 42 43 PRINTF(3)("Loading Campaign...\n"); 44 45 assert( root != NULL); 46 GameLoader* loader = GameLoader::getInstance(); 47 48 this->entities = new tList<StoryEntity>(); 49 this->isInit = false; 50 51 // grab all the necessary parameters 52 string = grabParameter( root, "identifier"); 53 if( string == NULL || sscanf(string, "%d", &id) != 1) 54 { 55 PRINTF(2)("Campaign is missing a proper 'identifier'\n"); 56 this->setStoryID( -1); 57 } 58 else this->setStoryID( id); 59 60 // find WorldList 61 element = root->FirstChildElement( "WorldList"); 62 if( element == NULL) 63 { 64 PRINTF(2)("Campaign is missing a proper 'WorldList'\n"); 65 } 66 else 67 element = element->FirstChildElement(); 68 69 // load Worlds/Subcampaigns/Whatever 70 StoryEntity* lastCreated = NULL; 71 while( element != NULL) 72 { 73 printf("Campaign: Constructor: adding a world\n"); 74 StoryEntity* created = (StoryEntity*) loader->fabricate( element); 75 /* 76 if( lastCreated != NULL) 77 created->setNextStoryID( lastCreated->getStoryID()); 78 else 79 created->setNextStoryID( WORLD_ID_GAMEEND); 80 */ 81 if( created != NULL) 82 { 83 this->addEntity( created); 84 lastCreated = created; 85 } 86 element = element->NextSiblingElement(); 87 } 88 //if( lastCreated != NULL) 89 //lastCreated->setStoryID( WORLD_ID_GAMEEND); 90 } 37 91 38 92 Campaign::~Campaign () {} -
orxonox/branches/openAL/src/story_entities/campaign.h
r3608 r4194 14 14 public: 15 15 Campaign (); 16 Campaign ( TiXmlElement* root); 16 17 virtual ~Campaign (); 17 18 -
orxonox/branches/openAL/src/story_entities/world.cc
r3870 r4194 1 1 2 2 3 /* … … 39 40 #include "garbage_collector.h" 40 41 #include "animation_player.h" 42 #include "particle_engine.h" 41 43 42 44 #include "command_node.h" 43 45 #include "glmenu_imagescreen.h" 44 46 #include "list.h" 45 46 47 #include "game_loader.h" 48 49 #include "animation3d.h" 50 51 #include "substring.h" 47 52 48 53 using namespace std; 49 50 54 51 55 WorldInterface* WorldInterface::singletonRef = 0; … … 113 117 } 114 118 115 119 CREATE_FACTORY(World); 120 121 World::World( TiXmlElement* root) 122 { 123 this->constuctorInit("", -1); 124 this->path = NULL; 125 const char *string; 126 char *name; 127 int id; 128 129 PRINTF0("Creating a World\n"); 130 131 // identifier 132 string = grabParameter( root, "identifier"); 133 if( string == NULL || sscanf(string, "%d", &id) != 1) 134 { 135 PRINTF0("World is missing a proper 'identifier'\n"); 136 this->setStoryID( -1); 137 } 138 else setStoryID( id); 139 140 // next id 141 string = grabParameter( root, "nextid"); 142 if( string == NULL || sscanf(string, "%d", &id) != 1) 143 { 144 PRINTF0("World is missing a proper 'nextid'\n"); 145 this->setStoryID( -1); 146 } 147 else setNextStoryID( id); 148 149 150 // path 151 string = grabParameter( root, "path"); 152 if( string == NULL) 153 { 154 PRINTF0("World is missing a proper 'path'\n"); 155 this->setPath( NULL); 156 } 157 else 158 { 159 name = new char[strlen(string + 2)]; 160 strcpy( name, string); 161 this->setPath( name); 162 } 163 } 116 164 117 165 /** … … 122 170 World::World (char* name) 123 171 { 124 this->init(name, -1); 172 this->path = NULL; 173 this->constuctorInit(name, -1); 125 174 //NullParent* np = NullParent::getInstance(); 126 175 } … … 132 181 World::World (int worldID) 133 182 { 134 this->init(NULL, worldID); 183 this->path = NULL; 184 this->constuctorInit(NULL, worldID); 135 185 } 136 186 … … 148 198 cn->reset(); 149 199 150 ResourceManager::getInstance()->debug();151 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);152 ResourceManager::getInstance()->debug();153 154 200 delete WorldInterface::getInstance(); 155 201 … … 158 204 delete this->lightMan; 159 205 delete this->trackManager; 206 delete this->particleEngine; 160 207 TextEngine::getInstance()->flush(); 161 208 162 AnimationPlayer::getInstance()->debug();163 209 delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence. 164 210 //delete garbagecollecor 165 211 //delete animator 166 212 167 213 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 168 214 } 169 215 … … 177 223 NO LEVEL LOADING HERE - NEVER! 178 224 */ 179 void World:: init(char* name, int worldID)225 void World::constuctorInit(char* name, int worldID) 180 226 { 181 227 this->setClassName ("World"); 182 228 183 this->worldName = name; 229 //this->worldName = name; 230 //this->worldName = new char[strlen(name)+1]; 231 //strcpy(this->worldName, name); 184 232 this->debugWorldNr = worldID; 185 233 this->entities = new tList<WorldEntity>(); 186 AnimationPlayer::getInstance(); // initializes the animationPlayer187 234 } 188 235 … … 200 247 wi->init(this); 201 248 this->garbageCollector = GarbageCollector::getInstance(); 249 250 this->particleEngine = ParticleEngine::getInstance(); 251 this->trackManager = TrackManager::getInstance(); 252 this->lightMan = LightManager::getInstance(); 253 this->nullParent = NullParent::getInstance (); 254 this->nullParent->setName ("NullParent"); 255 256 AnimationPlayer::getInstance(); // initializes the animationPlayer 257 258 this->localCamera = new Camera(); 259 this->localCamera->setName ("camera"); 202 260 } 203 261 … … 207 265 */ 208 266 ErrorMessage World::load() 209 { 210 // BezierCurve* tmpCurve = new BezierCurve(); 211 if(this->debugWorldNr != -1) 212 { 213 // initializing Font 214 this->glmis->step(); 267 { 268 PRINTF(3)("> Loading world: '%s'\n", getPath()); 269 TiXmlElement* element; 270 GameLoader* loader = GameLoader::getInstance(); 271 272 if( getPath() == NULL) 273 { 274 PRINTF(1)("World has no path specified for loading"); 275 return (ErrorMessage){213,"Path not specified","World::load()"}; 276 } 277 278 TiXmlDocument* XMLDoc = new TiXmlDocument( path); 279 // load the campaign document 280 if( !XMLDoc->LoadFile()) 281 { 282 // report an error 283 PRINTF(1)("loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 284 delete XMLDoc; 285 return (ErrorMessage){213,"XML File parsing error","World::load()"}; 286 } 287 288 // check basic validity 289 TiXmlElement* root = XMLDoc->RootElement(); 290 assert( root != NULL); 291 292 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile")) 293 { 294 // report an error 295 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 296 delete XMLDoc; 297 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; 298 } 299 300 // load the parameters 301 // name 302 char* temp; 303 const char* string = grabParameter( root, "name"); 304 if( string == NULL) 305 { 306 PRINTF(2)("World is missing a proper 'name'\n"); 307 string = "Unknown"; 308 temp = new char[strlen(string + 2)]; 309 strcpy( temp, string); 310 this->worldName = temp; 311 } 312 else 313 { 314 temp = new char[strlen(string + 2)]; 315 strcpy( temp, string); 316 this->worldName = temp; 317 } 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(); 336 // find WorldEntities 337 element = root->FirstChildElement("WorldEntities"); 338 339 if( element == NULL) 340 { 341 PRINTF(1)("World is missing 'WorldEntities'\n"); 342 } 343 else 344 { 345 element = element->FirstChildElement(); 346 // load Players/Objects/Whatever 347 PRINTF(4)("Loading WorldEntities\n"); 348 while( element != NULL) 349 { 350 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 351 if( created != NULL) this->spawn( created); 352 // if we load a 'Player' we use it as localPlayer 353 //todo do this more elegant 354 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created; 355 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created; 356 element = element->NextSiblingElement(); 357 glmis->step(); //! \todo temporary 358 } 359 PRINTF(4)("Done loading WorldEntities\n"); 360 } 361 362 // find Track 363 /*element = root->FirstChildElement( "Track"); 364 if( element == NULL) 365 { 366 PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n"); 367 } 368 else 369 { 370 //load track 371 PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n"); 372 373 trackManager->loadTrack( element); 374 trackManager->finalize(); 375 PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n"); 376 }*/ 377 378 // free the XML data 379 380 delete XMLDoc; 381 /* GENERIC LOADING PROCESS FINISHED */ 382 383 // bind input 384 Orxonox *orx = Orxonox::getInstance (); 385 orx->getLocalInput()->bind (localPlayer); 386 387 // bind camera 388 //this->localCamera->bind (localPlayer); 389 this->localPlayer->addChild (this->localCamera); 390 391 392 // stuff beyond this point remains to be loaded properly 393 215 394 // initializing the TrackManager 216 395 this->trackManager = TrackManager::getInstance(); 217 396 //trackManager->addPoint(Vector(0,0,0)); 218 397 trackManager->addPoint(Vector(150, -35, 5)); … … 272 451 273 452 274 /*monitor progress*/ 275 this->glmis->step(); 276 277 // LIGHT initialisation 278 lightMan = LightManager::getInstance(); 279 lightMan->setAmbientColor(.1,.1,.1); 280 lightMan->addLight(); 281 // lightMan->setAttenuation(1.0, .01, 0.0); 282 // lightMan->setDiffuseColor(1,1,1); 283 // lightMan->addLight(1); 284 // lightMan->setPosition(20, 10, -20); 285 // lightMan->setDiffuseColor(0,0,0); 286 lightMan->debug(); 287 288 switch(this->debugWorldNr) 289 { 290 /* 291 this loads the hard-coded debug world. this only for simplicity and will be 292 removed by a reald world-loader, which interprets a world-file. 293 if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and 294 make whatever you want... 295 */ 296 case DEBUG_WORLD_0: 297 { 298 lightMan->setPosition(-5.0, 10.0, -40.0); 299 this->nullParent = NullParent::getInstance (); 300 this->nullParent->setName ("NullParent"); 301 302 // !\todo old track-system has to be removed 303 304 //create helper for player 305 //HelperParent* hp = new HelperParent (); 306 /* the player has to be added to this helper */ 307 308 // create a player 309 this->localPlayer = new Player (); 310 this->localPlayer->setName ("player"); 311 this->spawn (this->localPlayer); 312 /*monitor progress*/ 313 //this->glmis->step(); 314 this->glmis->step(); 315 316 // bind input 317 Orxonox *orx = Orxonox::getInstance (); 318 orx->getLocalInput()->bind (this->localPlayer); 453 lightMan->setAmbientColor(.1,.1,.1); 454 lightMan->addLight(); 455 // lightMan->setAttenuation(1.0, .01, 0.0); 456 // lightMan->setDiffuseColor(1,1,1); 457 // lightMan->addLight(1); 458 // lightMan->setPosition(20, 10, -20); 459 // lightMan->setDiffuseColor(0,0,0); 460 lightMan->debug(); 461 lightMan->setPosition(-5.0, 10.0, -40.0); 462 463 // trackManager->setBindSlave(env); 464 PNode* tn = trackManager->getTrackNode(); 465 tn->addChild(this->localPlayer); 466 467 //localCamera->setParent(TrackNode::getInstance()); 468 tn->addChild(this->localCamera); 469 localCamera->lookAt(tn); 470 localCamera->setMode(PNODE_MOVEMENT); 471 this->localPlayer->setMode(PNODE_ALL); 472 Vector* cameraOffset = new Vector (0, 5, -10); 473 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 474 475 this->sky->setParent(this->localCamera); 476 477 // initialize debug coord system 478 objectList = glGenLists(1); 479 glNewList (objectList, GL_COMPILE); 480 481 // trackManager->drawGraph(.01); 482 trackManager->debug(2); 483 glEndList(); 484 485 terrain = new Terrain("worlds/newGround.obj"); 486 terrain->setRelCoor(Vector(0,-10,0)); 487 this->spawn(terrain); 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); 499 } 500 501 void World::loadDebugWorld(int worldID) 502 { 503 /*monitor progress*/ 504 this->glmis->step(); 505 506 // LIGHT initialisation 507 508 lightMan->setAmbientColor(.1,.1,.1); 509 lightMan->addLight(); 510 // lightMan->setAttenuation(1.0, .01, 0.0); 511 // lightMan->setDiffuseColor(1,1,1); 512 // lightMan->addLight(1); 513 // lightMan->setPosition(20, 10, -20); 514 // lightMan->setDiffuseColor(0,0,0); 515 lightMan->debug(); 516 517 switch(this->debugWorldNr) 518 { 519 /* 520 this loads the hard-coded debug world. this only for simplicity and will be 521 removed by a reald world-loader, which interprets a world-file. 522 if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and 523 make whatever you want... 524 */ 525 case DEBUG_WORLD_0: 526 { 527 lightMan->setPosition(-5.0, 10.0, -40.0); 528 529 // !\todo old track-system has to be removed 530 531 //create helper for player 532 //HelperParent* hp = new HelperParent (); 533 /* the player has to be added to this helper */ 534 535 // create a player 536 this->localPlayer = new Player (); 537 this->localPlayer->setName ("player"); 538 this->spawn (this->localPlayer); 539 /*monitor progress*/ 540 //this->glmis->step(); 541 this->glmis->step(); 542 543 // bind input 544 Orxonox *orx = Orxonox::getInstance (); 545 orx->getLocalInput()->bind (this->localPlayer); 319 546 320 321 322 547 // bind camera 548 this->localCamera = new Camera(); 549 this->localCamera->setName ("camera"); 323 550 324 /*monitor progress*/ 325 this->glmis->step(); 326 327 // Create SkySphere 328 // this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg"); 329 // this->skySphere->setName("SkySphere"); 330 // this->localCamera->addChild(this->skySphere); 331 // this->spawn(this->skySphere); 332 skyBox = new SkyBox(); 333 skyBox->setTexture("pictures/sky/skybox", "jpg"); 334 skyBox->setParent(localCamera); 335 this->spawn(skyBox); 336 337 /*monitor progress*/ 338 this->glmis->step(); 551 /*monitor progress*/ 552 this->glmis->step(); 553 554 sky = new SkyBox(); 555 // (SkyBox*)(sky)->setTexture("pictures/sky/skybox", "jpg"); 556 sky->setParent(localCamera); 557 this->spawn(sky); 558 559 /*monitor progress*/ 560 this->glmis->step(); 339 561 340 562 341 342 343 563 WorldEntity* env = new Environment(); 564 env->setName ("env"); 565 this->spawn(env); 344 566 345 567 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 568 /* 569 Vector* es = new Vector (10, 5, 0); 570 Quaternion* qs = new Quaternion (); 571 WorldEntity* pr = new Primitive(P_CYLINDER); 572 pr->setName("primitive"); 573 this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT); 574 */ 575 576 /*monitor progress*/ 577 this->glmis->step(); 578 579 // trackManager->setBindSlave(env); 580 PNode* tn = trackManager->getTrackNode(); 581 tn->addChild(this->localPlayer); 582 this->localCamera->lookAt(tn); 583 584 //localCamera->setParent(TrackNode::getInstance()); 585 tn->addChild(this->localCamera); 586 // localCamera->lookAt(tn); 587 this->localPlayer->setMode(PNODE_ALL); 588 //Vector* cameraOffset = new Vector (0, 5, -10); 589 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 590 this->glmis->step(); 591 break; 592 } 593 case DEBUG_WORLD_1: 594 { 595 lightMan->setPosition(.0, .0, .0); 596 lightMan->setAttenuation(1.0, .01, 0.0); 597 lightMan->setSpecularColor(1,0,0); 598 this->nullParent = NullParent::getInstance (); 599 this->nullParent->setName ("NullParent"); 600 601 // create a player 602 WorldEntity* myPlayer = new Player(); 603 myPlayer->setName ("player"); 604 this->spawn(myPlayer); 605 this->localPlayer = myPlayer; 384 606 385 386 387 607 // bind input 608 Orxonox *orx = Orxonox::getInstance(); 609 orx->getLocalInput()->bind (myPlayer); 388 610 389 390 391 392 393 394 395 396 skySphere = new Skysphere("../data/pictures/sky-replace.jpg");397 this->localPlayer->addChild(this->skySphere);398 this->spawn(this->skySphere);399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 611 // bind camera 612 this->localCamera = new Camera (); 613 this->localCamera->setName ("camera"); 614 this->localCamera->lookAt(LightManager::getInstance()->getLight(0)); 615 this->localCamera->setParent(this->localPlayer); 616 617 // Create SkySphere 618 sky = new Skysphere("pictures/sky-replace.jpg"); 619 this->localPlayer->addChild(this->sky); 620 this->spawn(this->sky); 621 Vector* es = new Vector (20, 0, 0); 622 Quaternion* qs = new Quaternion (); 623 624 lightMan->getLight(0)->setParent(trackManager->getTrackNode()); 625 break; 626 } 627 case DEBUG_WORLD_2: 628 { 629 lightMan->setAmbientColor(.1,.1,.1); 630 lightMan->addLight(); 631 lightMan->setPosition(-5.0, 10.0, -40.0); 632 this->nullParent = NullParent::getInstance (); 633 this->nullParent->setName ("NullParent"); 634 635 // !\todo old track-system has to be removed 636 637 //create helper for player 638 //HelperParent* hp = new HelperParent (); 639 /* the player has to be added to this helper */ 640 641 // create a player 642 this->localPlayer = new Player (); 643 this->localPlayer->setName ("player"); 644 this->spawn (this->localPlayer); 645 /*monitor progress*/ 646 //this->glmis->step(); 647 this->glmis->step(); 648 649 // bind input 650 Orxonox *orx = Orxonox::getInstance (); 651 orx->getLocalInput()->bind (this->localPlayer); 430 652 431 432 433 434 435 653 // bind camera 654 this->localCamera = new Camera(); 655 this->localCamera->setName ("camera"); 656 this->localCamera->lookAt(this->localPlayer); 657 this->localCamera->setParent(this->localPlayer); 436 658 437 438 439 440 441 this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");442 this->skySphere->setName("SkySphere");443 this->spawn(this->skySphere);444 this->localCamera->addChild(this->skySphere);445 this->skySphere->setMode(PNODE_MOVEMENT);446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 659 /*monitor progress*/ 660 this->glmis->step(); 661 662 // Create SkySphere 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); 668 /*monitor progress*/ 669 this->glmis->step(); 670 671 672 WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2); 673 this->localPlayer->addChild(baseNode); 674 baseNode->setRelCoor(Vector(10.0, 2.0, 1.0)); 675 this->spawn(baseNode); 676 677 WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0); 678 baseNode->addChild(secondNode); 679 secondNode->setRelCoor(Vector(0.0, 0.0, 3.0)); 680 this->spawn(secondNode); 681 682 683 WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0); 684 secondNode->addChild(thirdNode); 685 thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0)); 686 this->spawn(thirdNode); 465 687 466 688 689 690 WorldEntity* c = new Environment(); 691 this->localPlayer->addChild(c); 692 c->setRelCoor(Vector(10.0, 2.0, -1.0)); 693 this->spawn(c); 694 695 467 696 468 469 WorldEntity* b = new Environment(); 470 this->localPlayer->addChild(b); 471 b->setRelCoor(Vector(10.0, 1.0, 1.0)); 472 this->spawn(b); 473 474 475 WorldEntity* c = new Environment(); 476 this->localPlayer->addChild(c); 477 c->setRelCoor(Vector(10.0, 2.0, -1.0)); 478 this->spawn(c); 479 480 /* 481 KeyFrame* f1 = new KeyFrame; 482 f1->position = new Vector(-1.1, 0.0, 2.6); 483 f1->direction = new Quaternion(); 484 f1->time = 1.0; 485 f1->mode = NEG_EXP; 697 Animation3D* animation = new Animation3D(c); 698 animation->setInfinity(ANIM_INF_REPLAY); 699 700 701 animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 702 animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 703 animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 704 705 706 707 708 709 710 /* 711 KeyFrame* f1 = new KeyFrame; 712 f1->position = new Vector(-1.1, 0.0, 2.6); 713 f1->direction = new Quaternion(); 714 f1->time = 1.0; 715 f1->mode = NEG_EXP; 486 716 487 717 488 489 490 491 492 718 KeyFrame* f2 = new KeyFrame; 719 f2->position = new Vector(-2.1, 0.0, 2.6); 720 f2->direction = new Quaternion(); 721 f2->time = 0.1; 722 f2->mode = NEG_EXP; 493 723 494 495 496 497 498 724 KeyFrame* f3 = new KeyFrame; 725 f3->position = new Vector(10.0, 2.0, -1.0); 726 f3->direction = new Quaternion(); 727 f3->time = 0.2; 728 f3->mode = NEG_EXP; 499 729 500 501 502 503 504 730 KeyFrame* f4 = new KeyFrame; 731 f4->position = new Vector(10.0, 5.0, -1.0); 732 f4->direction = new Quaternion(); 733 f4->time = 1.0; 734 f4->mode = NEG_EXP; 505 735 506 736 507 737 508 this->simpleAnimation->animatorBegin(); 509 this->simpleAnimation->selectObject(b); 510 this->simpleAnimation->setAnimationMode(SINGLE); 511 this->simpleAnimation->addKeyFrame(f1); 512 this->simpleAnimation->addKeyFrame(f2); 513 this->simpleAnimation->start(); 514 this->simpleAnimation->selectObject(c); 515 this->simpleAnimation->addKeyFrame(f3); 516 this->simpleAnimation->addKeyFrame(f4); 517 this->simpleAnimation->start(); 518 this->simpleAnimation->animatorEnd(); 519 */ 520 521 /* 522 Vector* es = new Vector (10, 5, 0); 523 Quaternion* qs = new Quaternion (); 524 WorldEntity* pr = new Primitive(P_CYLINDER); 525 pr->setName("primitive"); 526 this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT); 527 */ 528 529 /*monitor progress*/ 530 this->glmis->step(); 531 532 // trackManager->setBindSlave(env); 533 PNode* tn = trackManager->getTrackNode(); 534 tn->addChild(this->localPlayer); 535 536 //localCamera->setParent(TrackNode::getInstance()); 537 tn->addChild(this->localCamera); 538 // localCamera->lookAt(tn); 539 this->localPlayer->setMode(PNODE_ALL); 540 //Vector* cameraOffset = new Vector (0, 5, -10); 541 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 542 this->glmis->step(); 543 544 break; 545 } 546 default: 547 printf("World::load() - no world with ID %i found", this->debugWorldNr ); 548 } 549 } 550 else if(this->worldName != NULL) 551 { 552 553 } 554 555 // initialize debug coord system 556 objectList = glGenLists(1); 557 glNewList (objectList, GL_COMPILE); 558 559 // trackManager->drawGraph(.01); 560 trackManager->debug(2); 561 glEndList(); 562 563 terrain = new Terrain("../data/worlds/newGround.obj"); 564 terrain->setRelCoor(Vector(0,-10,0)); 565 this->spawn(terrain); 566 567 } 738 this->simpleAnimation->animatorBegin(); 739 this->simpleAnimation->selectObject(b); 740 this->simpleAnimation->setAnimationMode(SINGLE); 741 this->simpleAnimation->addKeyFrame(f1); 742 this->simpleAnimation->addKeyFrame(f2); 743 this->simpleAnimation->start(); 744 this->simpleAnimation->selectObject(c); 745 this->simpleAnimation->addKeyFrame(f3); 746 this->simpleAnimation->addKeyFrame(f4); 747 this->simpleAnimation->start(); 748 this->simpleAnimation->animatorEnd(); 749 */ 750 751 /* 752 Vector* es = new Vector (10, 5, 0); 753 Quaternion* qs = new Quaternion (); 754 WorldEntity* pr = new Primitive(P_CYLINDER); 755 pr->setName("primitive"); 756 this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT); 757 */ 758 759 /*monitor progress*/ 760 this->glmis->step(); 761 762 // trackManager->setBindSlave(env); 763 PNode* tn = trackManager->getTrackNode(); 764 tn->addChild(this->localPlayer); 765 766 //localCamera->setParent(TrackNode::getInstance()); 767 tn->addChild(this->localCamera); 768 // localCamera->lookAt(tn); 769 this->localPlayer->setMode(PNODE_ALL); 770 //Vector* cameraOffset = new Vector (0, 5, -10); 771 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 772 this->glmis->step(); 773 774 break; 775 } 776 default: 777 printf("World::load() - no world with ID %i found", this->debugWorldNr ); 778 } 779 } 780 568 781 569 782 … … 637 850 638 851 //GLMenuImageScreen* 639 this->glmis = GLMenuImageScreen::getInstance();852 this->glmis = new GLMenuImageScreen(); 640 853 this->glmis->init(); 641 854 this->glmis->setMaximum(8); 642 this->glmis->draw();855 // this->glmis->draw(); 643 856 644 857 PRINTF(3)("World::displayLoadScreen - end\n"); … … 654 867 PRINTF(3)("World::releaseLoadScreen - start\n"); 655 868 this->glmis->setValue(this->glmis->getMaximum()); 656 //SDL_Delay(500);657 869 PRINTF(3)("World::releaseLoadScreen - end\n"); 870 delete this->glmis; 658 871 } 659 872 … … 745 958 746 959 TextEngine::getInstance()->draw(); 960 particleEngine->draw(this->dtS); //!< \todo should be dts like in the Trunk; 961 747 962 lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes // 748 963 } … … 840 1055 this->tick (); 841 1056 // Update the state 842 this->update (); 1057 this->update (); 843 1058 // Process collision 844 1059 this->collide (); … … 912 1127 913 1128 /* function to let all entities tick (iterate through list) */ 914 float seconds =this->dt / 1000.0;915 this->gameTime += seconds;1129 this->dtS = (float)this->dt / 1000.0; 1130 this->gameTime += this->dtS; 916 1131 //entity = entities->enumerate(); 917 1132 tIterator<WorldEntity>* iterator = this->entities->getIterator(); … … 919 1134 while( entity != NULL) 920 1135 { 921 entity->tick ( seconds);1136 entity->tick (this->dtS); 922 1137 entity = iterator->nextElement(); 923 1138 } 924 1139 delete iterator; 925 //skySphere->updatePosition(localCamera->absCoordinate); 926 1140 927 1141 /* update tick the rest */ 928 1142 this->trackManager->tick(this->dt); 929 1143 this->localCamera->tick(this->dt); 930 this->garbageCollector->tick(seconds); 931 932 AnimationPlayer::getInstance()->tick(seconds); 1144 this->garbageCollector->tick(this->dtS); 1145 1146 AnimationPlayer::getInstance()->tick(this->dtS); 1147 particleEngine->tick(this->dtS); 933 1148 } 934 1149 this->lastFrame = currentFrame; … … 945 1160 { 946 1161 this->garbageCollector->update(); 947 this->nullParent->update ( dt);1162 this->nullParent->update (this->dtS); 948 1163 } 949 1164 … … 1033 1248 bool World::command(Command* cmd) 1034 1249 { 1035 if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);1036 else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);1037 else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);1038 else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);1039 else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);1040 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); 1041 1256 1042 1257 return false; 1043 1258 } 1044 1259 1260 void World::setPath( const char* name) 1261 { 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 } 1274 } 1275 1276 const char* World::getPath( void) 1277 { 1278 return path; 1279 } -
orxonox/branches/openAL/src/story_entities/world.h
r3851 r4194 11 11 #include "story_entity.h" 12 12 #include "p_node.h" 13 13 #include "xmlparser/tinyxml.h" 14 14 15 15 class World; … … 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; … … 57 56 World (char* name); 58 57 World (int worldID); 58 World (TiXmlElement* root); 59 59 virtual ~World (); 60 60 … … 70 70 virtual ErrorMessage resume (); 71 71 virtual ErrorMessage destroy (); 72 73 void loadDebugWorld(int worldID); 72 74 73 75 virtual void displayLoadScreen(); … … 85 87 int parentingMode); 86 88 89 const char* getPath(); 90 void setPath( const char* name); 87 91 88 92 private: 89 void init(char* name, int worldID);93 void constuctorInit(char* name, int worldID); 90 94 91 95 Uint32 lastFrame; //!< last time of frame 92 96 Uint32 dt; //!< time needed to calculate this frame 97 float dtS; //!< The time needed for caluculations in seconds 93 98 double gameTime; //!< this is where the game time is saved 94 99 bool bQuitOrxonox; //!< quit this application … … 100 105 char* worldName; //!< The name of this World 101 106 int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong 107 char* path; //!< The file from which this world is loaded 102 108 103 109 PNode* nullParent; //!< The zero-point, that everything has as its parent. 104 110 TrackManager* trackManager; //!< The reference of the TrackManager that handles the course through the Level. 111 ParticleEngine* particleEngine; //!< The ParticleEngine of the World. 105 112 Camera* localCamera; //!< The current Camera 106 Skysphere* skySphere; //!< The Environmental Heaven of orxonox \todo insert this to environment insted 107 SkyBox* skyBox; 113 WorldEntity* sky; //!< The Environmental Heaven of orxonox \todo insert this to environment insted 108 114 LightManager* lightMan; //!< The Lights of the Level 109 115 Terrain* terrain; //!< The Terrain of the World.
Note: See TracChangeset
for help on using the changeset viewer.