Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8180 in orxonox.OLD for branches/atmospheric_engine/src/lib


Ignore:
Timestamp:
Jun 7, 2006, 8:03:04 AM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: ups, forgot that

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  
    5555
    5656        //load wind sound
    57         if (this->rainWindForce > 0) {
     57        if (this->rainWindForce != 0) {
    5858                if (this->windBuffer != NULL)
    5959                        ResourceManager::getInstance()->unload(this->windBuffer);
     
    8686        LoadParam(root, "life", this, RainEffect, setRainLife);
    8787        LoadParam(root, "wind", this, RainEffect, setRainWind);
     88        LoadParam(root, "startraining", this, RainEffect, setRainStart);
    8889
    8990        LOAD_PARAM_START_CYCLE(root, element);
     
    108109        this->rainMaxParticles = this->rainRate * this->rainLife;
    109110        this->rainWindForce  = 0;
     111        this->rainStartDuration = 0;
     112        this->localTimer = 0;
     113        this->soundRainVolume = 0.8f;
    110114
    111115        this->emitter = new PlaneEmitter(this->rainSize);
     
    144148        this->emitter->setSpread(this->rainWindForce / 50, 0.2);
    145149       
    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);
    149152
    150153        lightMan->setAmbientColor(.1,.1,.1);
     
    168171                this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z);
    169172        }
     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        }
    170192}
    171193
    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
     194void RainEffect::startRaining() {
     195        this->rainStartDuration = 10;
     196        // this->activate;
    181197}
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r8119 r8180  
    3939                inline void activateRain() { this->activate(); }
    4040                inline void deactivateRain() { this->deactivate(); }
     41                void startRaining();
    4142
    4243                inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
     
    4647                inline void setRainLife(float life) { this->rainLife = life; }
    4748                inline void setRainWind(int force) { this->rainWindForce = force; }
     49                inline void setRainStart(float duration) { this->rainStartDuration = duration; }
     50
    4851                inline void setRainOption(const std::string& option) {
    4952                        if (option == "moverain") this->rainMove = true;
     
    5154                }
    5255
    53                 void startRaining(float duration);
    5456
    5557        private:
    5658                static SparkParticles*                  rainParticles;
    5759                ParticleEmitter*                        emitter;
     60
     61                float                                   localTimer;
    5862
    5963                Vector                                  rainCoord;
     
    6468                GLfloat                                 rainMaxParticles;
    6569                int                                     rainWindForce;
     70                GLfloat                                 rainStartDuration;
    6671                bool                                    rainMove;
    6772                bool                                    rainActivate;
     
    7176                OrxSound::SoundBuffer*                  windBuffer;
    7277
     78                float                                   soundRainVolume;
     79
    7380                LightManager* lightMan;
    7481};
Note: See TracChangeset for help on using the changeset viewer.