Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9235 in orxonox.OLD for trunk/src/lib/graphics/effects


Ignore:
Timestamp:
Jul 5, 2006, 4:39:02 PM (18 years ago)
Author:
bensch
Message:

merged the presentation back

Location:
trunk/src/lib/graphics/effects
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/effects/cloud_effect.cc

    r9112 r9235  
    9090    this->planetRadius = 1500;
    9191    this->divs = 15;
     92    this->cloudActivate = false;
    9293    fadeSky = false;
    9394    fadeCloud = false;
  • trunk/src/lib/graphics/effects/fog_effect.cc

    r9112 r9235  
    2020#include "shell_command.h"
    2121#include "script_class.h"
     22#include "cloud_effect.h"
    2223
    2324// Define shell commands
    24 SHELL_COMMAND(activate, FogEffect, activateFog);
    25 SHELL_COMMAND(deactivate, FogEffect, deactivateFog);
     25//SHELL_COMMAND(activate, FogEffect, activateFog);
     26//SHELL_COMMAND(deactivate, FogEffect, deactivateFog);
    2627SHELL_COMMAND(fadein, FogEffect, fadeInFog);
    2728SHELL_COMMAND(fadeout, FogEffect, fadeOutFog);
     
    8485  this->fogFadeInActivate = false;
    8586  this->fogFadeOutActivate = false;
     87 
     88  this->cloudColor = Vector(0.2f, 0.3f, 0.3f);
     89  this->skyColor = Vector(0.2f, 0.3f, 0.3f);
    8690}
    8791
     
    9397    WeatherEffect::loadParams(root);
    9498
    95     LoadParam(root, "mode", this, FogEffect, setFogMode).describe("fog mode (linear, exponential)");;
    96     LoadParam(root, "density", this, FogEffect, setFogDensity).describe("fog density if exp. fog");;
    97     LoadParam(root, "range", this, FogEffect, setFogRange).describe("fog range: start, end");;
    98     LoadParam(root, "color", this, FogEffect, setFogColor).describe("fog color: r,g,b");;
    99     LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn).describe("duration of the fade in");;
    100     LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut).describe("duration of the fade out");;
    101 
     99    LoadParam(root, "mode", this, FogEffect, setFogMode).describe("fog mode (linear, exponential)");
     100    LoadParam(root, "density", this, FogEffect, setFogDensity).describe("fog density if exp. fog");
     101    LoadParam(root, "range", this, FogEffect, setFogRange).describe("fog range: start, end");
     102    LoadParam(root, "color", this, FogEffect, setFogColor).describe("fog color: r,g,b");
     103    LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn).describe("duration of the fade in");
     104    LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut).describe("duration of the fade out");
     105    LoadParam(root, "cloudcolor", this, FogEffect, setCloudColor);
     106    LoadParam(root, "skycolor", this, FogEffect, setSkyColor);
     107   
    102108    LOAD_PARAM_START_CYCLE(root, element);
    103109    {
    104       LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption).describe("sets a fog option: activate");;
     110      LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption).describe("sets a fog option: activate");
    105111    }
    106112    LOAD_PARAM_END_CYCLE(element);
     
    125131
    126132    glEnable(GL_FOG);
     133   
     134    // Store cloud- and sky color before the snow
     135    this->oldCloudColor = CloudEffect::cloudColor;
     136    this->oldSkyColor   = CloudEffect::skyColor;
     137   
     138    // Change the colors
     139    CloudEffect::changeCloudColor(this->cloudColor, this->fogFadeInDuration);
     140    CloudEffect::changeSkyColor(this->skyColor, this->fogFadeInDuration);
    127141}
    128142
     
    184198
    185199        if ( this->fogMode == GL_LINEAR)
    186           this->fogFadeEnd = 2000 * ( this->localTimer / this->fogFadeInDuration ) + this->fogEnd;
     200          this->fogFadeEnd = 2000 * ( this->localTimer / this->fogFadeOutDuration ) + this->fogEnd;
    187201        else
    188             this->fogFadeDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity);
     202            this->fogFadeDensity = 1 - (( this->localTimer / this->fogFadeOutDuration ) * this->fogDensity);
    189203
    190204        if ( this->localTimer >= this->fogFadeOutDuration )
     
    207221    // If no manual FadeIn value was set, set a default value
    208222    if (!this->fogFadeInDuration > 0)
    209         this->fogFadeInDuration = 20;
     223        this->fogFadeInDuration = 10;
    210224
    211225    // Reset local timer
     
    227241    this->fogFadeInActivate = false;
    228242
     243   
    229244    // If Fog is off, turn it on first
    230245    if (!this->fogActivate)
     
    233248    // If no manual FadeOut value was set, set a default value
    234249    if (!this->fogFadeOutDuration > 0)
    235         this->fogFadeOutDuration = 20;
     250        this->fogFadeOutDuration = 10;
    236251
    237252    // set FogFadeOut activate
     
    240255    // Reset local timer
    241256    this->localTimer = 0;
    242 }
    243 
     257
     258    // Restore the old cloud- and sky color
     259    CloudEffect::changeCloudColor(this->oldCloudColor, this->fogFadeOutDuration);
     260    CloudEffect::changeSkyColor(this->oldSkyColor, this->fogFadeOutDuration);
     261}
     262
  • trunk/src/lib/graphics/effects/fog_effect.h

    r8793 r9235  
    1010#include "glincl.h"
    1111#include "vector.h"
     12
     13class CloudEffect;
    1214
    1315class FogEffect : public WeatherEffect
     
    7375      this->fogActivate = true;
    7476  }
     77 
     78  inline void setCloudColor(float colorX, float colorY, float colorZ)
     79  {
     80    this->cloudColor = Vector(colorX, colorY, colorZ);
     81  }
     82  inline void setSkyColor(float colorX, float colorY, float colorZ)
     83  {
     84    this->skyColor = Vector(colorX, colorY, colorZ);
     85  }
    7586
    7687  void fadeInFog();
     
    109120  Vector        colorVector;
    110121  float         localTimer;
     122 
     123  Vector oldSkyColor;
     124  Vector oldCloudColor;
     125  Vector skyColor;
     126  Vector cloudColor;
    111127};
    112128
  • trunk/src/lib/graphics/effects/lightning_effect.cc

    r9112 r9235  
    112112    }
    113113
     114    //should load both texture
    114115    this->thunderTextureA = true;
    115116    this->setTexture();
     117    this->switchTexture();
    116118
    117119    if (this->lightningMove) {
  • trunk/src/lib/graphics/effects/rain_effect.cc

    r9112 r9235  
    3434
    3535// Define shell commands
    36 SHELL_COMMAND(activate, RainEffect, activateRain);
    37 SHELL_COMMAND(deactivate, RainEffect, deactivateRain);
     36//SHELL_COMMAND(activate, RainEffect, activateRain);
     37//SHELL_COMMAND(deactivate, RainEffect, deactivateRain);
    3838SHELL_COMMAND(startraining, RainEffect, startRaining);
    3939SHELL_COMMAND(stopraining, RainEffect, stopRaining);
     
    9696 */
    9797void RainEffect::init() {
     98
     99    this->rainParticles = NULL;
     100    this->emitter = NULL;
     101    this->rainBuffer = NULL;
     102    this->windBuffer = NULL;
     103    this->lightMan = NULL;
     104
    98105    //Default values
    99106    this->rainActivate = false;
     
    119126    this->emitter = new PlaneEmitter(this->rainSize);
    120127
     128    lightMan = LightManager::getInstance();
    121129}
    122130
     
    187195    // If we're not fading, change color immediately
    188196    if (!this->rainFadeInActivate || !this->rainFadeOutActivate) {
    189         CloudEffect::changeCloudColor(this->cloudColor, 0);
    190         CloudEffect::changeSkyColor(this->skyColor, 0);
    191     }
     197        CloudEffect::changeCloudColor(this->cloudColor, 0.2);
     198        CloudEffect::changeSkyColor(this->skyColor, 0.2);
     199    }
     200
     201    //lightMan->setAmbientColor(.1,.1,.1);
    192202}
    193203
     
    202212    this->rainFadeOutActivate = false;
    203213
    204     this->emitter->setSystem(NULL);
     214    //if(this->emitter)
     215    //  this->emitter->setSystem(NULL);
     216    //this->hideRain();
    205217
    206218    // Stop Sound
     
    208220
    209221    // Restore the old cloud- and sky color
    210     CloudEffect::changeCloudColor(this->oldCloudColor, 0);
    211     CloudEffect::changeSkyColor(this->oldSkyColor, 0);
     222    CloudEffect::changeCloudColor(this->oldCloudColor, 0.2);
     223    CloudEffect::changeSkyColor(this->oldSkyColor, 0.2);
    212224}
    213225
     
    242254
    243255        // increase sound volume
    244         if (!this->soundSource.isPlaying())
     256        if (progress > 0.5) {
     257          if (!this->soundSource.isPlaying())
    245258            this->soundSource.play(this->rainBuffer, this->soundRainVolume, true);
    246         this->soundSource.gain(this->rainBuffer, this->soundRainVolume * progress);
     259          this->soundSource.gain(this->rainBuffer, this->soundRainVolume * progress * 2 - 0.5);
     260        }
    247261
    248262        if (progress >= 1)
    249263            this->rainFadeInActivate = false;
     264
     265        lightMan->setAmbientColor(1-progress, 1-progress, 1-progress);
    250266    }
    251267
     
    276292            this->deactivate();
    277293        }
     294        lightMan->setAmbientColor(1-progress, 1-progress, 1-progress);
    278295    }
    279296}
  • trunk/src/lib/graphics/effects/rain_effect.h

    r9006 r9235  
    132132  float                       soundRainVolume;
    133133
    134   Vector oldSkyColor;
    135   Vector oldCloudColor;
    136   Vector skyColor;
    137   Vector cloudColor;
     134  Vector                      oldSkyColor;
     135  Vector                      oldCloudColor;
     136  Vector                      skyColor;
     137  Vector                      cloudColor;
     138 
     139  LightManager*               lightMan;
    138140
    139141};
  • trunk/src/lib/graphics/effects/snow_effect.cc

    r9112 r9235  
    2828#include "shell_command.h"
    2929#include "script_class.h"
     30#include "cloud_effect.h"
    3031
    3132#include "parser/tinyxml/tinyxml.h"
     
    5354
    5455        //load wind sound
    55         if (this->snowWindForce > 1) {
     56        if (this->snowWindForce >= 1) {
    5657                if (this->windBuffer != NULL)
    5758                        ResourceManager::getInstance()->unload(this->windBuffer);
    58                         this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
     59          this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
    5960        }
    6061
     
    8788        LoadParam(root, "size", this, SnowEffect, size);
    8889        LoadParam(root, "coord", this, SnowEffect, coord);
     90  LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor);
     91  LoadParam(root, "skycolor", this, SnowEffect, setSkyColor);
     92  LoadParam(root, "fadetime", this, SnowEffect, setFadeTime);
    8993
    9094        LOAD_PARAM_START_CYCLE(root, element);
     
    119123        this->snowCoord = Vector(100,450,400);
    120124        this->snowWindForce = 1;
     125 
     126  this->fadeTime = 10;
     127  this->cloudColor = Vector(0.2f, 0.2f, 0.2f);
     128  this->skyColor = Vector(0.0f, 0.0f, 0.0f);
    121129}
    122130
     
    149157  if (this->snowWindForce != 0)
    150158    this->soundSource.play(this->windBuffer, 0.1f * this->snowWindForce, true);
     159 
     160  // Store cloud- and sky color before the snow
     161  this->oldCloudColor = CloudEffect::cloudColor;
     162  this->oldSkyColor   = CloudEffect::skyColor;
     163
     164  // Change the colors
     165  CloudEffect::changeCloudColor(this->cloudColor, this->fadeTime);
     166  CloudEffect::changeSkyColor(this->skyColor, this->fadeTime);
    151167
    152168}
     
    162178        if (this->windBuffer != NULL)
    163179                ResourceManager::getInstance()->unload(this->windBuffer);
     180 
     181  // Restore the old cloud- and sky color
     182  CloudEffect::changeCloudColor(this->oldCloudColor, this->fadeTime);
     183  CloudEffect::changeSkyColor(this->oldSkyColor, this->fadeTime);
    164184}
    165185
  • trunk/src/lib/graphics/effects/snow_effect.h

    r8495 r9235  
    1616class PlaneEmitter;
    1717class PNode;
     18class CloudEffect;
    1819
    1920#include "sound_source.h"
     
    7778        this->snowWindForce = force;
    7879    }
     80    inline void setCloudColor(float colorX, float colorY, float colorZ)
     81    {
     82      this->cloudColor = Vector(colorX, colorY, colorZ);
     83    }
     84    inline void setSkyColor(float colorX, float colorY, float colorZ)
     85    {
     86      this->skyColor = Vector(colorX, colorY, colorZ);
     87    }
     88    inline void setFadeTime(float time)
     89    {
     90      this->fadeTime = time;
     91    }
    7992
    8093    inline void setSnowOption(const std::string& option) {
     
    97110    float         angle, randomAngle;
    98111    float         alpha;
     112    float         fadeTime;
    99113    Vector        snowCoord;
    100114    Vector2D      snowSize;
     
    110124    OrxSound::SoundBuffer*    windBuffer;
    111125
     126    Vector oldSkyColor;
     127    Vector oldCloudColor;
     128    Vector skyColor;
     129    Vector cloudColor;
    112130};
    113131
Note: See TracChangeset for help on using the changeset viewer.