Changeset 4122 in orxonox.OLD for orxonox/branches/heightMap/src/story_entities/world.cc
- Timestamp:
- May 9, 2005, 11:29:19 AM (20 years ago)
- Location:
- orxonox/branches/heightMap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/heightMap
- Property svn:externals
-
old new 1 data http://svn.orxonox.ethz.ch/data 1
-
- Property svn:externals
-
orxonox/branches/heightMap/src/story_entities/world.cc
r4093 r4122 1 1 2 2 3 /* … … 43 44 #include "glmenu_imagescreen.h" 44 45 #include "list.h" 45 46 46 #include "game_loader.h" 47 48 #include "animation3d.h" 49 50 #include "substring.h" 47 51 48 52 using namespace std; 49 50 53 51 54 WorldInterface* WorldInterface::singletonRef = 0; … … 113 116 } 114 117 115 118 CREATE_FACTORY(World); 119 120 World::World( TiXmlElement* root) 121 { 122 this->constuctorInit("", -1); 123 this->path = NULL; 124 const char *string; 125 char *name; 126 int id; 127 128 PRINTF0("Creating a World\n"); 129 130 // identifier 131 string = grabParameter( root, "identifier"); 132 if( string == NULL || sscanf(string, "%d", &id) != 1) 133 { 134 PRINTF0("World is missing a proper 'identifier'\n"); 135 this->setStoryID( -1); 136 } 137 else setStoryID( id); 138 139 // next id 140 string = grabParameter( root, "nextid"); 141 if( string == NULL || sscanf(string, "%d", &id) != 1) 142 { 143 PRINTF0("World is missing a proper 'nextid'\n"); 144 this->setStoryID( -1); 145 } 146 else setNextStoryID( id); 147 148 149 // path 150 string = grabParameter( root, "path"); 151 if( string == NULL) 152 { 153 PRINTF0("World is missing a proper 'path'\n"); 154 this->setPath( NULL); 155 } 156 else 157 { 158 name = new char[strlen(string + 2)]; 159 strcpy( name, string); 160 this->setPath( name); 161 } 162 } 116 163 117 164 /** … … 122 169 World::World (char* name) 123 170 { 124 this->init(name, -1); 171 this->path = NULL; 172 this->constuctorInit(name, -1); 125 173 //NullParent* np = NullParent::getInstance(); 126 174 } … … 132 180 World::World (int worldID) 133 181 { 134 this->init(NULL, worldID); 182 this->path = NULL; 183 this->constuctorInit(NULL, worldID); 135 184 } 136 185 … … 177 226 NO LEVEL LOADING HERE - NEVER! 178 227 */ 179 void World:: init(char* name, int worldID)228 void World::constuctorInit(char* name, int worldID) 180 229 { 181 230 this->setClassName ("World"); 182 231 183 this->worldName = name; 232 //this->worldName = name; 233 //this->worldName = new char[strlen(name)+1]; 234 //strcpy(this->worldName, name); 184 235 this->debugWorldNr = worldID; 185 236 this->entities = new tList<WorldEntity>(); 186 AnimationPlayer::getInstance(); // initializes the animationPlayer187 237 } 188 238 … … 200 250 wi->init(this); 201 251 this->garbageCollector = GarbageCollector::getInstance(); 252 253 this->trackManager = TrackManager::getInstance(); 254 this->lightMan = LightManager::getInstance(); 255 this->nullParent = NullParent::getInstance (); 256 this->nullParent->setName ("NullParent"); 257 258 AnimationPlayer::getInstance(); // initializes the animationPlayer 259 260 this->localCamera = new Camera(); 261 this->localCamera->setName ("camera"); 202 262 } 203 263 … … 207 267 */ 208 268 ErrorMessage World::load() 209 { 210 // BezierCurve* tmpCurve = new BezierCurve(); 211 if(this->debugWorldNr != -1) 212 { 213 // initializing Font 214 this->glmis->step(); 269 { 270 PRINTF(3)("> Loading world: '%s'\n", getPath()); 271 TiXmlElement* element; 272 GameLoader* loader = GameLoader::getInstance(); 273 274 if( getPath() == NULL) 275 { 276 PRINTF(1)("World has no path specified for loading"); 277 return (ErrorMessage){213,"Path not specified","World::load()"}; 278 } 279 280 TiXmlDocument* XMLDoc = new TiXmlDocument( path); 281 // load the campaign document 282 if( !XMLDoc->LoadFile()) 283 { 284 // report an error 285 PRINTF(1)("loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 286 delete XMLDoc; 287 return (ErrorMessage){213,"XML File parsing error","World::load()"}; 288 } 289 290 // check basic validity 291 TiXmlElement* root = XMLDoc->RootElement(); 292 assert( root != NULL); 293 294 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile")) 295 { 296 // report an error 297 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 298 delete XMLDoc; 299 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; 300 } 301 302 // load the parameters 303 // name 304 char* temp; 305 const char* string = grabParameter( root, "name"); 306 if( string == NULL) 307 { 308 PRINTF(2)("World is missing a proper 'name'\n"); 309 string = "Unknown"; 310 temp = new char[strlen(string + 2)]; 311 strcpy( temp, string); 312 this->worldName = temp; 313 } 314 else 315 { 316 temp = new char[strlen(string + 2)]; 317 strcpy( temp, string); 318 this->worldName = temp; 319 } 320 //////////////// 321 // LOADSCREEN // 322 //////////////// 323 element = root->FirstChildElement("LoadScreen"); 324 if (element == NULL) 325 { 326 PRINTF(2)("no LoadScreen specified, loading default\n"); 327 328 glmis->setBackgroundImage("pictures/load_screen.jpg"); 329 this->glmis->setMaximum(8); 330 this->glmis->draw(); 331 } 332 else 333 { 334 this->glmis->load(element); 335 this->glmis->draw(); 336 } 337 this->glmis->draw(); 338 // find WorldEntities 339 element = root->FirstChildElement("WorldEntities"); 340 341 if( element == NULL) 342 { 343 PRINTF(1)("World is missing 'WorldEntities'\n"); 344 } 345 else 346 { 347 element = element->FirstChildElement(); 348 // load Players/Objects/Whatever 349 PRINTF(4)("Loading WorldEntities\n"); 350 while( element != NULL) 351 { 352 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 353 if( created != NULL) this->spawn( created); 354 // if we load a 'Player' we use it as localPlayer 355 //todo do this more elegant 356 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created; 357 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created; 358 element = element->NextSiblingElement(); 359 glmis->step(); //! \todo temporary 360 } 361 PRINTF(4)("Done loading WorldEntities\n"); 362 } 363 364 // find Track 365 /*element = root->FirstChildElement( "Track"); 366 if( element == NULL) 367 { 368 PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n"); 369 } 370 else 371 { 372 //load track 373 PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n"); 374 375 trackManager->loadTrack( element); 376 trackManager->finalize(); 377 PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n"); 378 }*/ 379 380 // free the XML data 381 382 delete XMLDoc; 383 /* GENERIC LOADING PROCESS FINISHED */ 384 385 // bind input 386 Orxonox *orx = Orxonox::getInstance (); 387 orx->getLocalInput()->bind (localPlayer); 388 389 // bind camera 390 //this->localCamera->bind (localPlayer); 391 this->localPlayer->addChild (this->localCamera); 392 393 394 // stuff beyond this point remains to be loaded properly 395 215 396 // initializing the TrackManager 216 397 this->trackManager = TrackManager::getInstance(); 217 398 //trackManager->addPoint(Vector(0,0,0)); 218 399 trackManager->addPoint(Vector(150, -35, 5)); … … 272 453 273 454 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); 455 lightMan->setAmbientColor(.1,.1,.1); 456 lightMan->addLight(); 457 // lightMan->setAttenuation(1.0, .01, 0.0); 458 // lightMan->setDiffuseColor(1,1,1); 459 // lightMan->addLight(1); 460 // lightMan->setPosition(20, 10, -20); 461 // lightMan->setDiffuseColor(0,0,0); 462 lightMan->debug(); 463 lightMan->setPosition(-5.0, 10.0, -40.0); 464 465 // trackManager->setBindSlave(env); 466 PNode* tn = trackManager->getTrackNode(); 467 tn->addChild(this->localPlayer); 468 469 //localCamera->setParent(TrackNode::getInstance()); 470 tn->addChild(this->localCamera); 471 localCamera->lookAt(tn); 472 localCamera->setMode(PNODE_MOVEMENT); 473 this->localPlayer->setMode(PNODE_ALL); 474 Vector* cameraOffset = new Vector (0, 5, -10); 475 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 476 477 this->sky->setParent(this->localCamera); 478 479 // initialize debug coord system 480 objectList = glGenLists(1); 481 glNewList (objectList, GL_COMPILE); 482 483 // trackManager->drawGraph(.01); 484 trackManager->debug(2); 485 glEndList(); 486 487 terrain = new Terrain("worlds/newGround.obj"); 488 terrain->setRelCoor(Vector(0,-10,0)); 489 this->spawn(terrain); 490 491 } 492 493 void World::loadDebugWorld(int worldID) 494 { 495 /*monitor progress*/ 496 this->glmis->step(); 497 498 // LIGHT initialisation 499 500 lightMan->setAmbientColor(.1,.1,.1); 501 lightMan->addLight(); 502 // lightMan->setAttenuation(1.0, .01, 0.0); 503 // lightMan->setDiffuseColor(1,1,1); 504 // lightMan->addLight(1); 505 // lightMan->setPosition(20, 10, -20); 506 // lightMan->setDiffuseColor(0,0,0); 507 lightMan->debug(); 508 509 switch(this->debugWorldNr) 510 { 511 /* 512 this loads the hard-coded debug world. this only for simplicity and will be 513 removed by a reald world-loader, which interprets a world-file. 514 if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and 515 make whatever you want... 516 */ 517 case DEBUG_WORLD_0: 518 { 519 lightMan->setPosition(-5.0, 10.0, -40.0); 520 521 // !\todo old track-system has to be removed 522 523 //create helper for player 524 //HelperParent* hp = new HelperParent (); 525 /* the player has to be added to this helper */ 526 527 // create a player 528 this->localPlayer = new Player (); 529 this->localPlayer->setName ("player"); 530 this->spawn (this->localPlayer); 531 /*monitor progress*/ 532 //this->glmis->step(); 533 this->glmis->step(); 534 535 // bind input 536 Orxonox *orx = Orxonox::getInstance (); 537 orx->getLocalInput()->bind (this->localPlayer); 319 538 320 321 322 539 // bind camera 540 this->localCamera = new Camera(); 541 this->localCamera->setName ("camera"); 323 542 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(); 543 /*monitor progress*/ 544 this->glmis->step(); 545 546 sky = new SkyBox(); 547 // (SkyBox*)(sky)->setTexture("pictures/sky/skybox", "jpg"); 548 sky->setParent(localCamera); 549 this->spawn(sky); 550 551 /*monitor progress*/ 552 this->glmis->step(); 339 553 340 554 341 342 343 555 WorldEntity* env = new Environment(); 556 env->setName ("env"); 557 this->spawn(env); 344 558 345 559 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 560 /* 561 Vector* es = new Vector (10, 5, 0); 562 Quaternion* qs = new Quaternion (); 563 WorldEntity* pr = new Primitive(P_CYLINDER); 564 pr->setName("primitive"); 565 this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT); 566 */ 567 568 /*monitor progress*/ 569 this->glmis->step(); 570 571 // trackManager->setBindSlave(env); 572 PNode* tn = trackManager->getTrackNode(); 573 tn->addChild(this->localPlayer); 574 this->localCamera->lookAt(tn); 575 576 //localCamera->setParent(TrackNode::getInstance()); 577 tn->addChild(this->localCamera); 578 // localCamera->lookAt(tn); 579 this->localPlayer->setMode(PNODE_ALL); 580 //Vector* cameraOffset = new Vector (0, 5, -10); 581 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 582 this->glmis->step(); 583 break; 584 } 585 case DEBUG_WORLD_1: 586 { 587 lightMan->setPosition(.0, .0, .0); 588 lightMan->setAttenuation(1.0, .01, 0.0); 589 lightMan->setSpecularColor(1,0,0); 590 this->nullParent = NullParent::getInstance (); 591 this->nullParent->setName ("NullParent"); 592 593 // create a player 594 WorldEntity* myPlayer = new Player(); 595 myPlayer->setName ("player"); 596 this->spawn(myPlayer); 597 this->localPlayer = myPlayer; 384 598 385 386 387 599 // bind input 600 Orxonox *orx = Orxonox::getInstance(); 601 orx->getLocalInput()->bind (myPlayer); 388 602 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 603 // bind camera 604 this->localCamera = new Camera (); 605 this->localCamera->setName ("camera"); 606 this->localCamera->lookAt(LightManager::getInstance()->getLight(0)); 607 this->localCamera->setParent(this->localPlayer); 608 609 // Create SkySphere 610 sky = new Skysphere("pictures/sky-replace.jpg"); 611 this->localPlayer->addChild(this->sky); 612 this->spawn(this->sky); 613 Vector* es = new Vector (20, 0, 0); 614 Quaternion* qs = new Quaternion (); 615 616 lightMan->getLight(0)->setParent(trackManager->getTrackNode()); 617 break; 618 } 619 case DEBUG_WORLD_2: 620 { 621 lightMan->setAmbientColor(.1,.1,.1); 622 lightMan->addLight(); 623 lightMan->setPosition(-5.0, 10.0, -40.0); 624 this->nullParent = NullParent::getInstance (); 625 this->nullParent->setName ("NullParent"); 626 627 // !\todo old track-system has to be removed 628 629 //create helper for player 630 //HelperParent* hp = new HelperParent (); 631 /* the player has to be added to this helper */ 632 633 // create a player 634 this->localPlayer = new Player (); 635 this->localPlayer->setName ("player"); 636 this->spawn (this->localPlayer); 637 /*monitor progress*/ 638 //this->glmis->step(); 639 this->glmis->step(); 640 641 // bind input 642 Orxonox *orx = Orxonox::getInstance (); 643 orx->getLocalInput()->bind (this->localPlayer); 430 644 431 432 433 434 435 645 // bind camera 646 this->localCamera = new Camera(); 647 this->localCamera->setName ("camera"); 648 this->localCamera->lookAt(this->localPlayer); 649 this->localCamera->setParent(this->localPlayer); 436 650 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 651 /*monitor progress*/ 652 this->glmis->step(); 653 654 // Create SkySphere 655 this->sky = new Skysphere("pictures/sky-replace.jpg"); 656 this->sky->setName("SkySphere"); 657 this->spawn(this->sky); 658 this->localCamera->addChild(this->sky); 659 this->sky->setMode(PNODE_MOVEMENT); 660 /*monitor progress*/ 661 this->glmis->step(); 662 663 664 WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2); 665 this->localPlayer->addChild(baseNode); 666 baseNode->setRelCoor(Vector(10.0, 2.0, 1.0)); 667 this->spawn(baseNode); 668 669 WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0); 670 baseNode->addChild(secondNode); 671 secondNode->setRelCoor(Vector(0.0, 0.0, 3.0)); 672 this->spawn(secondNode); 673 674 675 WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0); 676 secondNode->addChild(thirdNode); 677 thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0)); 678 this->spawn(thirdNode); 465 679 466 680 681 682 WorldEntity* c = new Environment(); 683 this->localPlayer->addChild(c); 684 c->setRelCoor(Vector(10.0, 2.0, -1.0)); 685 this->spawn(c); 686 687 467 688 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; 689 Animation3D* animation = new Animation3D(c); 690 animation->setInfinity(ANIM_INF_REPLAY); 691 692 693 animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 694 animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 695 animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 696 697 698 699 700 701 702 /* 703 KeyFrame* f1 = new KeyFrame; 704 f1->position = new Vector(-1.1, 0.0, 2.6); 705 f1->direction = new Quaternion(); 706 f1->time = 1.0; 707 f1->mode = NEG_EXP; 486 708 487 709 488 489 490 491 492 710 KeyFrame* f2 = new KeyFrame; 711 f2->position = new Vector(-2.1, 0.0, 2.6); 712 f2->direction = new Quaternion(); 713 f2->time = 0.1; 714 f2->mode = NEG_EXP; 493 715 494 495 496 497 498 716 KeyFrame* f3 = new KeyFrame; 717 f3->position = new Vector(10.0, 2.0, -1.0); 718 f3->direction = new Quaternion(); 719 f3->time = 0.2; 720 f3->mode = NEG_EXP; 499 721 500 501 502 503 504 722 KeyFrame* f4 = new KeyFrame; 723 f4->position = new Vector(10.0, 5.0, -1.0); 724 f4->direction = new Quaternion(); 725 f4->time = 1.0; 726 f4->mode = NEG_EXP; 505 727 506 728 507 729 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 547 case DEBUG_WORLD_3: 548 { 549 lightMan->setPosition(-5.0, 10.0, -40.0); 550 this->nullParent = NullParent::getInstance (); 551 this->nullParent->setName ("NullParent"); 552 553 // !\todo old track-system has to be removed 554 555 //create helper for player 556 //HelperParent* hp = new HelperParent (); 557 /* the player has to be added to this helper */ 558 559 // create a player 560 this->localPlayer = new Player (); 561 this->localPlayer->setName ("player"); 562 this->spawn (this->localPlayer); 563 /*monitor progress*/ 564 //this->glmis->step(); 565 this->glmis->step(); 566 567 // bind input 568 Orxonox *orx = Orxonox::getInstance (); 569 orx->getLocalInput()->bind (this->localPlayer); 570 571 // bind camera 572 this->localCamera = new Camera(); 573 this->localCamera->setName ("camera"); 574 575 /*monitor progress*/ 576 this->glmis->step(); 577 578 // Create SkySphere 579 skyBox = new SkyBox(); 580 skyBox->setTexture("pictures/sky/skybox", "jpg"); 581 skyBox->setParent(localCamera); 582 this->spawn(skyBox); 583 584 /*monitor progress*/ 585 this->glmis->step(); 586 587 //WorldEntity* env = new Environment(); 588 //env->setName ("env"); 589 //this->spawn(env); 590 591 /*monitor progress*/ 592 this->glmis->step(); 593 594 // trackManager->setBindSlave(env); 595 PNode* tn = trackManager->getTrackNode(); 596 tn->addChild(this->localPlayer); 597 this->localCamera->lookAt(tn); 598 599 //localCamera->setParent(TrackNode::getInstance()); 600 tn->addChild(this->localCamera); 601 // localCamera->lookAt(tn); 602 this->localPlayer->setMode(PNODE_ALL); 603 //Vector* cameraOffset = new Vector (0, 5, -10); 604 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 605 this->glmis->step(); 606 break; 607 } 608 609 610 default: 611 printf("World::load() - no world with ID %i found", this->debugWorldNr ); 612 } 613 614 } 615 else if(this->worldName != NULL) 616 { 617 618 } 619 620 // initialize debug coord system 621 objectList = glGenLists(1); 622 glNewList (objectList, GL_COMPILE); 623 624 // trackManager->drawGraph(.01); 625 trackManager->debug(2); 626 glEndList(); 627 628 //terrain = new Terrain("../data/worlds/newGround.obj"); 629 terrain = new Terrain("../data/pictures/heightmapHello.bmp",100,1); 630 terrain->setRelCoor(Vector(0,-10,0)); 631 this->spawn(terrain); 632 633 } 730 this->simpleAnimation->animatorBegin(); 731 this->simpleAnimation->selectObject(b); 732 this->simpleAnimation->setAnimationMode(SINGLE); 733 this->simpleAnimation->addKeyFrame(f1); 734 this->simpleAnimation->addKeyFrame(f2); 735 this->simpleAnimation->start(); 736 this->simpleAnimation->selectObject(c); 737 this->simpleAnimation->addKeyFrame(f3); 738 this->simpleAnimation->addKeyFrame(f4); 739 this->simpleAnimation->start(); 740 this->simpleAnimation->animatorEnd(); 741 */ 742 743 /* 744 Vector* es = new Vector (10, 5, 0); 745 Quaternion* qs = new Quaternion (); 746 WorldEntity* pr = new Primitive(P_CYLINDER); 747 pr->setName("primitive"); 748 this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT); 749 */ 750 751 /*monitor progress*/ 752 this->glmis->step(); 753 754 // trackManager->setBindSlave(env); 755 PNode* tn = trackManager->getTrackNode(); 756 tn->addChild(this->localPlayer); 757 758 //localCamera->setParent(TrackNode::getInstance()); 759 tn->addChild(this->localCamera); 760 // localCamera->lookAt(tn); 761 this->localPlayer->setMode(PNODE_ALL); 762 //Vector* cameraOffset = new Vector (0, 5, -10); 763 trackManager->condition(2, LEFTRIGHT, this->localPlayer); 764 this->glmis->step(); 765 766 break; 767 } 768 default: 769 printf("World::load() - no world with ID %i found", this->debugWorldNr ); 770 } 771 } 772 634 773 635 774 … … 703 842 704 843 //GLMenuImageScreen* 705 this->glmis = GLMenuImageScreen::getInstance();844 this->glmis = new GLMenuImageScreen(); 706 845 this->glmis->init(); 846 glmis->setBackgroundImage("pictures/load_screen.jpg"); 707 847 this->glmis->setMaximum(8); 708 this->glmis->draw();848 // this->glmis->draw(); 709 849 710 850 PRINTF(3)("World::displayLoadScreen - end\n"); … … 720 860 PRINTF(3)("World::releaseLoadScreen - start\n"); 721 861 this->glmis->setValue(this->glmis->getMaximum()); 722 //SDL_Delay(500);723 862 PRINTF(3)("World::releaseLoadScreen - end\n"); 863 delete this->glmis; 724 864 } 725 865 … … 906 1046 this->tick (); 907 1047 // Update the state 908 this->update (); 1048 this->update (); 909 1049 // Process collision 910 1050 this->collide (); … … 989 1129 } 990 1130 delete iterator; 991 //skySphere->updatePosition(localCamera->absCoordinate); 992 1131 993 1132 /* update tick the rest */ 994 1133 this->trackManager->tick(this->dt); … … 1099 1238 bool World::command(Command* cmd) 1100 1239 { 1101 if( !strcmp( cmd->cmd, "view0")) this->localCamera->setViewMode(VIEW_NORMAL);1102 else if( !strcmp( cmd->cmd, "view1")) this->localCamera->setViewMode(VIEW_BEHIND);1103 else if( !strcmp( cmd->cmd, "view2")) this->localCamera->setViewMode(VIEW_FRONT);1104 else if( !strcmp( cmd->cmd, "view3")) this->localCamera->setViewMode(VIEW_LEFT);1105 else if( !strcmp( cmd->cmd, "view4")) this->localCamera->setViewMode(VIEW_RIGHT);1106 else if( !strcmp( cmd->cmd, "view5")) this->localCamera->setViewMode(VIEW_TOP);1240 if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW0)) this->localCamera->setViewMode(VIEW_NORMAL); 1241 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW1)) this->localCamera->setViewMode(VIEW_BEHIND); 1242 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW2)) this->localCamera->setViewMode(VIEW_FRONT); 1243 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW3)) this->localCamera->setViewMode(VIEW_LEFT); 1244 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW4)) this->localCamera->setViewMode(VIEW_RIGHT); 1245 else if( !strcmp( cmd->cmd, CONFIG_NAME_VIEW5)) this->localCamera->setViewMode(VIEW_TOP); 1107 1246 1108 1247 return false; 1109 1248 } 1110 1249 1250 void World::setPath( const char* name) 1251 { 1252 if (this->path) 1253 delete this->path; 1254 if (ResourceManager::isFile(name)) 1255 { 1256 this->path = new char[strlen(name)+1]; 1257 strcpy(this->path, name); 1258 } 1259 else 1260 { 1261 this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1]; 1262 sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name); 1263 } 1264 } 1265 1266 const char* World::getPath( void) 1267 { 1268 return path; 1269 }
Note: See TracChangeset
for help on using the changeset viewer.