- Timestamp:
- Jun 7, 2006, 8:03:04 AM (18 years ago)
- Location:
- branches/atmospheric_engine/src/lib/graphics/effects
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc
r8119 r8180 55 55 56 56 //load wind sound 57 if (this->rainWindForce >0) {57 if (this->rainWindForce != 0) { 58 58 if (this->windBuffer != NULL) 59 59 ResourceManager::getInstance()->unload(this->windBuffer); … … 86 86 LoadParam(root, "life", this, RainEffect, setRainLife); 87 87 LoadParam(root, "wind", this, RainEffect, setRainWind); 88 LoadParam(root, "startraining", this, RainEffect, setRainStart); 88 89 89 90 LOAD_PARAM_START_CYCLE(root, element); … … 108 109 this->rainMaxParticles = this->rainRate * this->rainLife; 109 110 this->rainWindForce = 0; 111 this->rainStartDuration = 0; 112 this->localTimer = 0; 113 this->soundRainVolume = 0.8f; 110 114 111 115 this->emitter = new PlaneEmitter(this->rainSize); … … 144 148 this->emitter->setSpread(this->rainWindForce / 50, 0.2); 145 149 146 this->soundSource.loop(this->rainBuffer, 0.8f); 147 if (this->rainWindForce > 0) 148 this->soundSource.loop(this->windBuffer, 0.5f); 150 this->soundSource.loop(this->rainBuffer, this->soundRainVolume); 151 if (this->rainWindForce != 0) this->soundSource.loop(this->windBuffer, 0.1f * this->rainWindForce); 149 152 150 153 lightMan->setAmbientColor(.1,.1,.1); … … 168 171 this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z); 169 172 } 173 174 if (this->rainStartDuration != 0 && this->localTimer < this->rainStartDuration) { 175 this->localTimer += dt; 176 float progress = this->localTimer / this->rainStartDuration; 177 178 // use alpha in color to fade in 179 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1 180 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2 181 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2 * progress); // light grey 182 183 // increase radius for more "heavy" rain 184 RainEffect::rainParticles->setRadius(0, 0.03 * progress); 185 RainEffect::rainParticles->setRadius(0.2, 0.02 * progress); 186 RainEffect::rainParticles->setRadius(1, 0.01 * progress); 187 188 // increase sound volume 189 this->soundSource.loop(this->rainBuffer, this->soundRainVolume * progress); 190 191 } 170 192 } 171 193 172 /** 173 * Slowly starts rain 174 * @param duration duration of the fade in process in seconds 175 */ 176 void RainEffect::startRaining(float duration) 177 { 178 // use alpha in color to fade in 179 // increase radius for more "heavy" rain 180 // increase sound volume 194 void RainEffect::startRaining() { 195 this->rainStartDuration = 10; 196 // this->activate; 181 197 } -
branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h
r8119 r8180 39 39 inline void activateRain() { this->activate(); } 40 40 inline void deactivateRain() { this->deactivate(); } 41 void startRaining(); 41 42 42 43 inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); } … … 46 47 inline void setRainLife(float life) { this->rainLife = life; } 47 48 inline void setRainWind(int force) { this->rainWindForce = force; } 49 inline void setRainStart(float duration) { this->rainStartDuration = duration; } 50 48 51 inline void setRainOption(const std::string& option) { 49 52 if (option == "moverain") this->rainMove = true; … … 51 54 } 52 55 53 void startRaining(float duration);54 56 55 57 private: 56 58 static SparkParticles* rainParticles; 57 59 ParticleEmitter* emitter; 60 61 float localTimer; 58 62 59 63 Vector rainCoord; … … 64 68 GLfloat rainMaxParticles; 65 69 int rainWindForce; 70 GLfloat rainStartDuration; 66 71 bool rainMove; 67 72 bool rainActivate; … … 71 76 OrxSound::SoundBuffer* windBuffer; 72 77 78 float soundRainVolume; 79 73 80 LightManager* lightMan; 74 81 };
Note: See TracChangeset
for help on using the changeset viewer.