Changeset 8787 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
- Timestamp:
- Jun 26, 2006, 2:29:33 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
r8781 r8787 29 29 #include "parser/tinyxml/tinyxml.h" 30 30 31 Vector CloudEffect::cloudColor; 32 Vector CloudEffect::skyColor; 31 33 32 34 using namespace std; … … 53 55 { 54 56 this->deactivate(); 55 57 56 58 if (glIsTexture(noise3DTexName)) 57 59 glDeleteTextures(1, &noise3DTexName); 58 60 59 61 delete shader; 60 62 } … … 64 66 { 65 67 PRINTF(0)("Initializing CloudEffect\n"); 66 68 67 69 this->offsetZ = 0; 68 70 this->animationSpeed = 2; … … 71 73 this->planetRadius = 1500; 72 74 this->divs = 50; 73 75 74 76 this->skyColor = Vector(0.0f, 0.0f, 0.8f); 75 77 this->cloudColor = Vector(0.8f, 0.8f, 0.8f); 76 78 77 noise3DTexSize = 128;78 noise3DTexName = 0;79 this->noise3DTexSize = 128; 80 this->noise3DTexName = 0; 79 81 80 82 this->make3DNoiseTexture(); … … 92 94 noise3DTexSize, noise3DTexSize, noise3DTexSize, 93 95 0, GL_RGBA, GL_UNSIGNED_BYTE, noise3DTexPtr); 94 96 95 97 this->skydome = new Skydome(); 96 98 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"); 100 102 101 103 this->shader->activateShader(); 102 104 103 105 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"); 108 110 109 111 this->shader->deactivateShader(); 110 112 111 113 this->skydome->setShader(shader); 112 114 } … … 121 123 LoadParam(root, "cloudcolor", this, CloudEffect, setCloudColor); 122 124 LoadParam(root, "skycolor", this, CloudEffect, setSkyColor); 123 125 124 126 LoadParam(root, "planetRadius", this, CloudEffect, setPlanetRadius); 125 127 LoadParam(root, "atmosphericRadius", this, CloudEffect, setAtmosphericRadius); 126 128 LoadParam(root, "divisions", this, CloudEffect, setDivisions); 127 129 128 130 LOAD_PARAM_START_CYCLE(root, element); 129 131 { … … 137 139 { 138 140 PRINTF(0)( "Activating\n"); 139 141 140 142 // Can only be set after the loadParams call 141 143 this->shader->activateShader(); … … 144 146 this->cloudcolor->set(cloudColor.x, cloudColor.y, cloudColor.z); 145 147 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); 148 150 149 151 this->cloudActivate = true; … … 158 160 159 161 void CloudEffect::draw() const 160 { 161 } 162 {} 162 163 163 164 void CloudEffect::tick (float dt) … … 166 167 { 167 168 this->offsetZ += 0.05 * dt * this->animationSpeed; 168 169 169 170 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); 171 174 this->shader->deactivateShader(); 172 175 } 176 } 177 178 179 void CloudEffect::changeSkyColor(Vector color) 180 { 181 skyColor = color; 182 } 183 184 185 void CloudEffect::changeCloudColor(Vector color) 186 { 187 cloudColor = color; 173 188 } 174 189
Note: See TracChangeset
for help on using the changeset viewer.