Changeset 5924 in orxonox.OLD for branches/avi_play/src/story_entities
- Timestamp:
- Dec 4, 2005, 11:37:49 PM (19 years ago)
- Location:
- branches/avi_play/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/avi_play/src/story_entities/world.cc
r5819 r5924 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" … … 72 69 #include "npcs/npc_test1.h" 73 70 #include "shader.h" 71 72 #include "playable.h" 74 73 75 74 SHELL_COMMAND(speed, World, setSpeed); … … 122 121 PRINTF(3)("World::~World() - deleting current world\n"); 123 122 123 124 124 // here everything that is alocated by the World is deleted 125 125 delete this->entities; 126 126 State::setWorldEntityList(NULL); 127 127 128 delete this->localPlayer; 128 129 129 130 // delete all the initialized Engines. 130 131 FastFactory::flushAll(true); 131 132 delete LightManager::getInstance(); 132 delete TrackManager::getInstance();133 133 delete ParticleEngine::getInstance(); 134 134 delete AnimationPlayer::getInstance(); … … 142 142 // erease everything that is left. 143 143 delete NullParent::getInstance(); 144 144 145 Shader::suspendShader(); 145 146 … … 172 173 this->shell = NULL; 173 174 this->entities = NULL; 175 this->localPlayer = NULL; 176 this->localCamera = NULL; 174 177 175 178 this->showPNodes = false; … … 213 216 214 217 AnimationPlayer::getInstance(); // initializes the animationPlayer 218 ParticleEngine::getInstance(); 215 219 PhysicsEngine::getInstance(); 216 220 … … 242 246 } 243 247 244 TiXmlDocument* XMLDoc = new TiXmlDocument( path);248 TiXmlDocument* XMLDoc = new TiXmlDocument( getPath()); 245 249 // load the campaign document 246 250 if( !XMLDoc->LoadFile()) 247 251 { 248 252 // report an error 249 PRINTF(1)("loading XML File: %s @ % d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());253 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 250 254 delete XMLDoc; 251 255 return (ErrorMessage){213,"XML File parsing error","World::load()"}; … … 313 317 while( element != NULL) 314 318 { 315 WorldEntity* created = dynamic_cast<WorldEntity*>( loader->fabricate( element)); 316 if( created != NULL) this->spawn( created); 319 BaseObject* created = (loader->fabricate(element)); 320 if( created != NULL ) 321 { 322 if(created->isA(CL_WORLD_ENTITY)) 323 this->spawn(dynamic_cast<WorldEntity*>(created)); 324 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 325 } 326 317 327 // if we load a 'Player' we use it as localPlayer 328 329 318 330 //todo do this more elegant 319 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) 320 { 321 localPlayer = (Player*) created; 322 CDEngine::getInstance()->setPlayer(localPlayer); 323 } 324 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created; 331 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 332 sky = dynamic_cast<SkyBox*>(created); 325 333 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 326 334 { 327 terrain = (Terrain*) created;335 terrain = dynamic_cast<Terrain*>(created); 328 336 CDEngine::getInstance()->setTerrain(terrain); 329 337 } … … 340 348 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams); 341 349 342 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 343 LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 344 345 // find Track 346 element = root->FirstChildElement( "Track"); 347 if( element == NULL) 348 { 349 PRINTF(0)("World is missing a 'Track'\n"); 350 } 351 else 352 { 353 //load track 354 PRINTF(4)("Loading Track\n"); 355 356 TrackManager::getInstance()->loadParams( element); 357 TrackManager::getInstance()->finalize(); 358 } 350 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 351 // LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 359 352 360 353 // free the XML data … … 363 356 /* GENERIC LOADING PROCESS FINISHED */ 364 357 365 // bind input 366 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_UP); 367 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_DOWN); 368 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_LEFT); 369 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_RIGHT); 370 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1); 371 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON); 372 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON); 373 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEUP); 374 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEDOWN); 358 359 // Create a Player 360 this->localPlayer = new Player(); 361 362 Playable* playable; 363 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 364 if (playableList != NULL) 365 { 366 playable = dynamic_cast<Playable*>(playableList->front()); 367 this->localPlayer->setControllable(playable); 368 } 375 369 376 370 // bind camera 377 //this->localCamera->bind (localPlayer); 378 // this->localPlayer->addChild (this->localCamera); 379 380 381 // TrackManager::getInstance()->setBindSlave(env); 382 PNode* tn = TrackManager::getInstance()->getTrackNode(); 383 tn->addChild(this->localPlayer); 384 385 //localCamera->setParent(TrackNode::getInstance()); 386 tn->addChild(this->localCamera); 387 localCamera->lookAt(tn); 371 playable->addChild (this->localCamera); 372 373 // //localCamera->setParent(TrackNode::getInstance()); 374 // tn->addChild(this->localCamera); 388 375 localCamera->setClipRegion(1, 10000.0); 389 this->localPlayer->setParentMode(PNODE_ALL); 390 TrackManager::getInstance()->condition(1, LEFTRIGHT, this->localPlayer); 391 376 localCamera->lookAt(playable); 377 // this->localPlayer->setParentMode(PNODE_ALL); 392 378 if (sky != NULL) 393 379 { … … 400 386 glNewList (objectList, GL_COMPILE); 401 387 402 //TrackManager::getInstance()->drawGraph(.01);403 //TrackManager::getInstance()->debug(2);404 388 glEndList(); 405 389 … … 412 396 //////////// 413 397 414 Gravity* test = new Gravity();415 416 // SYSTEM TRAILING THE PLAYER417 // Creating a Test Particle System418 419 //new PhysicsConnection(system, gravity);420 // new PhysicsConnection(this->localPlayer, gravity);421 398 422 399 // TestEntity* testEntity = new TestEntity(); … … 424 401 // testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0))); 425 402 // this->spawn(testEntity); 426 427 // TestEntity* testEntity2 = new TestEntity();428 // testEntity2->setAnim(STAND);429 // testEntity2->setRelCoor(Vector(2400.0, 10.0, -30.0));430 // testEntity2->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));431 // //testEntity2->setParent(this->localPlayer);432 // this->spawn(testEntity2);433 //434 // TestEntity* testEntity3 = new TestEntity();435 // testEntity3->setAnim(BOOM);436 // testEntity3->setRelCoor(Vector(2450.0, 10.0, -40.0));437 // testEntity3->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));438 // this->spawn(testEntity3);439 //440 // TestEntity* testEntity4 = new TestEntity();441 // testEntity4->setAnim(FLIP);442 // testEntity4->setRelCoor(Vector(2500.0, 10.0, -22.0));443 // testEntity4->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));444 // this->spawn(testEntity4);445 //446 // TestEntity* testEntity5 = new TestEntity();447 // testEntity5->setAnim(WAVE);448 // testEntity5->setRelCoor(Vector(2420.0, 10.0, -50.0));449 // testEntity5->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));450 // this->spawn(testEntity5);451 //452 // TestEntity* testEntity6 = new TestEntity();453 // testEntity6->setAnim(WAVE);454 // testEntity6->setRelCoor(Vector(2420.0, 10.0, -20.0));455 // testEntity6->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));456 // this->spawn(testEntity6);457 //458 // TestEntity* testEntity7 = new TestEntity();459 // testEntity7->setAnim(WAVE);460 // testEntity7->setRelCoor(Vector(2500.0, 10.0, -50.0));461 // testEntity7->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));462 // this->spawn(testEntity7);463 464 465 466 // PhysicsEngine::getInstance()->debug();467 468 469 403 470 404 for(int i = 0; i < 100; i++) … … 476 410 tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30); 477 411 this->spawn(tmp); 478 479 480 412 } 481 482 483 484 // ClassList::debug();485 413 486 414 this->music = NULL;//(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL); … … 498 426 this->glmis->step(); 499 427 // stuff beyond this point remains to be loaded properly 500 501 // initializing the TrackManager502 TrackManager::getInstance()->addPointV(Vector(150, -35, 5));503 TrackManager::getInstance()->addPointV(Vector(200,-35, 5));504 TrackManager::getInstance()->addPointV(Vector(250, -35, 5));505 TrackManager::getInstance()->addPointV(Vector(320,-33,-.55));506 TrackManager::getInstance()->setDuration(1);507 TrackManager::getInstance()->setSavePoint();508 509 TrackManager::getInstance()->addPointV(Vector(410, 0, 0));510 TrackManager::getInstance()->addPointV(Vector(510, 20, -10));511 TrackManager::getInstance()->addPointV(Vector(550, 20, -10));512 TrackManager::getInstance()->addPointV(Vector(570, 20, -10));513 TrackManager::getInstance()->setDuration(2);514 515 TrackManager::getInstance()->forkS("testFork1,testFork2");516 TrackManager::getInstance()->workOnS("testFork1");517 TrackManager::getInstance()->addPointV(Vector(640, 25, -30));518 TrackManager::getInstance()->addPointV(Vector(700, 40, -120));519 TrackManager::getInstance()->addPointV(Vector(800, 50, -150));520 TrackManager::getInstance()->addPointV(Vector(900, 60, -100));521 TrackManager::getInstance()->addPointV(Vector(900, 60, -70));522 TrackManager::getInstance()->addPointV(Vector(990, 65, -15));523 TrackManager::getInstance()->addPointV(Vector(1050, 65, -10));524 TrackManager::getInstance()->addPointV(Vector(1100, 65, -20));525 TrackManager::getInstance()->setDuration(4);526 527 TrackManager::getInstance()->workOnS("testFork2");528 TrackManager::getInstance()->addPointV(Vector(640, 25, 20));529 TrackManager::getInstance()->addPointV(Vector(670, 50, 120));530 TrackManager::getInstance()->addPointV(Vector(700, 70, 80));531 TrackManager::getInstance()->addPointV(Vector(800, 70, 65));532 TrackManager::getInstance()->addPointV(Vector(850, 65, 65));533 TrackManager::getInstance()->addPointV(Vector(920, 35, 40));534 TrackManager::getInstance()->addPointV(Vector(945, 40, 40));535 TrackManager::getInstance()->addPointV(Vector(970, 24, 40));536 TrackManager::getInstance()->addPointV(Vector(1000, 40, -7));537 538 TrackManager::getInstance()->setDuration(4);539 540 541 TrackManager::getInstance()->joinS("testFork1,testFork2");542 543 TrackManager::getInstance()->addPointV(Vector(1200, 60, -50));544 TrackManager::getInstance()->addPointV(Vector(1300, 50, -50));545 TrackManager::getInstance()->addPointV(Vector(1400, 40, -50));546 TrackManager::getInstance()->addPointV(Vector(1500, 40, -60));547 TrackManager::getInstance()->addPointV(Vector(1600, 35, -55));548 TrackManager::getInstance()->addPointV(Vector(1700, 45, -40));549 TrackManager::getInstance()->addPointV(Vector(1750, 60, -40));550 TrackManager::getInstance()->addPointV(Vector(1770, 80, -40));551 TrackManager::getInstance()->addPointV(Vector(1800, 100, -40));552 TrackManager::getInstance()->setDuration(10);553 554 TrackManager::getInstance()->finalize();555 556 428 557 429 // LIGHT initialisation … … 571 443 { 572 444 LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0); 573 574 575 this->localPlayer = new Player ();576 this->localPlayer->setName ("player");577 this->spawn (this->localPlayer);578 this->localPlayer->setRelCoor(Vector(5,0,0));579 445 /*monitor progress*/ 580 446 this->glmis->step(); 581 582 583 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1);584 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON);585 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON);586 587 /*588 Field* testField = new Gravity();589 testField->setMagnitude(10);590 new PhysicsConnection(this->localPlayer, testField);591 */592 447 593 448 // bind camera … … 614 469 this->glmis->step(); 615 470 616 this->pilotNode = new PilotNode();617 this->spawn(this->pilotNode);618 this->pilotNode->setAbsCoor(Vector(150, -35, 5));619 this->pilotNode->addChild(this->localPlayer);620 this->pilotNode->addChild(this->localCamera);621 this->localCamera->lookAt(this->localPlayer);622 623 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_UP);624 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_DOWN);625 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_LEFT);626 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_RIGHT);627 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, EV_MOUSE_MOTION);628 629 /*630 PNode* tn = TrackManager::getInstance()->getTrackNode();631 tn->addChild(this->localPlayer);632 this->localCamera->lookAt(tn);633 634 tn->addChild(this->localCamera);635 this->localPlayer->setParentMode(PNODE_ALL);636 TrackManager::getInstance()->condition(2, LEFTRIGHT, this->localPlayer);637 */638 471 this->glmis->step(); 639 472 break; … … 663 496 { 664 497 this->bPause = false; 665 this->pilotNode = NULL;666 498 667 499 /* update the object position before game start - so there are no wrong coordinates used in the first processing */ … … 838 670 void World::handleInput () 839 671 { 840 // localinput841 //CommandNode* cn = Orxonox::getInstance()->getLocalInput();842 //cn->process();843 844 672 EventHandler::getInstance()->process(); 845 673 … … 893 721 894 722 /* update tick the rest */ 895 TrackManager::getInstance()->tick(this->dtS);896 723 this->localCamera->tick(this->dtS); 897 724 // tick the engines -
branches/avi_play/src/story_entities/world.h
r5429 r5924 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.