Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 27, 2006, 5:26:04 PM (19 years ago)
Author:
hdavid
Message:

branches/mountain_lake: fading sky/cloud colors works, RainEffect::stopRaining is a bit buggy

File:
1 edited

Legend:

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

    r8793 r8837  
    2626#include "shader.h"
    2727#include "shell_command.h"
     28#include "t_animation.h"
    2829
    2930#include "parser/tinyxml/tinyxml.h"
     
    3435Vector  CloudEffect::newSkyColor;
    3536
     37bool CloudEffect::fadeSky;
     38bool CloudEffect::fadeCloud;
     39float CloudEffect::fadeTime;
     40
    3641using namespace std;
    3742
     
    6873{
    6974  PRINTF(0)("Initializing CloudEffect\n");
    70 
     75 
    7176  this->offsetZ = 0;
    7277  this->animationSpeed = 2;
     
    7580  this->planetRadius = 1500;
    7681  this->divs = 50;
     82  fadeSky = false;
     83  fadeCloud = false;
    7784
    7885  skyColor = Vector(0.0f, 0.0f, 0.8f);
     
    8087  newSkyColor = skyColor;
    8188  newCloudColor = cloudColor;
    82   this->fadeTime = 3;
    8389
    8490  this->noise3DTexSize = 128;
     
    176182    this->offset->set(0.0f, 0.0f, offsetZ);
    177183   
    178     //if(cloudColor != newCloudColor)
    179     //{
    180       // TODO: fade from cloudColor to newCloudColor
    181       cloudColor = newCloudColor;
     184    if(cloudColor != newCloudColor)
     185    {
     186      if(fadeCloud)
     187      {
     188        this->cloudColorFadeX = new tAnimation<CloudEffect>(this, &CloudEffect::setColorCloudX);
     189        this->cloudColorFadeX->setInfinity(ANIM_INF_CONSTANT);
     190        this->cloudColorFadeY = new tAnimation<CloudEffect>(this, &CloudEffect::setColorCloudY);
     191        this->cloudColorFadeY->setInfinity(ANIM_INF_CONSTANT);
     192        this->cloudColorFadeZ = new tAnimation<CloudEffect>(this, &CloudEffect::setColorCloudZ);
     193        this->cloudColorFadeZ->setInfinity(ANIM_INF_CONSTANT);
     194       
     195        this->cloudColorFadeX->addKeyFrame(cloudColor.x, fadeTime, ANIM_LINEAR);
     196        this->cloudColorFadeX->addKeyFrame(newCloudColor.x, 0, ANIM_LINEAR);
     197 
     198        this->cloudColorFadeY->addKeyFrame(cloudColor.y, fadeTime, ANIM_LINEAR);
     199        this->cloudColorFadeY->addKeyFrame(newCloudColor.y, 0, ANIM_LINEAR);
     200 
     201        this->cloudColorFadeZ->addKeyFrame(cloudColor.z, fadeTime, ANIM_LINEAR);
     202        this->cloudColorFadeZ->addKeyFrame(newCloudColor.z, 0, ANIM_LINEAR);
     203       
     204        fadeCloud = false;
     205       
     206        this->cloudColorFadeX->replay();
     207        this->cloudColorFadeY->replay();
     208        this->cloudColorFadeZ->replay();
     209      }
     210     
    182211      this->cloudcolor->set(this->cloudColor.x, this->cloudColor.y, this->cloudColor.z);
    183     //}
    184     //if(cloudColor != newCloudColor)
    185     //{
    186       // TODO: fade from skyColor to newSkyColor
    187       skyColor = newSkyColor;
     212    }
     213
     214    if(skyColor != newSkyColor)
     215    {
     216      if(fadeSky)
     217      {
     218        this->skyColorFadeX = new tAnimation<CloudEffect>(this, &CloudEffect::setColorSkyX);
     219        this->skyColorFadeX->setInfinity(ANIM_INF_CONSTANT);
     220        this->skyColorFadeY = new tAnimation<CloudEffect>(this, &CloudEffect::setColorSkyY);
     221        this->skyColorFadeY->setInfinity(ANIM_INF_CONSTANT);
     222        this->skyColorFadeZ = new tAnimation<CloudEffect>(this, &CloudEffect::setColorSkyZ);
     223        this->skyColorFadeZ->setInfinity(ANIM_INF_CONSTANT);
     224       
     225        this->skyColorFadeX->addKeyFrame(skyColor.x, fadeTime, ANIM_LINEAR);
     226        this->skyColorFadeX->addKeyFrame(newSkyColor.x, 0, ANIM_LINEAR);
     227 
     228        this->skyColorFadeY->addKeyFrame(skyColor.y, fadeTime, ANIM_LINEAR);
     229        this->skyColorFadeY->addKeyFrame(newSkyColor.y, 0, ANIM_LINEAR);
     230 
     231        this->skyColorFadeZ->addKeyFrame(skyColor.z, fadeTime, ANIM_LINEAR);
     232        this->skyColorFadeZ->addKeyFrame(newSkyColor.z, 0, ANIM_LINEAR);
     233       
     234        fadeSky = false;
     235       
     236        this->skyColorFadeX->replay();
     237        this->skyColorFadeY->replay();
     238        this->skyColorFadeZ->replay();
     239      }
     240     
    188241      this->skycolor->set(this->skyColor.x, this->skyColor.y, this->skyColor.z);
    189     //}
     242    }
    190243   
    191244    this->shader->deactivateShader();
     
    194247
    195248
    196 void CloudEffect::changeSkyColor(Vector color)
     249void CloudEffect::setColorSkyX(float color)
     250{
     251  skyColor.x = color;
     252}
     253void CloudEffect::setColorSkyY(float color)
     254{
     255  skyColor.y = color;
     256}
     257void CloudEffect::setColorSkyZ(float color)
     258{
     259  skyColor.z = color;
     260}
     261void CloudEffect::setColorCloudX(float color)
     262{
     263  cloudColor.x = color;
     264}
     265void CloudEffect::setColorCloudY(float color)
     266{
     267  cloudColor.y = color;
     268}
     269void CloudEffect::setColorCloudZ(float color)
     270{
     271  cloudColor.z = color;
     272}
     273
     274void CloudEffect::changeSkyColor(Vector color, float time)
    197275{
    198276  newSkyColor = color;
    199 }
    200 
    201 
    202 void CloudEffect::changeCloudColor(Vector color)
     277  fadeSky = true;
     278  fadeTime = time;
     279}
     280
     281
     282void CloudEffect::changeCloudColor(Vector color, float time)
    203283{
    204284  newCloudColor = color;
     285  fadeCloud = true;
     286  fadeTime = time;
    205287}
    206288
Note: See TracChangeset for help on using the changeset viewer.