home *** CD-ROM | disk | FTP | other *** search
- #include "ParticleSystem.h"
-
- #include <stdlib.h>
- #include "log.h"
- #include "SDL.h"
- #include "Game.h"
-
- ParticleCluster* ParticleSystem::particleClusters[PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS];
-
-
- void ParticleSystem::linkParticleCluster(ParticleCluster* cluster){
- for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
- if(particleClusters[i]==NULL){
- // if(particleClusters[i]==cluster){
- // warn("(in linkParticleCluster()): Cluster already linked.\n\n");
- // return;
- // }else{
- particleClusters[i]=cluster;
- return;
- // }
- }
- }
- warn("(in ParticleSystem::linkParticleCluster()): Couldn't link particle cluster. MAX_PARTICLE_CLUSTERS reached.\n\n");
-
- }
- void ParticleSystem::unlinkParticleCluster(ParticleCluster* cluster){
- for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
- if(particleClusters[i]==cluster){
- particleClusters[i]=NULL;
- return; // THINKABOUTME: doppelte lottchen??
- }
- }
- warn("(in unlinkParticleCluster()): Couldn't find particle cluster to unlink.\n\n");
- }
- void ParticleSystem::deleteParticleCluster(ParticleCluster* cluster){
- for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
- if(particleClusters[i]==cluster){
- delete particleClusters[i];
- particleClusters[i]=NULL;
- return; // THINKABOUTME: doppelte lottchen??
- }
- }
- warn("(in ParticleSystem::deleteParticleCluster()): Couldn't find particle cluster to delete.\n\n");
- }
-
- void ParticleSystem::renderParticleClusters(){
- for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
- if(particleClusters[i]!=NULL
- && particleClusters[i]->importance <= Renderer::info.var.renderParticleEffects
- && (particleClusters[i]->boundingSphereRadius == 0.0f || Game::cam.sphereInFrustum(particleClusters[i]->pos, particleClusters[i]->boundingSphereRadius) )
- ){
- particleClusters[i]->render();
- }
- }
- }
-
- void ParticleSystem::moveParticleClusters(){
- unsigned long currentMillis=SDL_GetTicks();
-
- for(int i=0;i<PARTICLE_SYSTEM_MAX_PARTICLE_CLUSTERS;i++){
- if(particleClusters[i]!=NULL){
- if(currentMillis > particleClusters[i]->spawntimeMillis + particleClusters[i]->lifetimeMillis){
- delete particleClusters[i];
- particleClusters[i]=NULL;
- continue;
- }
- particleClusters[i]->move(); // THINKABOUTME: EIN delatT verwenden?
- }
- }
- }
-