Changeset 9406 in orxonox.OLD for trunk/src/lib/graphics/effects
- Timestamp:
- Jul 24, 2006, 11:09:47 AM (18 years ago)
- Location:
- trunk/src/lib/graphics/effects
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/effects/atmospheric_engine.cc
r8495 r9406 25 25 26 26 27 using namespace std; 27 28 28 29 29 /** … … 116 116 std::list<BaseObject*>::const_iterator it; 117 117 for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) { 118 /* printf("%s::%s \n", (*it)->getClass Name(), (*it)->getName());*/118 /* printf("%s::%s \n", (*it)->getClassCName(), (*it)->getName());*/ 119 119 dynamic_cast<WeatherEffect*>(*it)->tick(dt); 120 120 } -
trunk/src/lib/graphics/effects/cloud_effect.cc
r9235 r9406 40 40 float CloudEffect::fadeTime; 41 41 42 using namespace std; 42 43 43 44 44 SHELL_COMMAND(activate, CloudEffect, activateCloud); -
trunk/src/lib/graphics/effects/fog_effect.cc
r9235 r9406 28 28 SHELL_COMMAND(fadeout, FogEffect, fadeOutFog); 29 29 30 using namespace std; 30 31 31 32 32 CREATE_SCRIPTABLE_CLASS(FogEffect, CL_FOG_EFFECT, -
trunk/src/lib/graphics/effects/graphics_effect.cc
r8495 r9406 23 23 24 24 25 using namespace std; 25 26 26 27 27 -
trunk/src/lib/graphics/effects/lense_flare.cc
r9006 r9406 34 34 35 35 36 using namespace std; 36 37 37 38 38 -
trunk/src/lib/graphics/effects/lightning_effect.cc
r9235 r9406 34 34 SHELL_COMMAND(deactivate, LightningEffect, deactivateLightning); 35 35 36 using namespace std; 36 37 37 38 38 CREATE_SCRIPTABLE_CLASS(LightningEffect, CL_LIGHTNING_EFFECT, … … 130 130 131 131 //load sound 132 if (this->thunderBuffer != NULL)133 ResourceManager::getInstance()->unload(this->thunderBuffer);134 132 this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/thunder.wav", WAV); 135 133 -
trunk/src/lib/graphics/effects/rain_effect.cc
r9235 r9406 39 39 SHELL_COMMAND(stopraining, RainEffect, stopRaining); 40 40 41 using namespace std; 41 42 42 43 43 CREATE_SCRIPTABLE_CLASS(RainEffect, CL_RAIN_EFFECT, -
trunk/src/lib/graphics/effects/snow_effect.cc
r9235 r9406 1 1 /* 2 3 4 5 6 7 8 9 2 orxonox - the future of 3D-vertical-scrollers 3 4 Copyright (C) 2004 orx 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: hdavid, amaechler 13 13 */ 14 14 … … 35 35 SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow); 36 36 37 using namespace std;38 37 39 38 CREATE_SCRIPTABLE_CLASS(SnowEffect, CL_SNOW_EFFECT, … … 46 45 SnowEffect::SnowEffect(const TiXmlElement* root) 47 46 { 48 this->setClassID(CL_SNOW_EFFECT, "SnowEffect"); 49 50 this->init(); 51 52 if (root != NULL) 53 this->loadParams(root); 54 55 //load wind sound 56 if (this->snowWindForce >= 1) { 57 if (this->windBuffer != NULL) 58 ResourceManager::getInstance()->unload(this->windBuffer); 59 this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV); 60 } 47 this->setClassID(CL_SNOW_EFFECT, "SnowEffect"); 48 49 this->init(); 50 51 if (root != NULL) 52 this->loadParams(root); 53 54 this->windBuffer = NULL; 55 //load wind sound 56 if (this->snowWindForce >= 1) { 57 this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV); 58 } 61 59 62 60 if(snowActivate) { 63 61 this->activate(); 64 62 SnowEffect::snowParticles->precache((int) this->snowLife); 65 63 } … … 69 67 SnowEffect::~SnowEffect() 70 68 { 71 69 this->deactivate(); 72 70 } 73 71 … … 76 74 void SnowEffect::loadParams(const TiXmlElement* root) 77 75 { 78 79 80 81 82 83 84 85 86 87 88 89 76 WeatherEffect::loadParams(root); 77 78 LoadParam(root, "numParticles", this, SnowEffect, numParticles); 79 LoadParam(root, "materialTexture", this, SnowEffect, materialTexture); 80 LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan); 81 LoadParam(root, "radius", this, SnowEffect, radius); 82 LoadParam(root, "mass", this, SnowEffect, mass); 83 LoadParam(root, "emissionRate", this, SnowEffect, emissionRate); 84 LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity); 85 LoadParam(root, "wind", this, SnowEffect, wind); 86 LoadParam(root, "size", this, SnowEffect, size); 87 LoadParam(root, "coord", this, SnowEffect, coord); 90 88 LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor); 91 89 LoadParam(root, "skycolor", this, SnowEffect, setSkyColor); 92 90 LoadParam(root, "fadetime", this, SnowEffect, setFadeTime); 93 91 94 95 96 97 98 92 LOAD_PARAM_START_CYCLE(root, element); 93 { 94 LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption); 95 } 96 LOAD_PARAM_END_CYCLE(element); 99 97 } 100 98 101 99 void SnowEffect::init() 102 100 { 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 101 this->emitter = new PlaneEmitter(); 102 103 // Default values 104 this->snowActivate = false; 105 this->snowMove = false; 106 this->particles = 12000; 107 this->texture = "maps/snow_flake_01_32x32.png"; 108 this->snowLife = 8; 109 this->randomLife = 2; 110 this->snowRadius = 3.5; 111 this->randomRadius = 1; 112 this->snowMass = 1.0; 113 this->randomMass = 0.3; 114 this->rate = 900; 115 this->velocity = -100; 116 this->randomVelocity = 5; 117 this->angle = 0.5; 118 this->randomAngle = 0.2; 119 this->alpha = 0.5; 120 this->snowSize = Vector2D(2500, 2500); 121 this->snowCoord = Vector(100,450,400); 122 this->snowWindForce = 1; 123 126 124 this->fadeTime = 10; 127 125 this->cloudColor = Vector(0.2f, 0.2f, 0.2f); … … 131 129 void SnowEffect::activate() 132 130 { 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 131 PRINTF(3)("Activating SnowEffect\n"); 132 133 this->snowActivate = true; 134 135 SnowEffect::snowParticles = new SpriteParticles(particles); 136 SnowEffect::snowParticles->setName("SnowEffectTrailParticles"); 137 SnowEffect::snowParticles->setMaterialTexture(texture); 138 SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife); 139 SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius); 140 SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8); 141 SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5); 142 SnowEffect::snowParticles->setMass(0, snowMass, randomMass); 143 SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha); 144 SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2); 145 SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0); 146 147 this->emitter->setSystem(SnowEffect::snowParticles); 148 149 this->emitter->setRelCoor(snowCoord); 150 this->emitter->setEmissionRate(rate); 151 this->emitter->setEmissionVelocity(velocity, randomVelocity); 152 this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce); 153 this->emitter->setSize(snowSize); 156 154 157 155 if (this->snowWindForce != 0) 158 156 this->soundSource.play(this->windBuffer, 0.1f * this->snowWindForce, true); 159 157 160 158 // Store cloud- and sky color before the snow 161 159 this->oldCloudColor = CloudEffect::cloudColor; … … 171 169 void SnowEffect::deactivate() 172 170 { 173 174 175 176 177 178 179 180 171 PRINTF(3)("Deactivating SnowEffect\n"); 172 173 this->snowActivate = false; 174 this->emitter->setSystem(NULL); 175 176 if (this->windBuffer != NULL) 177 ResourceManager::getInstance()->unload(this->windBuffer); 178 181 179 // Restore the old cloud- and sky color 182 180 CloudEffect::changeCloudColor(this->oldCloudColor, this->fadeTime); … … 186 184 void SnowEffect::draw() const 187 185 { 188 189 186 if (!this->snowActivate) 187 return; 190 188 } 191 189 192 190 void SnowEffect::tick(float dt) 193 191 { 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 } 192 if (!this->snowActivate) 193 return; 194 195 /* 196 float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len(); 197 198 if(activated) 199 { 200 if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y) 201 this->deactivate(); 202 else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y) 203 this->alpha = 0.15; 204 else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y) 205 this->alpha = 0.25; 206 else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y) 207 this->alpha = 0.4; 208 209 SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha); 210 SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2); 211 SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0); 212 } 213 else 214 { 215 if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y ) 216 this->activate(); 217 if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y ) 218 this->alpha = 0.25; 219 else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y ) 220 this->alpha = 0.4; 221 else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y ) 222 this->alpha = 0.5; 223 224 SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha); 225 SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2); 226 SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0); 227 }*/ 228 229 if (this->snowMove) { 230 this->snowCoord = State::getCameraNode()->getAbsCoor(); 231 this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z); 232 } 233 } -
trunk/src/lib/graphics/effects/snow_effect.h
r9235 r9406 101 101 102 102 private: 103 int particles;103 int particles; 104 104 std::string texture; 105 float snowLife, randomLife;106 float snowRadius, randomRadius;107 float snowMass, randomMass;108 float rate;109 float velocity, randomVelocity;110 float angle, randomAngle;111 float alpha;112 float fadeTime;113 Vector snowCoord;114 Vector2D snowSize;115 int snowWindForce;105 float snowLife, randomLife; 106 float snowRadius, randomRadius; 107 float snowMass, randomMass; 108 float rate; 109 float velocity, randomVelocity; 110 float angle, randomAngle; 111 float alpha; 112 float fadeTime; 113 Vector snowCoord; 114 Vector2D snowSize; 115 int snowWindForce; 116 116 117 bool snowMove;118 bool snowActivate;117 bool snowMove; 118 bool snowActivate; 119 119 120 120 PlaneEmitter* emitter; 121 121 122 122 static SpriteParticles* snowParticles; 123 OrxSound::SoundSource soundSource;123 OrxSound::SoundSource soundSource; 124 124 OrxSound::SoundBuffer* windBuffer; 125 125 126 Vector oldSkyColor;127 Vector oldCloudColor;128 Vector skyColor;129 Vector cloudColor;126 Vector oldSkyColor; 127 Vector oldCloudColor; 128 Vector skyColor; 129 Vector cloudColor; 130 130 }; 131 131 -
trunk/src/lib/graphics/effects/sun_effect.cc
r8793 r9406 21 21 22 22 23 using namespace std; 23 24 24 25 25 -
trunk/src/lib/graphics/effects/volfog_effect.cc
r9006 r9406 47 47 48 48 49 using namespace std; 49 50 50 51 51 CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT); -
trunk/src/lib/graphics/effects/weather_effect.cc
r8495 r9406 21 21 22 22 23 using namespace std; 23 24 24 25 25
Note: See TracChangeset
for help on using the changeset viewer.