Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4917 in orxonox.OLD for orxonox/trunk/src/story_entities/world.cc


Ignore:
Timestamp:
Jul 21, 2005, 12:22:44 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: some very little cleanup in the World - make it a better place

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/story_entities/world.cc

    r4890 r4917  
    6969#include "class_list.h"
    7070
     71#include "cd_engine.h"
     72
    7173
    7274using namespace std;
     
    787789
    788790/**
    789   *  checks for collisions
    790 
    791     This method runs through all WorldEntities known to the world and checks for collisions
    792     between them. In case of collisions the collide() method of the corresponding entities
    793     is called.
    794 */
    795 void World::collide ()
    796 {
    797   /*
    798   List *a, *b;
    799   WorldEntity *aobj, *bobj;
    800 
    801   a = entities;
    802 
    803   while( a != NULL)
    804     {
    805       aobj = a->nextElement();
    806       if( aobj->bCollide && aobj->collisioncluster != NULL)
    807         {
    808           b = a->nextElement();
    809           while( b != NULL )
    810             {
    811               bobj = b->nextElement();
    812               if( bobj->bCollide && bobj->collisioncluster != NULL )
    813                 {
    814                   unsigned long ahitflg, bhitflg;
    815                   if( check_collision ( &aobj->place, aobj->collisioncluster,
    816                                         &ahitflg, &bobj->place, bobj->collisioncluster,
    817                                         &bhitflg) );
    818                   {
    819                     aobj->collide (bobj, ahitflg, bhitflg);
    820                     bobj->collide (aobj, bhitflg, ahitflg);
    821                   }
    822                 }
    823               b = b->nextElement();
    824             }
    825         }
    826       a = a->enumerate();
    827     }
    828   */
    829 }
    830 
    831 /**
    832   *  runs through all entities calling their draw() methods
    833 */
    834 void World::draw ()
    835 {
    836   /* draw entities */
    837   WorldEntity* entity;
    838   glLoadIdentity();
    839   //entity = this->entities->enumerate();
    840   tIterator<WorldEntity>* iterator = this->entities->getIterator();
    841   entity = iterator->nextElement();
    842   while( entity != NULL )
    843     {
    844       if( entity->isVisible() ) entity->draw();
    845       //entity = this->entities->nextElement();
    846       entity = iterator->nextElement();
    847     }
    848   delete iterator;
    849 
    850   glCallList (objectList);
    851 
    852   ParticleEngine::getInstance()->draw();
    853 
    854   GraphicsEngine::getInstance()->draw();
    855   //TextEngine::getInstance()->draw();
    856 }
    857 
    858 
    859 /**
    860791 *  function to put your own debug stuff into it. it can display informations about
    861792   the current class/procedure
     
    863794void World::debug()
    864795{
    865   PRINTF(2)("debug() - starting debug\n");
    866   PNode* p1 = NullParent::getInstance ();
    867   PNode* p2 = new PNode (Vector(2, 2, 2), p1);
    868   PNode* p3 = new PNode (Vector(4, 4, 4), p1);
    869   PNode* p4 = new PNode (Vector(6, 6, 6), p2);
    870 
    871   p1->debug ();
    872   p2->debug ();
    873   p3->debug ();
    874   p4->debug ();
    875 
    876   p1->shiftCoor (Vector(-1, -1, -1));
    877 
    878   printf("World::debug() - shift\n");
    879   p1->debug ();
    880   p2->debug ();
    881   p3->debug ();
    882   p4->debug ();
    883 
    884   p1->update (0);
    885 
    886   printf ("World::debug() - update\n");
    887   p1->debug ();
    888   p2->debug ();
    889   p3->debug ();
    890   p4->debug ();
    891 
    892   p2->shiftCoor (Vector(-1, -1, -1));
    893   p1->update (0);
    894 
    895   p1->debug ();
    896   p2->debug ();
    897   p3->debug ();
    898   p4->debug ();
    899 
    900   p2->setAbsCoor (Vector(1,2,3));
    901 
    902 
    903  p1->update (0);
    904 
    905   p1->debug ();
    906   p2->debug ();
    907   p3->debug ();
    908   p4->debug ();
    909 
    910   delete p1;
    911 
    912 
    913   /*
    914   WorldEntity* entity;
    915   printf("counting all entities\n");
    916   printf("World::debug() - enumerate()\n");
    917   entity = entities->enumerate();
    918   while( entity != NULL )
    919     {
    920       if( entity->bDraw ) printf("got an entity\n");
    921       entity = entities->nextElement();
    922     }
    923   */
    924796}
    925797
     
    1075947
    1076948
     949void World::collide()
     950{
     951
     952}
     953
    1077954/**
    1078955 *  render the current frame
     
    1098975
    1099976/**
     977 *  runs through all entities calling their draw() methods
     978 */
     979void World::draw ()
     980{
     981  /* draw entities */
     982  WorldEntity* entity;
     983  glLoadIdentity();
     984  //entity = this->entities->enumerate();
     985  tIterator<WorldEntity>* iterator = this->entities->getIterator();
     986  entity = iterator->nextElement();
     987  while( entity != NULL )
     988  {
     989    if( entity->isVisible() ) entity->draw();
     990      //entity = this->entities->nextElement();
     991    entity = iterator->nextElement();
     992  }
     993  delete iterator;
     994
     995  glCallList (objectList);
     996
     997  ParticleEngine::getInstance()->draw();
     998
     999  GraphicsEngine::getInstance()->draw();
     1000  //TextEngine::getInstance()->draw();
     1001}
     1002
     1003/**
    11001004 *  add and spawn a new entity to this world
    11011005 * @param entity to be added
Note: See TracChangeset for help on using the changeset viewer.