Changeset 8787 in orxonox.OLD
- Timestamp:
- Jun 26, 2006, 2:29:33 PM (18 years ago)
- 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 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 -
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
r8781 r8787 48 48 inline void activateCloud() 49 49 { this->activate(); } 50 50 51 51 inline void deactivateCloud() 52 52 { this->deactivate(); } 53 53 54 54 inline void setCloudOption(const std::string& option) 55 55 { … … 57 57 this->cloudActivate = true; 58 58 } 59 59 60 60 inline void setAnimationSpeed(float speed) 61 61 { this->animationSpeed = speed; } 62 62 63 63 inline void setCloudScale(float scale) 64 64 { this->scale = scale; } 65 65 66 66 inline void setCloudColor(float colorX, float colorY, float colorZ) 67 67 { this->cloudColor = Vector(colorX, colorY, colorZ); } 68 68 69 69 inline void setSkyColor(float colorX, float colorY, float colorZ) 70 70 { this->skyColor = Vector(colorX, colorY, colorZ); } 71 71 72 72 inline void setPlanetRadius(float planetRadius) 73 73 { this->planetRadius = planetRadius; } 74 74 75 75 inline void setAtmosphericRadius(float atmosphericRadius) 76 76 { this->atmosphericRadius = atmosphericRadius; } 77 77 78 78 inline void setDivisions(int divs) 79 79 { this->divs = divs; } 80 80 81 81 virtual void draw() const; 82 82 virtual void tick(float dt); 83 84 static void changeSkyColor(Vector color); 85 static void changeCloudColor(Vector color); 83 86 84 87 static Vector cloudColor; 88 static Vector skyColor; 85 89 86 90 void make3DNoiseTexture(); … … 97 101 bool cloudActivate; 98 102 float animationSpeed; 99 Vector cloudColor;100 Vector skyColor;101 103 102 104 // Material cloudMaterial; 103 105 Skydome* skydome; 104 106 105 107 // SHADER STUFF 106 108 Shader* shader; -
branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc
r8771 r8787 26 26 #include "shell_command.h" 27 27 #include "light.h" 28 #include "cloud_effect.h" 28 29 29 30 #include "parser/tinyxml/tinyxml.h" … … 101 102 this->rainFadeInDuration = 0; 102 103 this->rainFadeOutDuration = 0; 104 105 this->cloudColor = Vector(0.8f, 0.8f, 0.8f); 106 this->skyColor = Vector(0.0f, 0.0f, 0.0f); 103 107 104 108 this->rainMaxParticles = this->rainRate * this->rainLife; … … 127 131 LoadParam(root, "fadeinduration", this, RainEffect, setRainFadeIn); 128 132 LoadParam(root, "fadeoutduration", this, RainEffect, setRainFadeOut); 133 LoadParam(root, "cloudcolor", this, RainEffect, setCloudColor); 134 LoadParam(root, "skycolor", this, RainEffect, setSkyColor); 129 135 130 136 LOAD_PARAM_START_CYCLE(root, element); … … 177 183 if (this->rainFadeInDuration == 0) 178 184 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); 179 191 } 180 192 … … 194 206 // Restore Light Ambient 195 207 lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient); 208 209 CloudEffect::changeCloudColor(this->oldCloudColor); 210 CloudEffect::changeSkyColor(this->oldSkyColor); 196 211 } 197 212 -
branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h
r8771 r8787 18 18 class PlainEmitter; 19 19 class LightManager; 20 class CloudEffect; 20 21 21 22 #include "sound_buffer.h" … … 85 86 this->rainFadeOutDuration = fadeout; 86 87 } 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 } 87 97 88 98 inline void setRainOption(const std::string& option) … … 122 132 LightManager* lightMan; 123 133 GLfloat rainAmbient; 134 135 Vector oldSkyColor; 136 Vector oldCloudColor; 137 Vector skyColor; 138 Vector cloudColor; 124 139 125 140 };
Note: See TracChangeset
for help on using the changeset viewer.