Changeset 7652 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc
- Timestamp:
- May 17, 2006, 6:41:58 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc
r7646 r7652 20 20 21 21 #include "glincl.h" 22 // #include "debug.h" 23 22 #include "p_node.h" 24 23 #include "state.h" 25 24 #include "spark_particles.h" … … 37 36 RainEffect::RainEffect(const TiXmlElement* root) 38 37 { 39 38 this->setClassID(CL_RAIN_EFFECT, "RainEffect"); 40 39 41 if (root != NULL) 42 this->loadParams(root); 40 this->init(); 43 41 44 // this->soundSource.setSourceNode(this); 42 if (root != NULL) 43 this->loadParams(root); 45 44 46 47 48 49 45 //load sound 46 if (this->rainBuffer != NULL) 47 ResourceManager::getInstance()->unload(this->rainBuffer); 48 this->rainBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV); 50 49 51 this->init(); 52 53 this->activate(); 50 this->activate(); 54 51 } 55 52 56 53 RainEffect::~RainEffect() 57 54 { 58 55 this->deactivate(); 59 56 } 60 57 … … 63 60 WeatherEffect::loadParams(root); 64 61 62 LoadParam(root, "moverain", this, RainEffect, setMoveRain); 65 63 LoadParam(root, "coord", this, RainEffect, setRainCoord); 66 64 LoadParam(root, "size", this, RainEffect, setRainSize); 67 65 LoadParam(root, "rate", this, RainEffect, setRainRate); 68 66 LoadParam(root, "velocity", this, RainEffect, setRainVelocity); 67 LoadParam(root, "life", this, RainEffect, setRainLife); 69 68 } 70 69 … … 72 71 bool RainEffect::init() 73 72 { 74 this->emitter = new PlaneEmitter(this->rainSize); 73 //Default values 74 this->rainCoord = Vector(500, 500, 500); 75 this->rainSize = Vector2D(1000, 1000); 76 this->rainRate = 5000; 77 this->rainVelocity = -300; 78 this->rainLife = 2; 75 79 80 this->emitter = new PlaneEmitter(this->rainSize); 76 81 } 77 82 … … 81 86 bool RainEffect::activate() 82 87 { 83 PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f \n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity);88 PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f, moveRain: %s\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity, this->rainMove ? "true" : "false" ); 84 89 85 90 if (unlikely(RainEffect::rainParticles == NULL)) 86 91 { 87 RainEffect::rainParticles = new SparkParticles( 10000);92 RainEffect::rainParticles = new SparkParticles(50000); 88 93 RainEffect::rainParticles->setName("RainParticles"); 89 RainEffect::rainParticles->setLifeSpan( 2, 2);94 RainEffect::rainParticles->setLifeSpan(this->rainLife, 2); 90 95 RainEffect::rainParticles->setRadius(0.02, 0.02); 91 96 RainEffect::rainParticles->setRadius(0.01, 0.01); … … 98 103 99 104 this->emitter->setSystem(RainEffect::rainParticles); 100 101 // RainEffect::rainParticles->debug();102 105 103 106 this->emitter->setRelCoor(this->rainCoord); … … 115 118 bool RainEffect::deactivate() 116 119 { 117 120 PRINTF(0)("Deactivating RainEffect\n"); 118 121 119 122 this->emitter->setSystem(NULL); 120 123 } 121 124 122 125 void RainEffect::tick (float dt) 123 126 { 127 //float distance = (State::getCameraNode()->getAbsCoor() - rainCoord).len(); 128 129 // PRINTF(0)( "RainEffect, coords: %f, %f, %f\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z ); 124 130 131 //if (this->rainMove) { 132 //PRINTF(0)( "Moving Rain" ); 133 // this->rainCoord = State::getCameraNode()->getAbsCoor(); 134 // this->emitter->setRelCoor(this->rainCoord.x +150, this->rainCoord.y+700, this->rainCoord.z+150); 135 //} 125 136 }
Note: See TracChangeset
for help on using the changeset viewer.