Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8787 in orxonox.OLD


Ignore:
Timestamp:
Jun 26, 2006, 2:29:33 PM (18 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: activating rain effect changes the cloud- & skycolor

Location:
branches/atmospheric_engine/src/lib/graphics/effects
Files:
4 edited

Legend:

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

    r8781 r8787  
    2929#include "parser/tinyxml/tinyxml.h"
    3030
     31Vector  CloudEffect::cloudColor;
     32Vector  CloudEffect::skyColor;
    3133
    3234using namespace std;
     
    5355{
    5456  this->deactivate();
    55  
     57
    5658  if (glIsTexture(noise3DTexName))
    5759    glDeleteTextures(1, &noise3DTexName);
    58  
     60
    5961  delete shader;
    6062}
     
    6466{
    6567  PRINTF(0)("Initializing CloudEffect\n");
    66  
     68
    6769  this->offsetZ = 0;
    6870  this->animationSpeed = 2;
     
    7173  this->planetRadius = 1500;
    7274  this->divs = 50;
    73  
     75
    7476  this->skyColor = Vector(0.0f, 0.0f, 0.8f);
    7577  this->cloudColor = Vector(0.8f, 0.8f, 0.8f);
    7678
    77   noise3DTexSize = 128;
    78   noise3DTexName = 0;
     79  this->noise3DTexSize = 128;
     80  this->noise3DTexName = 0;
    7981
    8082  this->make3DNoiseTexture();
     
    9294               noise3DTexSize, noise3DTexSize, noise3DTexSize,
    9395               0, GL_RGBA, GL_UNSIGNED_BYTE, noise3DTexPtr);
    94  
     96
    9597  this->skydome = new Skydome();
    9698  this->skydome->setTexture(noise3DTexName);
    97  
    98   shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
    99                       ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
     99
     100  this->shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
     101                            ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
    100102
    101103  this->shader->activateShader();
    102104
    103105  Shader::Uniform(shader, "Noise").set(0);
    104  
    105   offset = new Shader::Uniform(shader, "Offset");
    106   skycolor = new Shader::Uniform(shader, "SkyColor");
    107   cloudcolor = new Shader::Uniform(shader, "CloudColor");
     106
     107  this->offset = new Shader::Uniform(shader, "Offset");
     108  this->skycolor = new Shader::Uniform(shader, "SkyColor");
     109  this->cloudcolor = new Shader::Uniform(shader, "CloudColor");
    108110
    109111  this->shader->deactivateShader();
    110  
     112
    111113  this->skydome->setShader(shader);
    112114}
     
    121123  LoadParam(root, "cloudcolor", this, CloudEffect, setCloudColor);
    122124  LoadParam(root, "skycolor", this, CloudEffect, setSkyColor);
    123  
     125
    124126  LoadParam(root, "planetRadius", this, CloudEffect, setPlanetRadius);
    125127  LoadParam(root, "atmosphericRadius", this, CloudEffect, setAtmosphericRadius);
    126128  LoadParam(root, "divisions", this, CloudEffect, setDivisions);
    127  
     129
    128130  LOAD_PARAM_START_CYCLE(root, element);
    129131  {
     
    137139{
    138140  PRINTF(0)( "Activating\n");
    139  
     141
    140142  // Can only be set after the loadParams call
    141143  this->shader->activateShader();
     
    144146  this->cloudcolor->set(cloudColor.x, cloudColor.y, cloudColor.z);
    145147  this->shader->deactivateShader();
    146  
    147   skydome->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1);
     148
     149  this->skydome->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1);
    148150
    149151  this->cloudActivate = true;
     
    158160
    159161void CloudEffect::draw() const
    160 {
    161 }
     162  {}
    162163
    163164void CloudEffect::tick (float dt)
     
    166167  {
    167168    this->offsetZ += 0.05 * dt * this->animationSpeed;
    168    
     169
    169170    this->shader->activateShader();
    170     offset->set(0.0f, 0.0f, offsetZ);
     171    this->offset->set(0.0f, 0.0f, offsetZ);
     172    this->cloudcolor->set(this->cloudColor.x, this->cloudColor.y, this->cloudColor.z);
     173    this->skycolor->set(this->skyColor.x, this->skyColor.y, this->skyColor.z);
    171174    this->shader->deactivateShader();
    172175  }
     176}
     177
     178
     179void CloudEffect::changeSkyColor(Vector color)
     180{
     181  skyColor = color;
     182}
     183
     184
     185void CloudEffect::changeCloudColor(Vector color)
     186{
     187  cloudColor = color;
    173188}
    174189
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h

    r8781 r8787  
    4848  inline void activateCloud()
    4949  { this->activate(); }
    50  
     50
    5151  inline void deactivateCloud()
    5252  { this->deactivate(); }
    53  
     53
    5454  inline void setCloudOption(const std::string& option)
    5555  {
     
    5757      this->cloudActivate = true;
    5858  }
    59  
     59
    6060  inline void setAnimationSpeed(float speed)
    61   { this->animationSpeed = speed; }
     61{ this->animationSpeed = speed; }
    6262
    6363  inline void setCloudScale(float scale)
    6464  { this->scale = scale; }
    65  
     65
    6666  inline void setCloudColor(float colorX, float colorY, float colorZ)
    6767  { this->cloudColor = Vector(colorX, colorY, colorZ); }
    68  
     68
    6969  inline void setSkyColor(float colorX, float colorY, float colorZ)
    7070  { this->skyColor = Vector(colorX, colorY, colorZ); }
    71  
     71
    7272  inline void setPlanetRadius(float planetRadius)
    7373  { this->planetRadius = planetRadius; }
    74  
     74
    7575  inline void setAtmosphericRadius(float atmosphericRadius)
    7676  { this->atmosphericRadius = atmosphericRadius; }
    77  
     77
    7878  inline void setDivisions(int divs)
    7979  { this->divs = divs; }
    80  
     80
    8181  virtual void draw() const;
    8282  virtual void tick(float dt);
     83
     84  static void changeSkyColor(Vector color);
     85  static void changeCloudColor(Vector color);
    8386 
    84  
     87  static Vector    cloudColor;
     88  static Vector    skyColor;
    8589
    8690  void make3DNoiseTexture();
     
    97101  bool             cloudActivate;
    98102  float            animationSpeed;
    99   Vector           cloudColor;
    100   Vector           skyColor;
    101103
    102104  // Material                 cloudMaterial;
    103105  Skydome*         skydome;
    104  
     106
    105107  // SHADER STUFF
    106108  Shader*          shader;
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r8771 r8787  
    2626#include "shell_command.h"
    2727#include "light.h"
     28#include "cloud_effect.h"
    2829
    2930#include "parser/tinyxml/tinyxml.h"
     
    101102  this->rainFadeInDuration = 0;
    102103  this->rainFadeOutDuration = 0;
     104 
     105  this->cloudColor = Vector(0.8f, 0.8f, 0.8f);
     106  this->skyColor = Vector(0.0f, 0.0f, 0.0f);
    103107
    104108  this->rainMaxParticles = this->rainRate * this->rainLife;
     
    127131  LoadParam(root, "fadeinduration", this, RainEffect, setRainFadeIn);
    128132  LoadParam(root, "fadeoutduration", this, RainEffect, setRainFadeOut);
     133  LoadParam(root, "cloudcolor", this, RainEffect, setCloudColor);
     134  LoadParam(root, "skycolor", this, RainEffect, setSkyColor);
    129135
    130136  LOAD_PARAM_START_CYCLE(root, element);
     
    177183  if (this->rainFadeInDuration == 0)
    178184    lightMan->setAmbientColor(.1,.1,.1);
     185 
     186  // Change the cloudcolor,skycolor
     187  this->oldCloudColor = CloudEffect::cloudColor;
     188  this->oldSkyColor = CloudEffect::skyColor;
     189  CloudEffect::changeCloudColor(this->cloudColor);
     190  CloudEffect::changeSkyColor(this->skyColor);
    179191}
    180192
     
    194206  // Restore Light Ambient
    195207  lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient);
     208 
     209  CloudEffect::changeCloudColor(this->oldCloudColor);
     210  CloudEffect::changeSkyColor(this->oldSkyColor);
    196211}
    197212
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r8771 r8787  
    1818class PlainEmitter;
    1919class LightManager;
     20class CloudEffect;
    2021
    2122#include "sound_buffer.h"
     
    8586    this->rainFadeOutDuration = fadeout;
    8687  }
     88 
     89  inline void setCloudColor(float colorX, float colorY, float colorZ)
     90  {
     91    this->cloudColor = Vector(colorX, colorY, colorZ);
     92  }
     93  inline void setSkyColor(float colorX, float colorY, float colorZ)
     94  {
     95    this->skyColor = Vector(colorX, colorY, colorZ);
     96  }
    8797
    8898  inline void setRainOption(const std::string& option)
     
    122132  LightManager*               lightMan;
    123133  GLfloat                     rainAmbient;
     134 
     135  Vector oldSkyColor;
     136  Vector oldCloudColor;
     137  Vector skyColor;
     138  Vector cloudColor;
    124139
    125140};
Note: See TracChangeset for help on using the changeset viewer.