Changeset 5968 in orxonox.OLD for branches/network/src/story_entities
- Timestamp:
- Dec 7, 2005, 4:16:51 PM (19 years ago)
- Location:
- branches/network/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/world.cc
r5829 r5968 26 26 #include "null_parent.h" 27 27 #include "pilot_node.h" 28 #include "track_node.h"29 28 #include "world_entity.h" 30 29 #include "player.h" … … 40 39 #include "shell.h" 41 40 42 #include "track_manager.h"43 41 #include "garbage_collector.h" 44 42 #include "fast_factory.h" … … 63 61 #include "weapons/projectile.h" 64 62 #include "event_handler.h" 65 66 63 #include "sound_engine.h" 67 64 #include "ogg_player.h" … … 74 71 75 72 #include "network_manager.h" 73 #include "playable.h" 74 76 75 77 76 SHELL_COMMAND(speed, World, setSpeed); … … 124 123 PRINTF(3)("World::~World() - deleting current world\n"); 125 124 125 126 126 // here everything that is alocated by the World is deleted 127 127 delete this->entities; 128 128 State::setWorldEntityList(NULL); 129 129 130 delete this->localPlayer; 130 131 131 132 // delete all the initialized Engines. 132 133 FastFactory::flushAll(true); 133 134 delete LightManager::getInstance(); 134 delete TrackManager::getInstance();135 135 delete ParticleEngine::getInstance(); 136 136 delete AnimationPlayer::getInstance(); … … 144 144 // erease everything that is left. 145 145 delete NullParent::getInstance(); 146 146 147 Shader::suspendShader(); 147 148 … … 174 175 this->shell = NULL; 175 176 this->entities = NULL; 177 this->localPlayer = NULL; 178 this->localCamera = NULL; 176 179 177 180 this->showPNodes = false; … … 215 218 216 219 AnimationPlayer::getInstance(); // initializes the animationPlayer 220 ParticleEngine::getInstance(); 217 221 PhysicsEngine::getInstance(); 218 222 … … 244 248 } 245 249 246 TiXmlDocument* XMLDoc = new TiXmlDocument( path);250 TiXmlDocument* XMLDoc = new TiXmlDocument( getPath()); 247 251 // load the campaign document 248 252 if( !XMLDoc->LoadFile()) 249 253 { 250 254 // report an error 251 PRINTF(1)("loading XML File: %s @ % d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());255 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 252 256 delete XMLDoc; 253 257 return (ErrorMessage){213,"XML File parsing error","World::load()"}; … … 315 319 while( element != NULL) 316 320 { 317 WorldEntity* created = dynamic_cast<WorldEntity*>( loader->fabricate( element)); 318 if( created != NULL) this->spawn( created); 319 // if we load a 'Player' we use it as localPlayer 320 //todo do this more elegant 321 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) 321 BaseObject* created = (loader->fabricate(element)); 322 if( created != NULL ) 322 323 { 323 localPlayer = (Player*) created; 324 CDEngine::getInstance()->setPlayer(localPlayer); 324 if(created->isA(CL_WORLD_ENTITY)) 325 this->spawn(dynamic_cast<WorldEntity*>(created)); 326 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 325 327 NetworkManager::getInstance()->connectSynchronizeable(*(Synchronizeable*)this->localPlayer); 326 328 } 327 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created; 329 330 // if we load a 'Player' we use it as localPlayer 331 332 333 //todo do this more elegant 334 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 335 sky = dynamic_cast<SkyBox*>(created); 328 336 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 329 337 { 330 terrain = (Terrain*) created;338 terrain = dynamic_cast<Terrain*>(created); 331 339 CDEngine::getInstance()->setTerrain(terrain); 332 340 } … … 343 351 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams); 344 352 345 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 346 LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 347 348 // find Track 349 element = root->FirstChildElement( "Track"); 350 if( element == NULL) 351 { 352 PRINTF(0)("World is missing a 'Track'\n"); 353 } 354 else 355 { 356 //load track 357 PRINTF(4)("Loading Track\n"); 358 359 TrackManager::getInstance()->loadParams( element); 360 TrackManager::getInstance()->finalize(); 361 } 353 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 354 // LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 362 355 363 356 // free the XML data … … 366 359 /* GENERIC LOADING PROCESS FINISHED */ 367 360 368 // bind input 369 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_UP); 370 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_DOWN); 371 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_LEFT); 372 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_RIGHT); 373 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1); 374 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON); 375 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON); 376 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEUP); 377 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEDOWN); 361 362 // Create a Player 363 this->localPlayer = new Player(); 364 365 Playable* playable; 366 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 367 if (playableList != NULL) 368 { 369 playable = dynamic_cast<Playable*>(playableList->front()); 370 this->localPlayer->setControllable(playable); 371 } 378 372 379 373 // bind camera 380 //this->localCamera->bind (localPlayer); 381 // this->localPlayer->addChild (this->localCamera); 382 383 384 // TrackManager::getInstance()->setBindSlave(env); 385 PNode* tn = TrackManager::getInstance()->getTrackNode(); 386 tn->addChild(this->localPlayer); 387 388 //localCamera->setParent(TrackNode::getInstance()); 389 tn->addChild(this->localCamera); 390 localCamera->lookAt(tn); 374 playable->addChild (this->localCamera); 375 376 // //localCamera->setParent(TrackNode::getInstance()); 377 // tn->addChild(this->localCamera); 391 378 localCamera->setClipRegion(1, 10000.0); 392 this->localPlayer->setParentMode(PNODE_ALL); 393 TrackManager::getInstance()->condition(1, LEFTRIGHT, this->localPlayer); 394 379 localCamera->lookAt(playable); 380 // this->localPlayer->setParentMode(PNODE_ALL); 395 381 if (sky != NULL) 396 382 { … … 403 389 glNewList (objectList, GL_COMPILE); 404 390 405 //TrackManager::getInstance()->drawGraph(.01);406 //TrackManager::getInstance()->debug(2);407 391 glEndList(); 408 392 … … 415 399 //////////// 416 400 417 Gravity* test = new Gravity();418 419 // SYSTEM TRAILING THE PLAYER420 // Creating a Test Particle System421 422 //new PhysicsConnection(system, gravity);423 // new PhysicsConnection(this->localPlayer, gravity);424 401 425 402 // TestEntity* testEntity = new TestEntity(); … … 427 404 // testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0))); 428 405 // this->spawn(testEntity); 429 430 // TestEntity* testEntity2 = new TestEntity();431 // testEntity2->setAnim(STAND);432 // testEntity2->setRelCoor(Vector(2400.0, 10.0, -30.0));433 // testEntity2->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));434 // //testEntity2->setParent(this->localPlayer);435 // this->spawn(testEntity2);436 //437 // TestEntity* testEntity3 = new TestEntity();438 // testEntity3->setAnim(BOOM);439 // testEntity3->setRelCoor(Vector(2450.0, 10.0, -40.0));440 // testEntity3->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));441 // this->spawn(testEntity3);442 //443 // TestEntity* testEntity4 = new TestEntity();444 // testEntity4->setAnim(FLIP);445 // testEntity4->setRelCoor(Vector(2500.0, 10.0, -22.0));446 // testEntity4->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));447 // this->spawn(testEntity4);448 //449 // TestEntity* testEntity5 = new TestEntity();450 // testEntity5->setAnim(WAVE);451 // testEntity5->setRelCoor(Vector(2420.0, 10.0, -50.0));452 // testEntity5->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));453 // this->spawn(testEntity5);454 //455 // TestEntity* testEntity6 = new TestEntity();456 // testEntity6->setAnim(WAVE);457 // testEntity6->setRelCoor(Vector(2420.0, 10.0, -20.0));458 // testEntity6->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));459 // this->spawn(testEntity6);460 //461 // TestEntity* testEntity7 = new TestEntity();462 // testEntity7->setAnim(WAVE);463 // testEntity7->setRelCoor(Vector(2500.0, 10.0, -50.0));464 // testEntity7->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));465 // this->spawn(testEntity7);466 467 468 469 // PhysicsEngine::getInstance()->debug();470 471 472 406 473 407 for(int i = 0; i < 100; i++) … … 479 413 tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30); 480 414 this->spawn(tmp); 481 482 483 415 } 484 485 486 487 // ClassList::debug();488 416 489 417 this->music = NULL;//(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL); … … 501 429 this->glmis->step(); 502 430 // stuff beyond this point remains to be loaded properly 503 504 // initializing the TrackManager505 TrackManager::getInstance()->addPointV(Vector(150, -35, 5));506 TrackManager::getInstance()->addPointV(Vector(200,-35, 5));507 TrackManager::getInstance()->addPointV(Vector(250, -35, 5));508 TrackManager::getInstance()->addPointV(Vector(320,-33,-.55));509 TrackManager::getInstance()->setDuration(1);510 TrackManager::getInstance()->setSavePoint();511 512 TrackManager::getInstance()->addPointV(Vector(410, 0, 0));513 TrackManager::getInstance()->addPointV(Vector(510, 20, -10));514 TrackManager::getInstance()->addPointV(Vector(550, 20, -10));515 TrackManager::getInstance()->addPointV(Vector(570, 20, -10));516 TrackManager::getInstance()->setDuration(2);517 518 TrackManager::getInstance()->forkS("testFork1,testFork2");519 TrackManager::getInstance()->workOnS("testFork1");520 TrackManager::getInstance()->addPointV(Vector(640, 25, -30));521 TrackManager::getInstance()->addPointV(Vector(700, 40, -120));522 TrackManager::getInstance()->addPointV(Vector(800, 50, -150));523 TrackManager::getInstance()->addPointV(Vector(900, 60, -100));524 TrackManager::getInstance()->addPointV(Vector(900, 60, -70));525 TrackManager::getInstance()->addPointV(Vector(990, 65, -15));526 TrackManager::getInstance()->addPointV(Vector(1050, 65, -10));527 TrackManager::getInstance()->addPointV(Vector(1100, 65, -20));528 TrackManager::getInstance()->setDuration(4);529 530 TrackManager::getInstance()->workOnS("testFork2");531 TrackManager::getInstance()->addPointV(Vector(640, 25, 20));532 TrackManager::getInstance()->addPointV(Vector(670, 50, 120));533 TrackManager::getInstance()->addPointV(Vector(700, 70, 80));534 TrackManager::getInstance()->addPointV(Vector(800, 70, 65));535 TrackManager::getInstance()->addPointV(Vector(850, 65, 65));536 TrackManager::getInstance()->addPointV(Vector(920, 35, 40));537 TrackManager::getInstance()->addPointV(Vector(945, 40, 40));538 TrackManager::getInstance()->addPointV(Vector(970, 24, 40));539 TrackManager::getInstance()->addPointV(Vector(1000, 40, -7));540 541 TrackManager::getInstance()->setDuration(4);542 543 544 TrackManager::getInstance()->joinS("testFork1,testFork2");545 546 TrackManager::getInstance()->addPointV(Vector(1200, 60, -50));547 TrackManager::getInstance()->addPointV(Vector(1300, 50, -50));548 TrackManager::getInstance()->addPointV(Vector(1400, 40, -50));549 TrackManager::getInstance()->addPointV(Vector(1500, 40, -60));550 TrackManager::getInstance()->addPointV(Vector(1600, 35, -55));551 TrackManager::getInstance()->addPointV(Vector(1700, 45, -40));552 TrackManager::getInstance()->addPointV(Vector(1750, 60, -40));553 TrackManager::getInstance()->addPointV(Vector(1770, 80, -40));554 TrackManager::getInstance()->addPointV(Vector(1800, 100, -40));555 TrackManager::getInstance()->setDuration(10);556 557 TrackManager::getInstance()->finalize();558 559 431 560 432 // LIGHT initialisation … … 574 446 { 575 447 LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0); 576 577 578 this->localPlayer = new Player ();579 this->localPlayer->setName ("player");580 this->spawn (this->localPlayer);581 this->localPlayer->setRelCoor(Vector(5,0,0));582 448 /*monitor progress*/ 583 449 this->glmis->step(); 584 585 586 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1);587 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON);588 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON);589 590 /*591 Field* testField = new Gravity();592 testField->setMagnitude(10);593 new PhysicsConnection(this->localPlayer, testField);594 */595 450 596 451 // bind camera … … 617 472 this->glmis->step(); 618 473 619 this->pilotNode = new PilotNode();620 this->spawn(this->pilotNode);621 this->pilotNode->setAbsCoor(Vector(150, -35, 5));622 this->pilotNode->addChild(this->localPlayer);623 this->pilotNode->addChild(this->localCamera);624 this->localCamera->lookAt(this->localPlayer);625 626 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_UP);627 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_DOWN);628 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_LEFT);629 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_RIGHT);630 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, EV_MOUSE_MOTION);631 632 /*633 PNode* tn = TrackManager::getInstance()->getTrackNode();634 tn->addChild(this->localPlayer);635 this->localCamera->lookAt(tn);636 637 tn->addChild(this->localCamera);638 this->localPlayer->setParentMode(PNODE_ALL);639 TrackManager::getInstance()->condition(2, LEFTRIGHT, this->localPlayer);640 */641 474 this->glmis->step(); 642 475 break; … … 666 499 { 667 500 this->bPause = false; 668 this->pilotNode = NULL;669 501 670 502 /* update the object position before game start - so there are no wrong coordinates used in the first processing */ … … 842 674 void World::handleInput () 843 675 { 844 // localinput845 //CommandNode* cn = Orxonox::getInstance()->getLocalInput();846 //cn->process();847 848 676 EventHandler::getInstance()->process(); 849 677 … … 897 725 898 726 /* update tick the rest */ 899 TrackManager::getInstance()->tick(this->dtS);900 727 this->localCamera->tick(this->dtS); 901 728 // tick the engines -
branches/network/src/story_entities/world.h
r5429 r5968 16 16 class Camera; 17 17 class Player; 18 class PNode;19 18 class GLMenuImageScreen; 20 19 class Terrain; … … 22 21 class Text; 23 22 class TiXmlElement; 24 class PilotNode;25 23 26 24 class Shell; … … 121 119 tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 122 120 Player* localPlayer; //!< The Player, you fly through the level. 123 PilotNode* pilotNode; //!< THe pilot node to fly with the mouse124 125 126 121 }; 127 122
Note: See TracChangeset
for help on using the changeset viewer.