Index: /branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
===================================================================
--- /branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc	(revision 7783)
+++ /branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc	(revision 7784)
@@ -19,6 +19,5 @@
 
 #include "glincl.h"
-#include "graphics_engine.h"
-
+//#include "graphics_engine.h"
 
 #include "parser/tinyxml/tinyxml.h"
@@ -48,4 +47,7 @@
 {
 	WeatherEffect::loadParams(root);
+
+	LoadParam(root, "animSpeed", this, CloudEffect, setCloudAnimation);
+
 }
 
@@ -53,32 +55,6 @@
 bool CloudEffect::init()
 {
-	//Default values
-
-	CloudEffect::setNoise(map32);
-
-}
-
-bool CloudEffect::activate()
-{
-	PRINTF(0)( "Activating CloudEffect\n");
-
-	//Our cloud function  
-	CloudEffect::overlapOctaves(map32, map256);
-	CloudEffect::expFilter(map256);
-
-	for(int i=0; i<256; i++)         //Set cloud color value to temporary array
-		for(int j=0; j<256; j++) 
-		{
-			float color = map256[i*256+j]; 
-			texture[i][j][0] = (char) color;
-			texture[i][j][1] = (char) color;
-			texture[i][j][2] = (char) color;
-		}
-
-		/* for(int n=0; n<256; n++) {
-			for(int i=0; i<256; i++)
-				PRINTF(0)("%f ", map256[n*i]);
-			PRINTF(0)("\n");
-		} */
+	// default values
+	this->cloudAnimTimeStep = 0;
 
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -87,21 +63,55 @@
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 
-	glGenTextures(1, &texID[0]);           //Texture binding 
+	// Generate noise map a
+	CloudEffect::genNoiseMap(cloudMap32_a);
+	
+	if (this->cloudAnimTimeStep > 0) {
+		// Generate noise map b
+		CloudEffect::genNoiseMap(cloudMap32_b);
+	}
+}
+
+bool CloudEffect::activate()
+{
+	PRINTF(0)( "Activating CloudEffect\n");
+	if (this->cloudAnimTimeStep == 0) {
+		for (int i = 0; i < 32*32; i++)
+			cloudMap32_c[i] = cloudMap32_a[i];
+
+		CloudEffect::overlapOctaves();
+		CloudEffect::expFilter();
+		CloudEffect::genCloudTexture();
+	}
+}
+
+bool CloudEffect::deactivate()
+{
+	PRINTF(0)("Deactivating CloudEffect\n");
+}
+
+void CloudEffect::genCloudTexture() {
+	for(int i=0; i<256; i++)
+		for(int j=0; j<256; j++) 
+		{
+			float color = cloudMap256[i*256+j]; 
+			cloudTexture[i][j][0] = (char) color;
+			cloudTexture[i][j][1] = (char) color;
+			cloudTexture[i][j][2] = (char) color;
+		}
+
+	glGenTextures(2, &texID[0]);
 	glBindTexture(GL_TEXTURE_2D, texID[0]);
-	
-	gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, texture);
-}
-
-
-bool CloudEffect::deactivate()
-{
-	PRINTF(0)("Deactivating CloudEffect\n");
+	gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, cloudTexture);
+}
+
+void CloudEffect::calcAnimMap(float timer) {
+
+	for (int x=0; x<32*32; x++)
+		cloudMap32_c[x] = (cloudMap32_a[x] * ((this->cloudAnimTimeStep - timer) / this->cloudAnimTimeStep)) + (cloudMap32_b[x] * (timer / this->cloudAnimTimeStep));
+
 }
 
 void CloudEffect::draw() const
 {
-	//glPushAttrib(GL_ENABLE_BIT);
-	//glMatrixMode(GL_MODELVIEW);
-
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -109,14 +119,8 @@
 	glEnable(GL_TEXTURE_2D);
 
-	//glLoadIdentity();
 	glBindTexture(GL_TEXTURE_2D, texID[0]);
 
-	//glMatrixMode(GL_TEXTURE);        //Let's move the clouds from left to right
-	//static float x;    
-	//x+=0.01f;
-	//glTranslatef(x,0,0);
-
+	// FIXME : Bind this to the sky - how do I do this?
 	glBegin(GL_QUADS);
-		// Front Face
 		glTexCoord2f(0.0f, 0.0f); glVertex3f(20, 20,  60);	// Bottom Left Of The Texture and Quad
 		glTexCoord2f(1.0f, 0.0f); glVertex3f(60, 20,  60);	// Bottom Right Of The Texture and Quad
@@ -126,10 +130,25 @@
 
 	glPopMatrix();
-	//glPopAttrib();
-
 }
 
 void CloudEffect::tick (float dt)
 {
+	if (this->cloudAnimTimeStep > 0) {
+		if (timer >= this->cloudAnimTimeStep) {
+			timer -= this->cloudAnimTimeStep;
+			for (int i = 0; i < 32*32; i++)
+				cloudMap32_a[i] = cloudMap32_b[i];
+			CloudEffect::genNoiseMap(cloudMap32_b);
+		}
+
+		//map32anim = (map32a * (10 - timer)) + (map32b * timer);
+		CloudEffect::calcAnimMap(timer);
+
+		CloudEffect::overlapOctaves();
+		CloudEffect::expFilter();
+		CloudEffect::genCloudTexture();
+
+		timer += dt;
+	}
 }
 
@@ -148,9 +167,7 @@
 	Set noise for the 32*32 noise map:
 */
-void CloudEffect::setNoise(float  *map)
+void CloudEffect::genNoiseMap(float  *map)
 {
 	float temp[34][34];
-
-/* We declare a temporary array to make our function cleaner. Why does the array hold 34*34 elements instead of 32*32? This is because we will need extra elements for side and corner mirroring, as we shall see soon. */
 
 	int random = rand() % 5000;
@@ -181,5 +198,5 @@
 			float corners = (temp[x+1][y+1] + temp[x+1][y-1] + temp[x-1][y+1] + temp[x-1][y-1])/16.0f;
 
-			map32[((x-1)*32) + (y-1)] = center + sides + corners;
+			map[((x-1)*32) + (y-1)] = center + sides + corners;
 		}
 }
@@ -211,9 +228,9 @@
 	Octaves are overlapped together to give cloud more turbulence. We will use four octaves for our cloud.
 */
-void CloudEffect::overlapOctaves(float  *map32, float  *map256)
+void CloudEffect::overlapOctaves()
 {
 	for (int x=0; x<256*256; x++)
 	{
-		map256[x] = 0;
+		cloudMap256[x] = 0;
 	}
 
@@ -223,9 +240,9 @@
 			{
 				float scale = 1 / pow(2, 3-octave);
-				float noise = CloudEffect::interpolate(x*scale, y*scale , map32);
+				float noise = CloudEffect::interpolate(x*scale, y*scale , cloudMap32_c);
 
 				//The octaves are added together with the proper weight factors.
 				//You could replace pow(2, i) with 1<<i for faster computation
-				map256[(y*256) + x] += noise / pow(2, octave);
+				cloudMap256[(y*256) + x] += noise / pow(2, octave);
 			}
 }
@@ -235,5 +252,5 @@
 	Filter the noise with exponential function
 */
-void CloudEffect::expFilter(float  *map)
+void CloudEffect::expFilter()
 {
 	float cover = 20.0f;
@@ -242,7 +259,9 @@
 	for (int x=0; x<256*256; x++)
 	{
-		float c = map[x] - (255.0f-cover);
+		float c = cloudMap256[x] - (255.0f-cover);
 		if (c<0)     c = 0;
-		map[x] = 255.0f - ((float)(pow(sharpness, c))*255.0f);
-	}
-}
+		cloudMap256[x] = 255.0f - ((float)(pow(sharpness, c))*255.0f);
+	}
+}
+
+
Index: /branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
===================================================================
--- /branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h	(revision 7783)
+++ /branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h	(revision 7784)
@@ -30,19 +30,31 @@
 		virtual void tick(float dt);
 
+		inline void setCloudAnimation(float timestep) { this->cloudAnimTimeStep = timestep; }
+
 	private:
-		// Basic noise map 32x32
-		float map32[32 * 32];
+		// Basic noise maps 32x32
+		float 														cloudMap32_a[32 * 32];
+		float 														cloudMap32_b[32 * 32];
+		float 														cloudMap32_c[32 * 32];
 
-		// The cloud map
-		float map256[256 * 256];
+		// The cloud map 256x256
+		float 														cloudMap256[256 * 256];
 
-		char texture[256][256][3];       //Temporary array to hold texture RGB values 
+		// Temporary array to hold texture RGB values 
+		char 															cloudTexture[256][256][3];
 
-		float noise(int x, int y, int random);
-		void setNoise(float  *map);
-		float interpolate(float x, float y, float  *map);
-		void overlapOctaves(float  *map32, float  *map256);
-		void expFilter(float  *map);
-		GLuint texID[1];
+		GLuint 														texID[2];
+		float 														timer;
+
+		bool															cloudAnimTimeStep;
+
+		float 														noise(int x, int y, int random);
+		float 														interpolate(float x, float y, float  *map);
+		void  														overlapOctaves();
+		void  														expFilter();
+
+		void  														genNoiseMap(float  *map);
+		void  														genCloudTexture();
+		void  														calcAnimMap(float timer);
 
 };
Index: /branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc
===================================================================
--- /branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc	(revision 7783)
+++ /branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc	(revision 7784)
@@ -74,5 +74,4 @@
 	WeatherEffect::loadParams(root);
 
-	// LoadParam(root, "moverain", this, RainEffect, setMoveRain);
 	LoadParam(root, "coord", this, RainEffect, setRainCoord);
 	LoadParam(root, "size", this, RainEffect, setRainSize);
