Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5445 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Oct 29, 2005, 11:08:08 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Connection-Removing in the Particle-Class

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r5434 r5445  
    172172  CL_LIGHT                      =    0x00000809,
    173173  CL_PARTICLE_EMITTER           =    0x0000080a,
    174   CL_PARTICLE_SYSTEM            =    0x0000080a,
     174  CL_PARTICLE_SYSTEM            =    0x0000080b,
    175175  CL_ENVIRONMENT                =    0x00000810,
    176176  CL_SHADER                     =    0x00000811,
  • trunk/src/lib/particles/particle_emitter.cc

    r5357 r5445  
    5454  this->init();
    5555
    56    if (root)
     56   if (root != NULL)
    5757     this->loadParams(root);
    5858
  • trunk/src/lib/particles/particle_engine.cc

    r5439 r5445  
    5151ParticleEngine::~ParticleEngine ()
    5252{
    53   // we must not do this, because PNoe does it for us
    54   // or we do this with help from ClassList, which essentially makes much more sense
     53  /// @todo we must not do this, because PNoe does it for us
     54  /// or we do this with help from ClassList, which essentially makes much more sense
     55
    5556  // delete all remaining systems
    5657//   tIterator<ParticleSystem>* sysIt = this->systemList->getIterator();
     
    6465   delete this->systemList;
    6566//
    66 //   // delete all remaining emitters
    67 //   tIterator<ParticleEmitter>* emitIt = this->emitterList->getIterator();
    68 //   ParticleEmitter* tmpEmit = emitIt->firstElement();
    69 //   while(tmpEmit)
    70 //     {
    71 //       delete tmpEmit;
    72 //       tmpEmit = emitIt->nextElement();
    73 //     }
    74 //   delete emitIt;
     67   // delete all remaining emitters
     68   tIterator<ParticleEmitter>* emitIt = this->emitterList->getIterator();
     69   ParticleEmitter* tmpEmit = emitIt->firstElement();
     70   while(tmpEmit)
     71     {
     72       delete tmpEmit;
     73       tmpEmit = emitIt->nextElement();
     74     }
     75   delete emitIt;
    7576   delete this->emitterList;
    7677
     
    119120}
    120121
     122#include "class_list.h"
    121123/**
    122124* @brief Connects a ParticleSystem to a ParticleSystem thus emitting Particles.
     
    126128void ParticleEngine::addConnection(const char* emitter, const char* system)
    127129{
    128   ParticleEmitter* tmpEmit = this->getEmitterByName(emitter);
    129   ParticleSystem* tmpSys = this->getSystemByName(system);
     130  ParticleEmitter* tmpEmit = dynamic_cast<ParticleEmitter*>(ClassList::getObject(emitter, CL_PARTICLE_EMITTER));//this->getEmitterByName(emitter);
     131  ParticleSystem* tmpSys = dynamic_cast<ParticleSystem*>(ClassList::getObject(system, CL_PARTICLE_SYSTEM));//this->getSystemByName(system);
    130132
    131133  if (tmpEmit != NULL && tmpSys != NULL)
     
    154156      if (tmpConnection->emitter == emitter && tmpConnection->system == system)
    155157        {
    156           PRINTF(2)("Connection between Emitter and System already added\n");
     158          PRINTF(2)("Connection between Emitter and System already exists.\n");
    157159          delete tmpConIt;
    158160          return;
     
    181183  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    182184  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    183   while(tmpConnection)
     185  while(tmpConnection != NULL)
    184186    {
    185187      if (tmpConnection->system == system)
     
    202204  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    203205  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    204   while(tmpConnection)
     206  while(tmpConnection != NULL)
    205207    {
    206208      if (tmpConnection->emitter == emitter)
     
    298300
    299301/**
    300  * @param systemName the name of the system to search for
    301  * @returns the system called by systemName or NULL if not found
    302 */
    303 ParticleSystem* ParticleEngine::getSystemByName(const char* systemName) const
    304 {
    305   tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    306   ParticleSystem* tmpSys = tmpIt->firstElement();
    307   while(tmpSys)
    308     {
    309       if (!strcmp(systemName, tmpSys->getName()))
    310         {
    311           delete tmpIt;
    312           return tmpSys;
    313         }
    314       tmpSys = tmpIt->nextElement();
    315     }
    316   delete tmpIt;
    317   return NULL;
    318 }
    319 
    320 /**
    321302 * @param number the n-th system to return
    322303 * @returns the system called by number or NULL if not found
     
    342323
    343324/**
    344  * @param emitterName the name of the emitter to search for
    345  * @returns the emitter called by emitterName or NULL if not found
    346 */
    347 ParticleEmitter* ParticleEngine::getEmitterByName(const char* emitterName) const
    348 {
    349   tIterator<ParticleEmitter>* tmpIt = emitterList->getIterator();
    350   ParticleEmitter* tmpEmit = tmpIt->firstElement();
    351   while(tmpEmit)
    352     {
    353       if (!strcmp(emitterName, tmpEmit->getName()))
    354         {
    355           delete tmpIt;
    356           return tmpEmit;
    357         }
    358       tmpEmit = tmpIt->nextElement();
    359     }
    360   delete tmpIt;
    361   return NULL;
    362 }
    363 
    364 
    365 /**
    366325 * @param number the n-th emitter to return
    367326 * @returns the emitter called by number or NULL if not found
  • trunk/src/lib/particles/particle_engine.h

    r5405 r5445  
    5353  bool breakConnection(ParticleConnection* connection);
    5454
    55   ParticleSystem* getSystemByName(const char* systemName) const;
    56   ParticleSystem* getSystemByNumber(unsigned int number) const;
    57   ParticleEmitter* getEmitterByName(const char* emitterName) const;
    58   ParticleEmitter* getEmitterByNumber(unsigned int number) const;
     55   ParticleSystem* getSystemByNumber(unsigned int number) const;
     56   ParticleEmitter* getEmitterByNumber(unsigned int number) const;
    5957
    6058  void debug();
  • trunk/src/lib/particles/particle_system.cc

    r5357 r5445  
    4949
    5050/**
    51   \brief creates a Particle System out of a XML-element
    52 * @param root: the XML-element to load from
     51 * @brief creates a Particle System out of a XML-element
     52 * @param root: the XML-element to load from
    5353 */
    5454ParticleSystem::ParticleSystem(const TiXmlElement* root)
     
    198198      case PARTICLE_SPRITE:
    199199        this->material = new Material("transperencyMap");
    200         this->material->setDiffuseMap("pictures/radialTransparency.png");
     200        this->material->setDiffuseMap("maps/radialTransparency.png");
    201201      //  material->setTransparency(.5);
    202202        break;
  • trunk/src/world_entities/weapons/test_bullet.cc

    r5444 r5445  
    6464TestBullet::~TestBullet ()
    6565{
    66   delete this->emitter;
     66//  delete this->emitter;
    6767
    68   /* this is normaly done by World.cc by deleting the ParticleEngine
    69   if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() == 1)
     68  /* this is normaly done by World.cc by deleting the ParticleEngine */
     69  if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
    7070  {
    71     delete TestBullet::explosionParticles;
     71    if (ClassList::exists(TestBullet::explosionParticles, CL_PARTICLE_SYSTEM))
     72      delete TestBullet::explosionParticles;
    7273    TestBullet::explosionParticles = NULL;
     74    printf("-------------------\n");
    7375  }
    74   */
     76
    7577}
    7678
     
    8385  if (unlikely(TestBullet::explosionParticles == NULL))
    8486  {
     87    ClassList::debug(3, CL_PARTICLE_SYSTEM);
    8588    TestBullet::explosionParticles = new ParticleSystem(10000, PARTICLE_SPRITE);
     89    TestBullet::explosionParticles->setName("TestBulletTrailParticles");
    8690    TestBullet::explosionParticles->setLifeSpan(.5);
    8791    TestBullet::explosionParticles->setRadius(0.0, .5);
     
    9195    TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5);
    9296    TestBullet::explosionParticles->setColor(1.0, .5,.5,.5,.0);
     97    printf("::::::::::::::::::::::::::::\n");
    9398  }
    9499
Note: See TracChangeset for help on using the changeset viewer.