Changeset 2816 in orxonox.OLD for orxonox/trunk/src/world.cc
- Timestamp:
- Nov 11, 2004, 10:32:34 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world.cc
r2811 r2816 22 22 #include "command_node.h" 23 23 #include "camera.h" 24 #include "environment.h" 24 25 25 26 using namespace std; … … 35 36 this->worldName = name; 36 37 this->debugWorldNr = -1; 37 this->entities = new List <WorldEntity>();38 this->entities = new List(); 38 39 } 39 40 … … 42 43 this->debugWorldNr = worldID; 43 44 this->worldName = NULL; 44 this->entities = new List <WorldEntity>();45 this->entities = new List(); 45 46 } 46 47 … … 74 75 this->bQuitCurrentGame = true; 75 76 this->localCamera->setWorld(NULL); 77 this->entities->clear(); 78 Orxonox::getInstance()->get_localinput()->reset(); 76 79 this->~World(); 77 80 } … … 105 108 106 109 // create the tracks 107 this->tracklen = 6;108 this->track = new Track[ 6];110 this->tracklen = 2; 111 this->track = new Track[2]; 109 112 for( int i = 0; i < this->tracklen; i++) 110 113 { … … 113 116 114 117 // create a player 115 //WorldEntity* myPlayer = (WorldEntity*) this->spawn<Player>();116 118 WorldEntity* myPlayer = new Player(); 117 119 this->spawn(myPlayer); … … 125 127 this->localCamera = new Camera(this); 126 128 this->getCamera()->bind (myPlayer); 129 130 Placement* plc = new Placement; 131 plc->r = Vector(100, 10, 10); 132 plc->w = Quaternion(); 133 WorldEntity* env = new Environment(); 134 this->spawn(env, plc); 135 136 this->entities->debug(); 127 137 break; 128 138 } … … 260 270 void World::collide () 261 271 { 262 List<WorldEntity> *a, *b; 272 /* 273 List *a, *b; 263 274 WorldEntity *aobj, *bobj; 264 265 a = entities ->get_next();275 276 a = entities; 266 277 267 278 while( a != NULL) 268 279 { 269 aobj = a-> get_object();280 aobj = a->nextElement(); 270 281 if( aobj->bCollide && aobj->collisioncluster != NULL) 271 282 { 272 b = a-> get_next();283 b = a->nextElement(); 273 284 while( b != NULL ) 274 285 { 275 bobj = b-> get_object();286 bobj = b->nextElement(); 276 287 if( bobj->bCollide && bobj->collisioncluster != NULL ) 277 288 { … … 285 296 } 286 297 } 287 b = b-> get_next();298 b = b->nextElement(); 288 299 } 289 300 } 290 a = a->get_next(); 291 } 301 a = a->enumerate(); 302 } 303 */ 292 304 } 293 305 … … 300 312 301 313 // draw entities 302 List <WorldEntity>*l;314 List *l; 303 315 WorldEntity* entity; 304 316 305 l = entities->get_next(); 306 while( l != NULL ) 317 l = entities; 318 entity = l->enumerate(); 319 while( entity != NULL ) 307 320 { 308 entity = l->get_object();309 321 if( entity->bDraw ) entity->draw(); 310 l = l->get_next();322 entity = l->nextElement(); 311 323 } 312 324 … … 328 340 void World::update () 329 341 { 330 List<WorldEntity> *l;342 //List<WorldEntity> *l; 331 343 WorldEntity* entity; 332 344 Location* loc; … … 334 346 Uint32 t; 335 347 336 l = entities->get_next(); 337 while( l != NULL ) 348 // l = entities->enumerate(); 349 entity = this->entities->enumerate(); 350 while( entity != NULL ) 338 351 { 339 entity = l->get_object(); 352 340 353 341 354 if( !entity->isFree() ) … … 375 388 } 376 389 377 l = l->get_next();390 entity = entities->nextElement(); 378 391 } 379 392 … … 386 399 void World::time_slice (Uint32 deltaT) 387 400 { 388 List<WorldEntity> *l;401 //List<WorldEntity> *l; 389 402 WorldEntity* entity; 390 403 float seconds = deltaT; … … 392 405 seconds /= 1000; 393 406 394 l = entities->get_next();395 while( l!= NULL)407 entity = entities->enumerate(); 408 while( entity != NULL) 396 409 { 397 entity = l->get_object();398 410 entity->tick (seconds); 399 l = l->get_next();400 } 401 411 entity = entities->nextElement(); 412 } 413 402 414 for( int i = 0; i < tracklen; i++) track[i].tick (seconds); 403 415 } … … 436 448 void World::debug() 437 449 { 438 List<WorldEntity> *l;450 //List<WorldEntity> *l; 439 451 WorldEntity* entity; 440 452 441 453 printf("counting all entities\n"); 442 l = entities->get_next(); 443 while( l != NULL ) 454 printf("World::debug() - enumerate()\n"); 455 entity = entities->enumerate(); 456 while( entity != NULL ) 444 457 { 445 entity = l->get_object();446 458 if( entity->bDraw ) printf("got an entity\n"); 447 l = l->get_next();459 entity = entities->nextElement(); 448 460 } 449 461 } … … 470 482 // Draw 471 483 display(); 484 485 for(int i = 0; i < 1000000; i++){} 486 472 487 } 473 488 printf("World|Exiting the main loop\n"); … … 502 517 { 503 518 Uint32 dt = currentFrame - this->lastFrame; 504 /*519 505 520 if(dt > 0) 506 521 { … … 510 525 else 511 526 { 512 printf("fps = 1000 \n");513 } 514 */527 printf("fps = 1000 but 0ms!\n"); 528 } 529 515 530 this->time_slice (dt); 516 531 this->update (); … … 570 585 Location* loc = NULL; 571 586 WorldEntity* owner; 572 //T* entity = new T(); 573 entities->add (entity, LIST_ADD_NEXT); 574 //if( loc == NULL) 575 //{ 576 zeroloc.dist = 0; 577 zeroloc.part = 0; 578 zeroloc.pos = Vector(); 579 zeroloc.rot = Quaternion(); 580 loc = &zeroloc; 581 //} 587 588 entities->add (entity); 589 zeroloc.dist = 0; 590 zeroloc.part = 0; 591 zeroloc.pos = Vector(); 592 zeroloc.rot = Quaternion(); 593 loc = &zeroloc; 582 594 entity->init (loc, owner); 583 595 if (entity->bFree) … … 586 598 } 587 599 entity->post_spawn (); 600 } 601 602 603 void World::spawn(WorldEntity* entity, Location* loc) 604 { 605 Location zeroLoc; 606 WorldEntity* owner; 607 this->entities->add (entity); 608 if( loc == NULL) 609 { 610 zeroLoc.dist = 0; 611 zeroLoc.part = 0; 612 zeroLoc.pos = Vector(); 613 zeroLoc.rot = Quaternion(); 614 loc = &zeroLoc; 615 } 616 entity->init (loc, owner); 617 if (entity->bFree) 618 { 619 this->track[loc->part].map_coords( loc, entity->get_placement()); 620 } 621 entity->post_spawn (); 588 622 //return entity; 589 623 } 624 625 626 void World::spawn(WorldEntity* entity, Placement* plc) 627 { 628 Placement zeroPlc; 629 WorldEntity* owner; 630 if( plc == NULL) 631 { 632 zeroPlc.r = Vector(); 633 zeroPlc.w = Quaternion(); 634 plc = &zeroPlc; 635 } 636 this->entities->add (entity); 637 entity->init (plc, owner); 638 entity->post_spawn (); 639 //return entity; 640 }
Note: See TracChangeset
for help on using the changeset viewer.