Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.