Index: branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc	(revision 8372)
+++ branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc	(revision 8373)
@@ -27,4 +27,5 @@
 SHELL_COMMAND(fadeout, FogEffect, fadeOutFog);
 
+// TODO: Fix fades
 
 using namespace std;
@@ -133,5 +134,4 @@
 		return;
 		
-
 	if (this->fogFadeInDuration > 0 && this->localTimer < this->fogFadeInDuration) {
 		this->localTimer += dt;
Index: branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc	(revision 8372)
+++ branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc	(revision 8373)
@@ -33,4 +33,6 @@
 CREATE_FACTORY(LighteningEffect, CL_LIGHTENING_EFFECT);
 
+// TODO: FIx Lightening with Fog enabled
+
 LighteningEffect::LighteningEffect(const TiXmlElement* root)
 {
@@ -42,6 +44,6 @@
 		this->loadParams(root);
 
-  if(this->lighteningActivate)
-	 this->activate();
+	if(this->lighteningActivate)
+		this->activate();
 }
 
@@ -54,17 +56,17 @@
 {
 	WeatherEffect::loadParams(root);
-  
-  LoadParam(root, "coord", this, LighteningEffect, coord);
-  LoadParam(root, "frequency", this, LighteningEffect, setFlashFrequency);
-  LoadParam(root, "const-time", this, LighteningEffect, setFlashConstTime);
-  LoadParam(root, "rising-time", this, LighteningEffect, setFlashRisingTime);
-  LoadParam(root, "size", this, LighteningEffect, setFlashSize);
-  LoadParam(root, "seed", this, LighteningEffect, setFlashSeed);
-  
-  LOAD_PARAM_START_CYCLE(root, element);
-  {
-    LoadParam_CYCLE(element, "option", this, LighteningEffect, setLighteningOption);
-  }
-  LOAD_PARAM_END_CYCLE(element);
+
+	LoadParam(root, "coord", this, LighteningEffect, coord);
+	LoadParam(root, "frequency", this, LighteningEffect, setFlashFrequency);
+	LoadParam(root, "const-time", this, LighteningEffect, setFlashConstTime);
+	LoadParam(root, "rising-time", this, LighteningEffect, setFlashRisingTime);
+	LoadParam(root, "size", this, LighteningEffect, setFlashSize);
+	LoadParam(root, "seed", this, LighteningEffect, setFlashSeed);
+
+	LOAD_PARAM_START_CYCLE(root, element);
+	{
+		LoadParam_CYCLE(element, "option", this, LighteningEffect, setLighteningOption);
+	}
+	LOAD_PARAM_END_CYCLE(element);
 }
 
@@ -72,94 +74,93 @@
 bool LighteningEffect::init()
 {
-  lighteningActivate = false;
-  
-  this->time = 0.0;
-  this->flashFrequency = 1.4f;
-  this->mainFrequency = 1.4f;
-  this->flashConstTime = 0.5f;
-  this->flashRisingTime = 0.1f;
-
-  this->width = 400.0f;
-  this->height = 100.0f;
-  this->seedWidth = 50;
-  this->seedHeight = 50;
-  this->bNewCoordinate = false;
-
-  this->seedX = 500.f;
-  this->seedZ = 1000.0f;
-  this->seedTime = 4.0f;
-
-  this->billboard[0] = new Billboard(NULL);
-  this->billboard[0]->setTexture("maps/lightning_bolt1.png");
-  this->billboard[0]->setSize(this->width, this->height);
-  this->billboard[0]->setVisibiliy(false);
-
-  this->billboard[1] = new Billboard(NULL);
-  this->billboard[1]->setTexture("maps/lightning_bolt2.png");
-  this->billboard[1]->setSize(this->width, this->height);
-  this->billboard[1]->setVisibiliy(false);
-
-  this->billboard[2] = new Billboard(NULL);
-  this->billboard[2]->setTexture("maps/lightning_bolt3.png");
-  this->billboard[2]->setSize(this->width, this->height);
-  this->billboard[2]->setVisibiliy(false);
-
-  this->billboard[3] = new Billboard(NULL);
-  this->billboard[3]->setTexture("maps/lightning_bolt4.png");
-  this->billboard[3]->setSize(this->width, this->height);
-  this->billboard[3]->setVisibiliy(false);
-  
-  if (this->lighteningMove)
-  {
-    this->cameraCoor = State::getCameraNode()->getAbsCoor();
-    this->billboard[0]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
-    this->billboard[1]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
-    this->billboard[2]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
-    this->billboard[3]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
-  }
-  else
-  {
-    this->billboard[0]->setAbsCoor(3000,850,0);
-    this->billboard[1]->setAbsCoor(3000,850,0);
-    this->billboard[2]->setAbsCoor(3000,850,0);
-    this->billboard[3]->setAbsCoor(3000,850,0);
-  }
-  
-  this->flashLight = new Light();
-  this->flashLight->setDiffuseColor(0,0,0);
-  this->flashLight->setSpecularColor(0,0,0);
-  
-/*
-  this->soundSource = NULL;
-  this->thunderBuffer = NULL;
-
-  this->soundSource.setSourceNode(this);
-
-  //load sound
-  if (this->thunderBuffer != NULL)
-    ResourceManager::getInstance()->unload(this->thunderBuffer);
-  this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);*/
+	//default values
+	this->lighteningActivate = false;
+	
+	this->time = 0.0;
+	this->flashFrequency = 1.4f;
+	this->mainFrequency = 1.4f;
+	this->flashConstTime = 0.5f;
+	this->flashRisingTime = 0.1f;
+	
+	this->width = 400.0f;
+	this->height = 100.0f;
+	this->seedWidth = 50;
+	this->seedHeight = 50;
+	this->bNewCoordinate = false;
+	
+	this->seedX = 500.f;
+	this->seedZ = 1000.0f;
+	this->seedTime = 4.0f;
+	
+	// initialize lightening textures
+	this->billboard[0] = new Billboard(NULL);
+	this->billboard[0]->setTexture("maps/lightning_bolt1.png");
+	this->billboard[0]->setSize(this->width, this->height);
+	this->billboard[0]->setVisibiliy(false);
+	
+	this->billboard[1] = new Billboard(NULL);
+	this->billboard[1]->setTexture("maps/lightning_bolt2.png");
+	this->billboard[1]->setSize(this->width, this->height);
+	this->billboard[1]->setVisibiliy(false);
+	
+	this->billboard[2] = new Billboard(NULL);
+	this->billboard[2]->setTexture("maps/lightning_bolt3.png");
+	this->billboard[2]->setSize(this->width, this->height);
+	this->billboard[2]->setVisibiliy(false);
+	
+	this->billboard[3] = new Billboard(NULL);
+	this->billboard[3]->setTexture("maps/lightning_bolt4.png");
+	this->billboard[3]->setSize(this->width, this->height);
+	this->billboard[3]->setVisibiliy(false);
+	
+	if (this->lighteningMove) {
+		this->cameraCoor = State::getCameraNode()->getAbsCoor();
+		this->billboard[0]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
+		this->billboard[1]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
+		this->billboard[2]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
+		this->billboard[3]->setAbsCoor(this->cameraCoor.x+3000,850,this->cameraCoor.z+0);
+	} else {
+		this->billboard[0]->setAbsCoor(3000,850,0);
+		this->billboard[1]->setAbsCoor(3000,850,0);
+		this->billboard[2]->setAbsCoor(3000,850,0);
+		this->billboard[3]->setAbsCoor(3000,850,0);
+	}
+	
+	this->flashLight = new Light();
+	this->flashLight->setDiffuseColor(0,0,0);
+	this->flashLight->setSpecularColor(0,0,0);
+	
+	/*
+	this->soundSource = NULL;
+	this->thunderBuffer = NULL;
+	
+	this->soundSource.setSourceNode(this);
+	
+	//load sound
+	if (this->thunderBuffer != NULL)
+	ResourceManager::getInstance()->unload(this->thunderBuffer);
+	this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);*/
+
+	return 0;
 }
 
 void LighteningEffect::coord(float x, float y, float z)
 {
-  if (this->lighteningMove)
-  {
-    this->cameraCoor = State::getCameraNode()->getAbsCoor();
-    this->billboard[0]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
-    this->billboard[1]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
-    this->billboard[2]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
-    this->billboard[3]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
-  }
-  else
-  {
-    this->billboard[0]->setAbsCoor(x, y, z);
-    this->billboard[1]->setAbsCoor(x, y, z);
-    this->billboard[2]->setAbsCoor(x, y, z);
-    this->billboard[3]->setAbsCoor(x, y, z);
-  }
-  this->mainPosX = x;
-  this->mainPosY = y;
-  this->mainPosZ = z;
+	if (this->lighteningMove) {
+		this->cameraCoor = State::getCameraNode()->getAbsCoor();
+		this->billboard[0]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
+		this->billboard[1]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
+		this->billboard[2]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
+		this->billboard[3]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
+	} else {
+		this->billboard[0]->setAbsCoor(x, y, z);
+		this->billboard[1]->setAbsCoor(x, y, z);
+		this->billboard[2]->setAbsCoor(x, y, z);
+		this->billboard[3]->setAbsCoor(x, y, z);
+	}
+
+	this->mainPosX = x;
+	this->mainPosY = y;
+	this->mainPosZ = z;
 }
 
@@ -167,12 +168,13 @@
 void LighteningEffect::setFlashSize(float width, float height, float seedWidth, float seedHeight)
 {
-  this->width = width;
-  this->height = height;
-  this->seedWidth = seedWidth;
-  this->seedHeight = seedHeight;
-  this->billboard[0]->setSize(this->width, this->height);
-  this->billboard[1]->setSize(this->width, this->height);
-  this->billboard[2]->setSize(this->width, this->height);
-  this->billboard[3]->setSize(this->width, this->height);
+	this->width = width;
+	this->height = height;
+	this->seedWidth = seedWidth;
+	this->seedHeight = seedHeight;
+
+	this->billboard[0]->setSize(this->width, this->height);
+	this->billboard[1]->setSize(this->width, this->height);
+	this->billboard[2]->setSize(this->width, this->height);
+	this->billboard[3]->setSize(this->width, this->height);
 }
 
@@ -181,6 +183,9 @@
 {
 	PRINTF(0)( "Activating LighteningEffect\n" );
-  this->time = 0;
-  lighteningActivate = true;
+	this->lighteningActivate = true;
+
+	this->time = 0;
+
+	return 0;
 }
 
@@ -189,88 +194,102 @@
 {
 	PRINTF(0)("Deactivating LighteningEffect\n");
-  this->billboard[0]->setVisibiliy(false);
-  this->billboard[1]->setVisibiliy(false);
-  this->billboard[2]->setVisibiliy(false);
-  this->billboard[3]->setVisibiliy(false);
-  lighteningActivate = false;
+	this->lighteningActivate = false;
+
+	this->billboard[0]->setVisibiliy(false);
+	this->billboard[1]->setVisibiliy(false);
+	this->billboard[2]->setVisibiliy(false);
+	this->billboard[3]->setVisibiliy(false);
+
+	return 0;
 }
 
 void LighteningEffect::tick (float dt)
 {
-  if(!lighteningActivate)
-    return;
-  
-  this->time += dt;
-  
-  if( this->time > this->flashFrequency)
-  {
-    this->billboard[0]->setVisibiliy(true);
-    this->time = 0.0f;
-
-    this->flashLight->setAbsCoor(this->billboard[0]->getAbsCoor().x, this->billboard[0]->getAbsCoor().y, this->billboard[0]->getAbsCoor().z);
-    this->flashLight->setDiffuseColor(1,1,1);
-    this->flashLight->setSpecularColor(1,1,1);
-    
-    //this->soundSource.play(this->thunderBuffer);
-  }
-  else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime)
-  {
-    this->billboard[3]->setVisibiliy(false);
-    this->time = 0.0f;
-    this->flashLight->setDiffuseColor(0,0,0);
-    this->flashLight->setSpecularColor(0,0,0);
-    this->bNewCoordinate = true;
-  }
-
-  if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime)
-  {
-    this->billboard[2]->setVisibiliy(false);
-    this->billboard[3]->setVisibiliy(true);
-   // this->flashLight->setDiffuseColor(1,1,1);
-   // this->flashLight->setSpecularColor(1,1,1);
-  }
-  else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 )
-  {
-    this->billboard[1]->setVisibiliy(false);
-    this->billboard[2]->setVisibiliy(true);
-    //this->flashLight->setDiffuseColor(0,0,0);
-    //this->flashLight->setSpecularColor(0,0,0);
-  }
-  else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 )
-  {
-    this->billboard[0]->setVisibiliy(false);
-    this->billboard[1]->setVisibiliy(true);
-    //this->flashLight->setDiffuseColor(1,1,1);
-    //this->flashLight->setSpecularColor(1,1,1);
-  }
-
-  if( this->bNewCoordinate)
-  {
-    float posX, posZ;
-    if(this->lighteningMove)
-    {
-    this->cameraCoor = State::getCameraNode()->getAbsCoor();
-    posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX + this->cameraCoor.x;
-    posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX + this->cameraCoor.z;
-    }
-    else
-    {
-      posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX;
-      posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX;
-    }
-    
-    this->billboard[0]->setAbsCoor(posX, this->mainPosY, posZ);
-    this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ);
-    this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ);
-    this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ);
-    this->flashFrequency = this->mainFrequency + this->seedTime * (float)rand()/(float)RAND_MAX;
-    float w = this->width + this->seedWidth * (float)rand()/(float)RAND_MAX;
-    float h = this->height + this->seedHeight * (float)rand()/(float)RAND_MAX;
-    this->billboard[0]->setSize(w, h);
-    this->billboard[1]->setSize(w, h);
-    this->billboard[2]->setSize(w, h);
-    this->billboard[3]->setSize(w, h);
-    this->bNewCoordinate = false;
-  }
+	if(!lighteningActivate)
+		return;
+	
+	this->time += dt;
+
+	// TODO: Make random flashing with short light dingsda:)
+	
+	if( this->time > this->flashFrequency) {
+	
+		this->billboard[0]->setVisibiliy(true);
+		this->time = 0.0f;
+	
+		this->flashLight->setAbsCoor(this->billboard[0]->getAbsCoor().x, this->billboard[0]->getAbsCoor().y, this->billboard[0]->getAbsCoor().z);
+
+		// flash environmental lightening
+		this->flashLight->setDiffuseColor(1,1,1);
+		this->flashLight->setSpecularColor(1,1,1);
+	
+		//this->soundSource.play(this->thunderBuffer);
+
+	} else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime) {
+	
+		this->billboard[3]->setVisibiliy(false);
+		this->time = 0.0f;
+		this->flashLight->setDiffuseColor(0,0,0);
+		this->flashLight->setSpecularColor(0,0,0);
+		this->bNewCoordinate = true;
+
+	}
+	
+	if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime) {
+	
+		this->billboard[2]->setVisibiliy(false);
+		this->billboard[3]->setVisibiliy(true);
+		// this->flashLight->setDiffuseColor(1,1,1);
+		// this->flashLight->setSpecularColor(1,1,1);
+		
+	} else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 ) {
+	
+		this->billboard[1]->setVisibiliy(false);
+		this->billboard[2]->setVisibiliy(true);
+		//this->flashLight->setDiffuseColor(0,0,0);
+		//this->flashLight->setSpecularColor(0,0,0);
+		
+	} else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 ) {
+	
+		this->billboard[0]->setVisibiliy(false);
+		this->billboard[1]->setVisibiliy(true);
+		//this->flashLight->setDiffuseColor(1,1,1);
+		//this->flashLight->setSpecularColor(1,1,1);
+		
+	}
+	
+	if( this->bNewCoordinate) {
+		float posX, posZ;
+
+		if(this->lighteningMove) {
+		
+			this->cameraCoor = State::getCameraNode()->getAbsCoor();
+			posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX + this->cameraCoor.x;
+			posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX + this->cameraCoor.z;
+
+		} else {
+		
+			posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX;
+			posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX;
+
+		}
+	
+		this->billboard[0]->setAbsCoor(posX, this->mainPosY, posZ);
+		this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ);
+		this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ);
+		this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ);
+		
+		this->flashFrequency = this->mainFrequency + this->seedTime * (float)rand()/(float)RAND_MAX;
+		
+		float w = this->width + this->seedWidth * (float)rand()/(float)RAND_MAX;
+		float h = this->height + this->seedHeight * (float)rand()/(float)RAND_MAX;
+		
+		this->billboard[0]->setSize(w, h);
+		this->billboard[1]->setSize(w, h);
+		this->billboard[2]->setSize(w, h);
+		this->billboard[3]->setSize(w, h);
+		
+		this->bNewCoordinate = false;
+	}
 }
 
Index: branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h	(revision 8372)
+++ branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h	(revision 8373)
@@ -13,5 +13,4 @@
 #include "sound_buffer.h"
 #include "sound_source.h"
-
 
 class Billboard;
@@ -31,58 +30,71 @@
 		virtual bool deactivate();
 
-    virtual void draw() const;
-    virtual void tick(float dt);
-    
-    void coord(float x, float y, float z);
-    void setFlashSize(float width, float height, float seedWidth, float seedHeight);
-    
-    inline void setLighteningOption(const std::string& option) { if (option == "activate") this->lighteningActivate = true;
-                                                                                         if (option == "movelightening") this->lighteningMove = true;}
-    inline void setFlashFrequency(float mainFrequency, float seedTime) { this->mainFrequency = mainFrequency;
-                                                                                                            this->flashFrequency = mainFrequency;
-                                                                                                            this->seedTime = seedTime; }
-    inline void setFlashConstTime(float flashConstTime) { this->flashConstTime = flashConstTime; }
-    inline void setFlashRisingTime(float flashRisingTime) { if(flashRisingTime > this->flashConstTime)
-                                                                                        this->flashRisingTime = this->flashConstTime/2;
-                                                                                      else
-                                                                                        this->flashRisingTime = flashRisingTime; }
-    inline void setFlashSeed(float seedX, float seedZ) { this->seedX = seedX;
-                                                                                  this->seedZ = seedZ; }
+		inline void activateLightening() { this->activate(); }
+		inline void deactivateLightening() { this->deactivate(); }
 
-    void activateLightening() { this->activate(); }
-    void deactivateLightening() { this->deactivate(); }
-    
+		virtual void draw() const;
+		virtual void tick(float dt);
+		
+		void coord(float x, float y, float z);
+		void setFlashSize(float width, float height, float seedWidth, float seedHeight);
+		
+		inline void setLighteningOption(const std::string& option) {
+			if (option == "activate") this->lighteningActivate = true;
+			if (option == "movelightening") this->lighteningMove = true;
+		}
+
+		inline void setFlashFrequency(float mainFrequency, float seedTime) {
+			this->mainFrequency = mainFrequency;
+			this->flashFrequency = mainFrequency;
+			this->seedTime = seedTime;
+		}
+		
+		inline void setFlashConstTime(float flashConstTime) { this->flashConstTime = flashConstTime; }
+
+		inline void setFlashRisingTime(float flashRisingTime) {
+			if(flashRisingTime > this->flashConstTime)
+				this->flashRisingTime = this->flashConstTime/2;
+			else
+				this->flashRisingTime = flashRisingTime;
+		}
+		
+		inline void setFlashSeed(float seedX, float seedZ) {
+			this->seedX = seedX;
+			this->seedZ = seedZ;
+		}
+		
+
 	private:
-    Billboard* billboard[4];
-    bool lighteningActivate;
-    bool lighteningMove;
-
-    float flashFrequency;
-    float mainFrequency;
-    float flashConstTime;
-    float flashRisingTime;
-
-    float time;
-
-    bool  bNewCoordinate;
-    float width;
-    float height;
-    float seedWidth;
-    float seedHeight;
-
-    float seedX;
-    float seedZ;
-    float seedTime;
-    
-    float mainPosX;
-    float mainPosY;
-    float mainPosZ;
-    
-    Vector cameraCoor;
-
-    Light* flashLight;
-    
-    //OrxSound::SoundSource    soundSource;
-    //OrxSound::SoundBuffer*   thunderBuffer;
+		Billboard* billboard[4];
+		bool lighteningActivate;
+		bool lighteningMove;
+		
+		float flashFrequency;
+		float mainFrequency;
+		float flashConstTime;
+		float flashRisingTime;
+		
+		float time;
+		
+		bool  bNewCoordinate;
+		float width;
+		float height;
+		float seedWidth;
+		float seedHeight;
+		
+		float seedX;
+		float seedZ;
+		float seedTime;
+		
+		float mainPosX;
+		float mainPosY;
+		float mainPosZ;
+		
+		Vector cameraCoor;
+		
+		Light* flashLight;
+		
+		//OrxSound::SoundSource    soundSource;
+		//OrxSound::SoundBuffer*   thunderBuffer;
 
 };
