home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / ParticleSystem.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-06  |  2.3 KB  |  71 lines

  1. #include "ParticleSystem.h"
  2.  
  3. #include <stdlib.h>
  4. #include "log.h"
  5. #include "SDL.h"
  6. #include "Game.h"
  7.  
  8. ParticleCluster* ParticleSystem::particleClusters[PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS];
  9.  
  10.  
  11. void ParticleSystem::linkParticleCluster(ParticleCluster* cluster){
  12.     for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
  13.         if(particleClusters[i]==NULL){
  14. //            if(particleClusters[i]==cluster){
  15. //                warn("(in linkParticleCluster()): Cluster already linked.\n\n");
  16. //                return;
  17. //            }else{
  18.                 particleClusters[i]=cluster;
  19.                 return;
  20. //            }
  21.         }
  22.     }
  23.     warn("(in ParticleSystem::linkParticleCluster()): Couldn't link particle cluster. MAX_PARTICLE_CLUSTERS reached.\n\n");
  24.     
  25. }
  26. void ParticleSystem::unlinkParticleCluster(ParticleCluster* cluster){
  27.     for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
  28.         if(particleClusters[i]==cluster){
  29.                 particleClusters[i]=NULL;
  30.                 return;    // THINKABOUTME: doppelte lottchen??
  31.         }
  32.     }
  33.     warn("(in unlinkParticleCluster()): Couldn't find particle cluster to unlink.\n\n");
  34. }
  35. void ParticleSystem::deleteParticleCluster(ParticleCluster* cluster){
  36.     for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
  37.         if(particleClusters[i]==cluster){
  38.                 delete particleClusters[i];
  39.                 particleClusters[i]=NULL;
  40.                 return;    // THINKABOUTME: doppelte lottchen??
  41.         }
  42.     }
  43.     warn("(in ParticleSystem::deleteParticleCluster()): Couldn't find particle cluster to delete.\n\n");
  44. }
  45.  
  46. void ParticleSystem::renderParticleClusters(){
  47.     for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
  48.         if(particleClusters[i]!=NULL 
  49.                 && particleClusters[i]->importance <= Renderer::info.var.renderParticleEffects
  50.                 && (particleClusters[i]->boundingSphereRadius == 0.0f || Game::cam.sphereInFrustum(particleClusters[i]->pos, particleClusters[i]->boundingSphereRadius) )
  51.             ){
  52.             particleClusters[i]->render();
  53.         }
  54.     }
  55. }
  56.  
  57. void ParticleSystem::moveParticleClusters(){
  58.     unsigned long currentMillis=SDL_GetTicks();
  59.  
  60.     for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
  61.         if(particleClusters[i]!=NULL){
  62.             if(currentMillis  > particleClusters[i]->spawntimeMillis + particleClusters[i]->lifetimeMillis){
  63.                 delete particleClusters[i];
  64.                 particleClusters[i]=NULL;
  65.                 continue;
  66.             }
  67.             particleClusters[i]->move();    // THINKABOUTME: EIN delatT verwenden?
  68.         }
  69.     }
  70. }
  71.