Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8837 in orxonox.OLD


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

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

Location:
branches/mountain_lake/src/lib/graphics/effects
Files:
3 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
  • branches/mountain_lake/src/lib/graphics/effects/cloud_effect.h

    r8793 r8837  
    3131#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
    3232#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
     33
     34// FORWARD DECLARATION
     35template <class T> class tAnimation;
    3336
    3437
     
    8285  virtual void tick(float dt);
    8386
    84   static void changeSkyColor(Vector color);
    85   static void changeCloudColor(Vector color);
     87  static void changeSkyColor(Vector color, float time);
     88  static void changeCloudColor(Vector color, float time);
     89 
     90  void setColorSkyX(float color);
     91  void setColorSkyY(float color);
     92  void setColorSkyZ(float color);
     93  void setColorCloudX(float color);
     94  void setColorCloudY(float color);
     95  void setColorCloudZ(float color);
    8696 
    8797  static Vector    cloudColor;
     
    101111  bool             cloudActivate;
    102112  float            animationSpeed;
    103   float            fadeTime;
    104113 
    105114  static Vector           newSkyColor;
     
    108117  // Material                 cloudMaterial;
    109118  Skydome*         skydome;
     119 
     120  tAnimation<CloudEffect>*  skyColorFadeX;
     121  tAnimation<CloudEffect>*  skyColorFadeY;
     122  tAnimation<CloudEffect>*  skyColorFadeZ;
     123  tAnimation<CloudEffect>*  cloudColorFadeX;
     124  tAnimation<CloudEffect>*  cloudColorFadeY;
     125  tAnimation<CloudEffect>*  cloudColorFadeZ;
     126  static bool fadeSky;
     127  static bool fadeCloud;
     128  static float fadeTime;
    110129
    111130  // SHADER STUFF
  • branches/mountain_lake/src/lib/graphics/effects/rain_effect.cc

    r8793 r8837  
    103103  this->rainFadeOutDuration = 0;
    104104 
    105   this->cloudColor = Vector(0.8f, 0.8f, 0.8f);
     105  this->cloudColor = Vector(0.6f, 0.6f, 0.6f);
    106106  this->skyColor = Vector(0.0f, 0.0f, 0.0f);
    107107
     
    180180  if (this->rainWindForce != 0)
    181181    this->soundSource.play(this->windBuffer, 0.1f * this->rainWindForce, true);
    182 
    183   if (this->rainFadeInDuration == 0)
    184     lightMan->setAmbientColor(.1,.1,.1);
    185182 
    186183  // Change the cloudcolor,skycolor
    187184  this->oldCloudColor = CloudEffect::cloudColor;
    188185  this->oldSkyColor = CloudEffect::skyColor;
    189   CloudEffect::changeCloudColor(this->cloudColor);
    190   CloudEffect::changeSkyColor(this->skyColor);
     186  CloudEffect::changeCloudColor(this->cloudColor, this->rainFadeInDuration);
     187  CloudEffect::changeSkyColor(this->skyColor, this->rainFadeInDuration);
    191188}
    192189
     
    207204  lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient);
    208205 
    209   CloudEffect::changeCloudColor(this->oldCloudColor);
    210   CloudEffect::changeSkyColor(this->oldSkyColor);
     206  CloudEffect::changeCloudColor(this->oldCloudColor, this->rainFadeOutDuration);
     207  CloudEffect::changeSkyColor(this->oldSkyColor, this->rainFadeOutDuration);
    211208}
    212209
     
    291288
    292289  if (!this->rainFadeInDuration > 0)
    293     this->rainFadeInDuration = 20;
     290    this->rainFadeInDuration = 10;
    294291
    295292  this->localTimer = 0;
     
    308305
    309306  if (!this->rainFadeOutDuration > 0)
    310     this->rainFadeOutDuration = 20;
     307    this->rainFadeOutDuration = 10;
    311308
    312309  this->localTimer = 0;
Note: See TracChangeset for help on using the changeset viewer.